[patch][OpenMP,Fortran] Fix trans-openmp.c, add use_device_addr run-time test case (has known issues with actual offloading)
This use_device_addr patch does:
* Add trivial but crucial missing change to "fortran/trans-openmp.c (Ups!)
* Add a comprehensive set of test cases (only scalars and
* The test cases are known to mishandle "cc/dd/ee/ff" (= scalars with
allocatable + pointer attribute). That's only visible with actual
offloading as with shared memory the errors cancel and it works.
* OpenMP spec: As the test case shows, "is_device_ptr" with
"type(c_ptr), VALUE" would be nice; but OpenMP's spec for is_device_ptr
only permits dummy arguments without VALUE attribute.
* Known shortcomings (omp-low.c implementation; not tested for): arrays
with descriptor (alloctable/pointer arrays), absent optional variables,
polymorphic variables. [For the first two, draft patches exist.]
Comments, esp. to the test case?
PS: My next planned task is to fix the "scalars with allocatable +
pointer attribute" issue revealed in this case.
> @@ -11678,7 +11680,18 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
> - var = build_fold_addr_expr (var);
> + // While MAP is handled explicitly by the FE,
> + // for 'target update', only the identified is passed.
omp-low.c (like most of gcc/*.c) uses /* ... */ comments almost everywhere,
can you please just use the same here?
Otherwise the non-test part LGTM.
What worries me about the test is that the officially only portable way
to use it in a target region is is_device_ptr. I believe the intention was
to allow the implementation to transform the pointers from e.g.
use_device_ptr to whatever the implementation wants, where it could be e.g.
a structure containing pointer and something or whatever and is_device_ptr
actually finishing it up, even when in our implementation is_device_ptr is
basically just copying the pointer bits from host to device (==
Yes, I know there is the restriction that the is_device_ptr list item must
be a dummy variable without VALUE/ALLOCATABLE/POINTER. VALUE itself
wouldn't be a big deal, we could call just by reference instead of value,
but allocatable/pointer I bet is a problem. So, if there is no portable
way in Fortran to pass c_loc result as a dummy argument to some subprogram
where the dummy argument is not allocatable/pointer, and the caller doesn't
access the actual data in any way, I'm afraid we need to do what you are
doing. But then the test should start with a comment that it is not
portable and assumes that is_device_ptr doesn't need to transform the
use_device_ptr addresses in any way. Or another option would be to use C
code for the actual target region, c_loc is for C pointers and if you pass
to C code the c_loc as a pointer and pass in the array size/whatever else it
needs to know, it can then implement it portably with is_device_ptr clause
on the C pointer.