diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2024-09-24 10:53:59 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2024-09-24 10:53:59 +0200 |
commit | b752eed3e3f2f27570ea89b7c2339468698472a8 (patch) | |
tree | f09990037b25102e5e209a062d8cf13bea5e3f01 /libgomp/testsuite/libgomp.fortran | |
parent | 7e560ffd7562cbd1a51ae6298c515b89ebed1363 (diff) | |
download | gcc-b752eed3e3f2f27570ea89b7c2339468698472a8.zip gcc-b752eed3e3f2f27570ea89b7c2339468698472a8.tar.gz gcc-b752eed3e3f2f27570ea89b7c2339468698472a8.tar.bz2 |
OpenMP: Add support for 'self_maps' to the 'require' directive
'self_maps' implies 'unified_shared_memory', except that the latter
also permits that explicit maps copy data to device memory while
self_maps does not. In GCC, currently, both are handled identical.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_requires): Handle self_maps clause.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_requires): Handle self_maps clause.
gcc/fortran/ChangeLog:
* gfortran.h (enum gfc_omp_requires_kind): Add OMP_REQ_SELF_MAPS.
(gfc_namespace): Enlarge omp_requires bitfield.
* module.cc (enum ab_attribute, attr_bits): Add AB_OMP_REQ_SELF_MAPS.
(mio_symbol_attribute): Handle it.
* openmp.cc (gfc_check_omp_requires, gfc_match_omp_requires): Handle
self_maps clause.
* parse.cc (gfc_parse_file): Handle self_maps clause.
gcc/ChangeLog:
* lto-cgraph.cc (output_offload_tables, omp_requires_to_name): Handle
self_maps clause.
* omp-general.cc (struct omp_ts_info, omp_context_selector_matches):
Likewise for the associated trait.
* omp-general.h (enum omp_requires): Add OMP_REQUIRES_SELF_MAPS.
* omp-selectors.h (enum omp_ts_code): Add
OMP_TRAIT_IMPLEMENTATION_SELF_MAPS.
include/ChangeLog:
* gomp-constants.h (GOMP_REQUIRES_SELF_MAPS): #define.
libgomp/ChangeLog:
* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices):
Accept self_maps clause.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices):
Likewise.
* libgomp.texi (TR13 Impl. Status): Set to 'Y'.
* target.c (gomp_requires_to_name, GOMP_offload_register_ver,
gomp_target_init): Handle self_maps clause.
* testsuite/libgomp.fortran/self_maps.f90: New test.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/declare-variant-1.c: Add self_maps test.
* c-c++-common/gomp/requires-4.c: Likewise.
* gfortran.dg/gomp/declare-variant-3.f90: Likewise.
* c-c++-common/gomp/requires-2.c: Update dg-error msg.
* gfortran.dg/gomp/requires-2.f90: Likewise.
* gfortran.dg/gomp/requires-self-maps-aux.f90: New.
* gfortran.dg/gomp/requires-self-maps.f90: New.
Diffstat (limited to 'libgomp/testsuite/libgomp.fortran')
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/self_maps.f90 | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/self_maps.f90 b/libgomp/testsuite/libgomp.fortran/self_maps.f90 new file mode 100644 index 0000000..208fd1c --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/self_maps.f90 @@ -0,0 +1,49 @@ +! Basic test whether self_maps work + +module m + !$omp requires self_maps + implicit none (type, external) + type t + integer :: val + type(t), pointer :: next + end type t +contains + subroutine init(p) + integer :: i + type(t), pointer :: p, x + allocate(x) + p => x + do i = 1, 5 + x%val = i + if (i < 5) then + allocate(x%next) + x => x%next + end if + end do + end subroutine + + subroutine check(p) + !$omp declare target enter(check) + integer :: i + type(t), pointer :: p, x + x => p + do i = 1, 5 + if (x%val /= i) stop 1 + x => x%next + end do +end subroutine +end module + +use omp_lib +use m +implicit none (type, external) +type(t), pointer :: linked +integer :: i + +call init(linked) +do i = 0, omp_get_num_devices() + !$omp target device(i) + call check(linked) + !$omp end target +end do +end |