Hi Sandra,
Sandra Loosemore wrote:
This patch adds support for the case where #pragma omp declare variant
with append_args is used inside a #pragma omp dispatch interop that
specifies fewer interop args than required by the variant; new interop
objects are implicitly created and then destroyed around the call to the
variant, using the GOMP_interop builtin.
Thanks for the patch! It mostly looks okay, but I found two issues.
(A) Result without 'device' clause
(That likely happened as this part of code was in a flux
and only settled late in the GOMP_interop patch.)
Background:
GCC's behavior of the default device is a bit confusing as
-1 was original "= not specified", i.e. the current
default device.
But then OpenMP 5.2 (or was it 5.1?) added omp_initial_device == -1
and omp_invalid_device.
Thus, GCC now suddenly needs to handle special: An absent argument
and a user-specified omp_initial_device cannot both map to -1.
New:
OpenMP 6.1 will additionally add 'omp_default_device' as constant.
In anticipation of that change, the GOMP_interop patch
already added internally support for it - and uses it:
GOMP_DEVICE_DEFAULT_OMP_61 (== -5) is what will become
omp_default_device, but it is not yet exposed to the user
via omp.h/omp_lib.
Thus, please useGOMP_DEVICE_DEFAULT_OMP_61 for:
+ if (dispatch_device_num == NULL_TREE)
+ /* Not remapping device number. */
+ dispatch_device_num = build_int_cst (integer_type_node,
+ GOMP_DEVICE_ICV);
* * *
(B) prefer_type & Fortran
The other issue is exposed by the attached testcase. It has
append_args(interop(target),
interop(prefer_type("cuda","hip"), targetsync),
interop(target,targetsync,prefer_type({attr("ompx_foo")})))
but the prefer_type is not passed on.
I assume that's my fault by not handling it correctly in
gcc/fortran/trans-openmp.cc, but if you could have a look?
(The C testcase works, i.e. it really must be my fault!)
And I am delighted that VALUE is correctly handled. :-)
Otherwise, the patch looks good to me.
Thanks!
Tobias
PS: Reminder (also to self):
We need to fix prefer_type with C++ templates as
exposed by testcase g++.dg/gomp/append-args-1.C.
PPS: As we now have runtime support, someone (myself?)
should write a libgomp/testsuite/ runtime check for this.
module m
use omp_lib
contains
subroutine g(x,y,z)
integer(omp_interop_kind) :: x, y, z
value :: y
end
subroutine f()
!$omp declare variant(f: g) append_args(interop(target), interop(prefer_type("cuda","hip"), targetsync), interop(target,targetsync,prefer_type({attr("ompx_foo")}))) match(construct={dispatch})
end
end
use m
!$omp dispatch
call f()
!$omp dispatch device(99)
call f()
end