[Patch][fortran,omp-low.c] Fix OpenMP's use_device_ptr clause with array descriptors

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Patch][fortran,omp-low.c] Fix OpenMP's use_device_ptr clause with array descriptors

Tobias Burnus-3
Hi all,

using

!$omp target data map(A) use_device_ptr(A)
call foo(c_loc(A))
!$omp end target data

fails on trunk if "A" is not a simple pointer but an array with descriptor.

For the use_device_ptr clause, one needs to replace the host pointer
address by the address on the device (done by calling libgomp's
GOMP_target_data_ext). For array pointers, that's not directly "A" but
"A.data" which needs to be updated.

That's what the patch does. I think I covered all cases in the testsuite
– but I might have missed some.

"use_device_addr" might also need some changes, but as gfortran
(contrary to g++/gcc and omp-low.c) does not support it, yet, I have not
tested it.


"is_device_addr" is tested in the run-time test case. Quoting OpenMP 5's
"2.12.5 target Construct": "A list item that appears in an is_device_ptr
clause must be a dummy argument that does not have the ALLOCATABLE,
POINTER or VALUE attribute."

As that test case (commented parts) shows, this is currently one of
those things which are not tested at compile time – and not handled at
run time (ICE). In this patch round, I have not attempted to fix it.
Normally array-descriptor dummy arguments are immediately converted
using: "dummy.0 = dummy->data" (happens during the array-bounds
remapping). As "from.0" is what arrives in omp-low.c, that one can be
handled flawlessly.


I have tested the patch without offloading support on my laptop – and on
the server which actually supports nvptx offloading (both:
x86_64-gnu-linux).

I am sure, there will be many suggestions how things should be done
better. Still:
OK for the trunk?

Thanks,

Tobias

PS: A follow-up work is to add support for the "use_device_addr" clause
and adding a bunch of argument checks; albeit, I do _not_ intent to do
it as immediate follow-up patch.


use_device_ptr-trunk-v3.diff (52K) Download Attachment