Hi PA,
Paul-Antoine Arras wrote:
The attached diff fixes the overlapping-maps error for the testcase
above. However it then fails for `map(always, present, to:
chunk%tiles(1)%field%density1)` with:
libgomp: present clause: not present on the device (addr: 0x4bd95b0,
size: 32 (0x20), dev: 0)
With current mainline and 1/2, I see:
libgomp: Trying to map into device [0x19591a50..0x19591b00) object
when [0x19591a50..0x19591aa8) is already mapped
for the first 'target enter data':
!$omp target enter data &
!$omp map(to: chunk%tiles(1)%field%density0) &
!$omp map(to: chunk%tiles(1)%field%density1)
while with this patch, it only fails when present-always-mapping
'density1' after allocation - failing with:
libgomp: present clause: not present on the device (addr: 0x39633290,
size: 32 (0x20), dev: 0)
* * *
An obvious testcase is then the attached trimmed-down version of the test,
which does not access the unallocated density1 on the device. It seems to
me perfectly valid and sensible.
Thus – as you planned: It makes sense to fold 'present.diff' into the
1/2 patch, but not without a testcase. Voila, the attachment is one.
(I come back to the patch review of present.diff as part of the review of
1/2 itself.)
* * *
Regarding the attached testcase (present-nodt.f90), I notice that
with your follow-up patch, it behaves as follows (tested with the 1/2 patch
of this thread + current mainline): As it, it runs but the value is not copied out
("STOP 2");
using 'tofrom' instead of 'to' for 'density1', it compiles and works.
This is kind of sensible. Do you know whether there is already test coverage
for the 'tofrom' case? If not, I think a testcase should be added. [I know that
some variant it, but I lost track of the fine print and I don't feel looking
at existing testcases.]
Tobias
module m
implicit none
type field_type
real(kind=8), allocatable :: density0(:,:), density1(:,:)
end type field_type
type tile_type
type(field_type) :: field
end type tile_type
type chunk_type
real(kind=8), allocatable :: left_rcv_buffer(:)
type(tile_type), allocatable :: tiles(:)
end type chunk_type
type(chunk_type) :: chunk
end
use m
implicit none
allocate(chunk%tiles(1))
chunk%tiles(1)%field%density0 = reshape([1,2,3,4],[2,2])
!$omp target enter data &
!$omp map(to: chunk%tiles(1)%field%density0) &
!$omp map(to: chunk%tiles(1)%field%density1)
!$omp target map(present, alloc: chunk%tiles(1)%field%density0)
if (.not. allocated(chunk%tiles(1)%field%density0)) stop 1
if (any (chunk%tiles(1)%field%density0 /= reshape([1,2,3,4],[2,2]))) stop 1
chunk%tiles(1)%field%density0 = chunk%tiles(1)%field%density0 * 2
!$omp end target
chunk%tiles(1)%field%density1 = reshape([11,22,33,44],[2,2])
!$omp target map(alloc: chunk%tiles(1)%field%density0)
if (.not. allocated(chunk%tiles(1)%field%density0)) stop 1
if (any (chunk%tiles(1)%field%density0 /= 2*reshape([1,2,3,4],[2,2]))) stop 1
chunk%tiles(1)%field%density0 = chunk%tiles(1)%field%density0 * 7
!$omp end target
!$omp target exit data &
!$omp map(from: chunk%tiles(1)%field%density0) !&
!print *, chunk%tiles(1)%field%density0
!print *, chunk%tiles(1)%field%density1
if (any (chunk%tiles(1)%field%density0 /= 7*2*reshape([1,2,3,4],[2,2]))) stop 1
if (any (chunk%tiles(1)%field%density1 /= reshape([11,22,33,44],[2,2]))) stop 2
end