]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: Move omp requires checks to libgomp
authorTobias Burnus <tobias@codesourcery.com>
Mon, 4 Jul 2022 11:51:02 +0000 (13:51 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Mon, 4 Jul 2022 11:52:02 +0000 (13:52 +0200)
commit683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
tree6464c7a452dd52c98ef5d08071d552ecd4e42276
parent10b502fb78351a4073b6682c026a92c82d3da6c5
OpenMP: Move omp requires checks to libgomp

Handle reverse_offload, unified_address, and unified_shared_memory
requirements in libgomp by saving them alongside the offload table.
When the device lto1 runs, it extracts the data for mkoffload. The
latter than passes the value on to GOMP_offload_register_ver.

lto1 (either the host one, with -flto [+ ENABLE_OFFLOADING], or in the
offload-device lto1) also does the the consistency check is done,
erroring out when the 'omp requires' clause use is inconsistent.

For all in-principle supported devices, if a requirement cannot be fulfilled,
the device is excluded from the (supported) devices list. Currently, none of
those requirements are marked as supported for any of the non-host devices.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_target_data, c_parser_omp_target_update,
c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Set
OMP_REQUIRES_TARGET_USED.
(c_parser_omp_requires): Remove sorry.

gcc/ChangeLog:

* config/gcn/mkoffload.cc (process_asm): Write '#include <stdint.h>'.
(process_obj): Pass omp_requires_mask to GOMP_offload_register_ver.
(main): Ask lto1 to obtain omp_requires_mask and pass it on.
* config/nvptx/mkoffload.cc (process, main): Likewise.
* lto-cgraph.cc (omp_requires_to_name): New.
(input_offload_tables): Save omp_requires_mask.
(output_offload_tables): Read it, check for consistency,
save value for mkoffload.
* omp-low.cc (lower_omp_target): Force output_offloadtables
call for OMP_REQUIRES_TARGET_USED.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_target_data,
cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data,
cp_parser_omp_target_update): Set OMP_REQUIRES_TARGET_USED.
(cp_parser_omp_requires): Remove sorry.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_match_omp_requires): Remove sorry.
* parse.cc (decode_omp_directive): Don't regard 'declare target'
as target usage for 'omp requires'; add more flags to
omp_requires_mask.

include/ChangeLog:

* gomp-constants.h (GOMP_VERSION): Bump to 2.
(GOMP_REQUIRES_UNIFIED_ADDRESS, GOMP_REQUIRES_UNIFIED_SHARED_MEMORY,
GOMP_REQUIRES_REVERSE_OFFLOAD, GOMP_REQUIRES_TARGET_USED):
New defines.

libgomp/ChangeLog:

* libgomp-plugin.h (GOMP_OFFLOAD_get_num_devices): Add
omp_requires_mask arg.
* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Likewise;
return -1 when device available but omp_requires_mask != 0.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices): Likewise.
* oacc-host.c (host_get_num_devices, host_openacc_get_property):
Update call.
* oacc-init.c (resolve_device, acc_init_1, acc_shutdown_1,
goacc_attach_host_thread_to_device, acc_get_num_devices,
acc_set_device_num, get_property_any): Likewise.
* target.c (omp_requires_mask): New global var.
(gomp_requires_to_name): New.
(GOMP_offload_register_ver): Handle passed omp_requires_mask.
(gomp_target_init): Handle omp_requires_mask.
* libgomp.texi (OpenMP 5.0): Update requires impl. status.
(OpenMP 5.1): Add a missed item.
(OpenMP 5.2): Mark linear-clause change as supported in C/C++.
* testsuite/libgomp.c-c++-common/requires-1-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-1.c: New test.
* testsuite/libgomp.c-c++-common/requires-2-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-2.c: New test.
* testsuite/libgomp.c-c++-common/requires-3-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-3.c: New test.
* testsuite/libgomp.c-c++-common/requires-4-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-4.c: New test.
* testsuite/libgomp.c-c++-common/requires-5-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-5.c: New test.
* testsuite/libgomp.c-c++-common/requires-6.c: New test.
* testsuite/libgomp.c-c++-common/requires-7-aux.c: New test.
* testsuite/libgomp.c-c++-common/requires-7.c: New test.
* testsuite/libgomp.fortran/requires-1-aux.f90: New test.
* testsuite/libgomp.fortran/requires-1.f90: New test.

liboffloadmic/ChangeLog:

* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_num_devices):
Return -1 when device available but omp_requires_mask != 0.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/requires-4.c: Update dg-*.
* c-c++-common/gomp/reverse-offload-1.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-2.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-3.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-4.c: Likewise.
* c-c++-common/gomp/target-device-ancestor-5.c: Likewise.
* gfortran.dg/gomp/target-device-ancestor-3.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-4.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-5.f90: Likewise.
* gfortran.dg/gomp/target-device-ancestor-2.f90: Likewise. Move
post-FE checks to ...
* gfortran.dg/gomp/target-device-ancestor-2a.f90: ... this new file.
* gfortran.dg/gomp/requires-8.f90: Update as we don't regard
'declare target' for the 'requires' usage requirement.

Co-authored-by: Chung-Lin Tang <cltang@codesourcery.com>
Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
44 files changed:
gcc/c/c-parser.cc
gcc/config/gcn/mkoffload.cc
gcc/config/nvptx/mkoffload.cc
gcc/cp/parser.cc
gcc/fortran/openmp.cc
gcc/fortran/parse.cc
gcc/lto-cgraph.cc
gcc/omp-low.cc
gcc/testsuite/c-c++-common/gomp/requires-4.c
gcc/testsuite/c-c++-common/gomp/reverse-offload-1.c
gcc/testsuite/c-c++-common/gomp/target-device-ancestor-2.c
gcc/testsuite/c-c++-common/gomp/target-device-ancestor-3.c
gcc/testsuite/c-c++-common/gomp/target-device-ancestor-4.c
gcc/testsuite/c-c++-common/gomp/target-device-ancestor-5.c
gcc/testsuite/gfortran.dg/gomp/requires-8.f90
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-2.f90
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-2a.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-3.f90
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-4.f90
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-5.f90
include/gomp-constants.h
libgomp/libgomp-plugin.h
libgomp/libgomp.texi
libgomp/oacc-host.c
libgomp/oacc-init.c
libgomp/plugin/plugin-gcn.c
libgomp/plugin/plugin-nvptx.c
libgomp/target.c
libgomp/testsuite/libgomp.c-c++-common/requires-1-aux.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-2-aux.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-2.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-3-aux.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-3.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-4-aux.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-4.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-5-aux.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-5.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-6.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-7-aux.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/requires-7.c [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/requires-1-aux.f90 [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/requires-1.f90 [new file with mode: 0644]
liboffloadmic/plugin/libgomp-plugin-intelmic.cpp