[PR90743] Fortran 'allocatable' with OpenACC data/OpenMP 'target' 'map' clauses: 'declare'

Thomas Schwinge thomas@codesourcery.com
Fri Jun 21 11:46:00 GMT 2019


Hi!

On Wed, 05 Jun 2019 11:25:07 +0200, I wrote:
> I [...] had a look at what OpenMP 5.0
> is saying about Fortran 'allocatable' in 'map' clauses [...]

Will you (Jakub, and/or Fortran guys), please have a look at the attached
test case.

If I disable the '!$omp declare target (ar)', then this works with
offloading enabled, otherwise it fails, and here is my understanding what
happens.

With '!$omp declare target (ar)' active, the array descriptor globally
gets allocated on the device, via the 'offload_vars' handling in
'gcc/omp-offload.c' etc.

Then, in 'gcc/omp-low.c:scan_sharing_clauses', the 'GOMP_MAP_TO_PSET(ar)'
(which would update the array descriptor on the device after the
host-side 'allocate') gets removed, because 'Global variables with "omp
declare target" attribute don't need to be copied, the receiver side will
use them directly'.  So, on the device, we'll still have the dummy
(unallocated) array descriptor, and will thus fail.

But even with that behavior disabled, we'll still fail, because in
'libgomp/target.c:gomp_map_vars_internal', when processing the
'GOMP_MAP_TO_PSET(ar)', we find that 'ar' has already been mapped
(globally, as mentioned above), so for 'n && n->refcount !=
REFCOUNT_LINK', we'll call 'gomp_map_vars_existing', and that one again
won't update device-side the array descriptor, because it's not
'GOMP_MAP_ALWAYS_TO_P'.

Indeed, if I use '!$omp declare target link(ar)' ('link' added), then
things seem to work as expected.

Unless I got something wrong, at which level do you suggest this should
be fixed?


Grüße
 Thomas


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: target-array-properties-allocatable-declare-1.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190621/c0e7ed23/attachment.f90>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 658 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190621/c0e7ed23/attachment.sig>


More information about the Fortran mailing list