]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: Move omp requires checks to libgomp
authorTobias Burnus <tobias@codesourcery.com>
Tue, 5 Jul 2022 13:31:01 +0000 (15:31 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 5 Jul 2022 14:03:31 +0000 (16:03 +0200)
commit5e7baa3c8875018d94e4222bb26c42a72c7499cb
treec088cb71151288d0f8768ca9e2169aa1c4130096
parentf2cf3109e3eb14a8a64534a9f67a0b53b6272f52
OpenMP: Move omp requires checks to libgomp

This commit reverts OG12 commits
   commit 6ab6303f61c812d6e2f05d44af5cc79815c57bb8
   'OpenMP 5.0: requires directive'
and
   commit 47e5ba646c20fdb64fa233dd570f155880cafd04
   '[WIP] OpenMP 5.0: requires directive: workaround to fix libgomp IntelMIC plugin build'

And replaces those by the upstream version, commit r13-1458, i.e.
(cherry picked from commit 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0)

It also updates
* libgomp/plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices)
to permit GOMP_REQUIRES_UNIFIED_ADDRESS | GOMP_REQUIRES_UNIFIED_SHARED_MEMORY,
moved from the now no-longer existing function GOMP_OFFLOAD_supported_features;
the flags were added in OG12 commit 12d14a9a255c1cc10e4506935327aabd9766967d,
'amdgcn: libgomp plugin USM implementation'.

And, likewise, it updates
* libgomp/plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices)
from OG12 commit f3fd38e31fafdc7f6b6a721b53bdc595c4ec1e09,
'libgomp, nvptx: report USM'.

 * * *

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>
50 files changed:
gcc/ChangeLog.omp
gcc/c/ChangeLog.omp
gcc/c/c-parser.cc
gcc/config/gcn/mkoffload.cc
gcc/config/nvptx/mkoffload.cc
gcc/cp/ChangeLog.omp
gcc/cp/parser.cc
gcc/fortran/ChangeLog.omp
gcc/fortran/openmp.cc
gcc/fortran/parse.cc
gcc/lto-cgraph.cc
gcc/omp-low.cc
gcc/omp-offload.cc
gcc/testsuite/ChangeLog.omp
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-5.c
gcc/testsuite/gfortran.dg/gomp/requires-8.f90
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-2a.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/target-device-ancestor-5.f90
include/ChangeLog.omp
include/gomp-constants.h
libgcc/ChangeLog.omp
libgcc/offloadstuff.c
libgomp/ChangeLog.omp
libgomp/libgomp-plugin.h
libgomp/libgomp.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
libgomp/testsuite/libgomp.c-c++-common/requires-1.c
libgomp/testsuite/libgomp.c-c++-common/requires-2-aux.c
libgomp/testsuite/libgomp.c-c++-common/requires-2.c
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/ChangeLog.omp
liboffloadmic/plugin/libgomp-plugin-intelmic.cpp