]> git.ipfire.org Git - thirdparty/gcc.git/commit
libgomp, openmp: Add ompx_gnu_pinned_mem_alloc
authorAndrew Stubbs <ams@baylibre.com>
Wed, 12 Jun 2024 11:09:33 +0000 (11:09 +0000)
committerAndrew Stubbs <ams@baylibre.com>
Mon, 1 Jul 2024 10:59:59 +0000 (10:59 +0000)
commit64001441ec99b80e457188ce50bb6c59c757d3c6
tree7ce8527b53b7bc8bfe02471ac966a4da35e4e938
parent90efaebf95c93244f6b1eda5cb8724e52047cecd
libgomp, openmp: Add ompx_gnu_pinned_mem_alloc

This creates a new predefined allocator as a shortcut for using pinned
memory with OpenMP.  This is not in the OpenMP standard so it uses the "ompx"
namespace and an independent enum baseline of 200 (selected to not clash with
other known implementations).

The allocator is equivalent to using a custom allocator with the pinned
trait and the null fallback trait.  One motivation for having this feature is
for use by the (planned) -foffload-memory=pinned feature.

gcc/fortran/ChangeLog:

* openmp.cc (is_predefined_allocator): Update valid ranges to
incorporate ompx_gnu_pinned_mem_alloc.

libgomp/ChangeLog:

* allocator.c (ompx_gnu_min_predefined_alloc): New.
(ompx_gnu_max_predefined_alloc): New.
(predefined_alloc_mapping): Rename to ...
(predefined_omp_alloc_mapping): ... this.
(predefined_ompx_gnu_alloc_mapping): New.
(_Static_assert): Adjust for the new name, and add a new assert for the
new table.
(predefined_allocator_p): New.
(predefined_alloc_mapping): New.
(omp_aligned_alloc): Support ompx_gnu_pinned_mem_alloc.
Use predefined_allocator_p and predefined_alloc_mapping.
(omp_free): Likewise.
(omp_alligned_calloc): Likewise.
(omp_realloc): Likewise.
* env.c (parse_allocator): Add ompx_gnu_pinned_mem_alloc.
* libgomp.texi: Document ompx_gnu_pinned_mem_alloc.
* omp.h.in (omp_allocator_handle_t): Add ompx_gnu_pinned_mem_alloc.
* omp_lib.f90.in: Add ompx_gnu_pinned_mem_alloc.
* omp_lib.h.in: Add ompx_gnu_pinned_mem_alloc.
* testsuite/libgomp.c/alloc-pinned-5.c: New test.
* testsuite/libgomp.c/alloc-pinned-6.c: New test.
* testsuite/libgomp.fortran/alloc-pinned-1.f90: New test.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/allocate-pinned-1.f90: New test.

Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
gcc/fortran/openmp.cc
gcc/testsuite/gfortran.dg/gomp/allocate-pinned-1.f90 [new file with mode: 0644]
libgomp/allocator.c
libgomp/env.c
libgomp/libgomp.texi
libgomp/omp.h.in
libgomp/omp_lib.f90.in
libgomp/omp_lib.h.in
libgomp/testsuite/libgomp.c/alloc-pinned-5.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/alloc-pinned-6.c [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/alloc-pinned-1.f90 [new file with mode: 0644]