]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: need_device_ptr and need_device_addr support for adjust_args
authorSandra Loosemore <sloosemore@baylibre.com>
Wed, 30 Apr 2025 17:46:31 +0000 (17:46 +0000)
committerSandra Loosemore <sloosemore@baylibre.com>
Wed, 30 Apr 2025 17:46:31 +0000 (17:46 +0000)
commit9a06e4d6a117497c2536bf89bb6c7536289e44bb
treea77de63119da6865f92c841b7a39caa2fe6560e1
parent97067daf1d8e90e3b618ec7fd341a8b2395a6d35
OpenMP: need_device_ptr and need_device_addr support for adjust_args

This patch adds support for the "need_device_addr" modifier to the
"adjust args" clause for the "declare variant" directive, and
extends/re-works the support for "need_device_ptr" as well.

This patch builds on waffl3x's recently posted patch, "OpenMP: C/C++
adjust-args numeric ranges", here.

https://gcc.gnu.org/pipermail/gcc-patches/2025-April/681806.html

In C++, "need_device_addr" supports mapping reference arguments to
device pointers.  In Fortran, it similarly supports arguments passed
by reference, the default for the language, in contrast to
"need_device_ptr" which is used to map arguments of c_ptr type.  The
C++ support is straightforward, but Fortran has some additional
wrinkles involving arrays passed by descriptor (a new descriptor must
be constructed with a pointer to the array data which is the only part
mapped to the device), plus special cases for passing optional
arguments and a whole array instead of a reference to its first element.

gcc/cp/ChangeLog
* parser.cc (cp_finish_omp_declare_variant): Adjust error messages.

gcc/fortran/ChangeLog
* trans-openmp.cc (gfc_trans_omp_declare_variant): Disallow
polymorphic and optional arguments with need_device_addr for now, but
don't reject need_device_addr entirely.

gcc/ChangeLog
* gimplify.cc (modify_call_for_omp_dispatch): Rework logic for
need_device_ptr and need_device_addr adjustments.

gcc/testsuite/Changelog
* c-c++-common/gomp/adjust-args-10.c: Ignore the new sorry since the
lack of proper diagnostic is already xfail'ed.
* g++.dg/gomp/adjust-args-1.C: Adjust output patterns.
* g++.dg/gomp/adjust-args-17.C: New.
* gcc.dg/gomp/adjust-args-3.c: New.
* gfortran.dg/gomp/adjust-args-14.f90: Don't expect this to fail now.

libgomp/ChangeLog
* libgomp.texi: Mark need_device_addr as supported.
* testsuite/libgomp.c-c++-common/dispatch-3.c: New.
* testsuite/libgomp.c++/need-device-ptr.C: New.
* testsuite/libgomp.fortran/adjust-args-array-descriptor.f90: New.
* testsuite/libgomp.fortran/need-device-ptr.f90: New.

Co-Authored-By: Tobias Burnus <tburnus@baylibre.com>
13 files changed:
gcc/cp/parser.cc
gcc/fortran/trans-openmp.cc
gcc/gimplify.cc
gcc/testsuite/c-c++-common/gomp/adjust-args-10.c
gcc/testsuite/g++.dg/gomp/adjust-args-1.C
gcc/testsuite/g++.dg/gomp/adjust-args-17.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/adjust-args-3.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/adjust-args-14.f90
libgomp/libgomp.texi
libgomp/testsuite/libgomp.c++/need-device-ptr.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/dispatch-3.c [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/adjust-args-array-descriptor.f90 [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/need-device-ptr.f90 [new file with mode: 0644]