Hi! On 2022-11-02T21:22:25+0100, I wrote: > On 2022-11-02T21:15:31+0100, I wrote: >> On 2022-11-02T21:10:54+0100, I wrote: >>> On 2022-11-02T21:04:56+0100, I wrote: >>>> --- /dev/null >>>> +++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-allocatable-1.f90 >>>> @@ -0,0 +1,268 @@ >>>> +! Test OpenACC 'declare create' with allocatable arrays. >>>> + >>>> +! { dg-do run } >>>> + >>>> +!TODO-OpenACC-declare-allocate >>>> +! Not currently implementing correct '-DACC_MEM_SHARED=0' behavior: >>>> +! Missing support for OpenACC "Changes from Version 2.0 to 2.5": >>>> +! "The 'declare create' directive with a Fortran 'allocatable' has new behavior". >>>> +! { dg-xfail-run-if TODO { *-*-* } { -DACC_MEM_SHARED=0 } } >>>> + >>>> +[...] >>> >>> Getting rid of the "'dg-xfail-run-if' for '-DACC_MEM_SHARED=0'" via a >>> work around (as seen in real-world code), I've pushed to master branch >>> commit 59c6c5dbf267cd9d0a8df72b2a5eb5657b64268e >>> "Add 'libgomp.oacc-fortran/declare-allocatable-1-runtime.f90'" >> >>> ... which is 'libgomp.oacc-fortran/declare-allocatable-1.f90' adjusted >>> for missing support for OpenACC "Changes from Version 2.0 to 2.5": >>> "The 'declare create' directive with a Fortran 'allocatable' has new behavior". >>> Thus, after 'allocate'/before 'deallocate', call 'acc_create'/'acc_delete' >>> manually. >> >> A similar test case, but with different focus, I've pushed to master >> branch in commit abeaf3735fe2568b9d5b8096318da866b1fe1e5c >> "Add 'libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-runtime.f90'", >> see attached. > >> --- /dev/null >> +++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-allocatable-array_descriptor-1-runtime.f90 >> @@ -0,0 +1,402 @@ >> +! Test OpenACC 'declare create' with allocatable arrays. >> + >> +! { dg-do run } >> + >> +! Note that we're not testing OpenACC semantics here, but rather documenting >> +! current GCC behavior, specifically, behavior concerning updating of >> +! host/device array descriptors. >> +! { dg-skip-if n/a { *-*-* } { -DACC_MEM_SHARED=1 } } >> + >> +!TODO-OpenACC-declare-allocate >> +! Missing support for OpenACC "Changes from Version 2.0 to 2.5": >> +! "The 'declare create' directive with a Fortran 'allocatable' has new behavior". >> +! Thus, after 'allocate'/before 'deallocate', call 'acc_create'/'acc_delete' >> +! manually. > > If instead of calling 'acc_create'/'acc_delete' we'd like to use > '!$acc enter data create'/'!$acc exit data delete', we run into > > "[gfortran + OpenACC] Allocate in module causes refcount error". > Pushed to master branchcommit da8e0e1191c5512244a752b30dea0eba83e3d10c > "Support OpenACC 'declare create' with Fortran allocatable arrays, part I [PR106643]", > see attached. > --- a/libgomp/oacc-mem.c > +++ b/libgomp/oacc-mem.c > @@ -1166,6 +1165,31 @@ goacc_enter_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum, > bool processed = false; > > struct target_mem_desc *tgt = n->tgt; > + > + /* Arrange so that OpenACC 'declare' code à la PR106643 > + "[gfortran + OpenACC] Allocate in module causes refcount error" > + has a chance to work. */ > + if ((kinds[i] & 0xff) == GOMP_MAP_TO_PSET > + && tgt->list_count == 0) > + { > + /* 'declare target'. */ > + assert (n->refcount == REFCOUNT_INFINITY); > + > + for (size_t k = 1; k < groupnum; k++) > + { > + /* The only thing we expect to see here. */ > + assert ((kinds[i + k] & 0xff) == GOMP_MAP_POINTER); > + } > + > + /* Given that 'goacc_exit_data_internal'/'goacc_exit_datum_1' > + will always see 'n->refcount == REFCOUNT_INFINITY', > + there's no need to adjust 'n->dynamic_refcount' here. */ > + > + processed = true; > + } To make slightly more interesting (real-world) test cases work, we here also have to process the 'GOMP_MAP_TO_PSET', 'GOMP_MAP_POINTER' here. Tobias had implemented such a thing in context of OpenMP PR96668 "[OpenMP] Re-mapping allocated but previously unallocated allocatable does not work" a while ago, and we may do similar here. Side note: in the first version of my changes, I had actually here in 'libgomp/oacc-mem.c:goacc_enter_data_internal' re-implemented the corresponding -- "somewhat ugly" -- logic, when at some point I realized that I instead could simply call into the existing code, greatly reducing the complexity here... Pushed to master branch commit f6ce1e77bbf5d3a096f52e674bfd7354c6537d10 "Support OpenACC 'declare create' with Fortran allocatable arrays, part II [PR106643, PR96668]", see attached. Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955