1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
!
! Check that mapping with map(var%tiles(1)) works.
!
! This uses deep mapping to handle the allocatable
! derived-type components
!
! The tricky part is that GCC generates intermittently
! an SSA_NAME that needs to be resolved.
!
module m
type t
integer, allocatable :: den1(:,:), den2(:,:)
end type t
type t2
type(t), allocatable :: tiles(:)
end type t2
end
use m
use iso_c_binding
implicit none (type, external)
type(t2), target :: var
logical :: is_self_map
type(C_ptr) :: pden1, pden2, ptiles, ptiles1
allocate(var%tiles(1))
var%tiles(1)%den1 = reshape([1,2,3,4],[2,2])
var%tiles(1)%den2 = reshape([11,22,33,44],[2,2])
ptiles = c_loc(var%tiles)
ptiles1 = c_loc(var%tiles(1))
pden1 = c_loc(var%tiles(1)%den1)
pden2 = c_loc(var%tiles(1)%den2)
is_self_map = .false.
!$omp target map(to: is_self_map)
is_self_map = .true.
!$omp end target
!$omp target enter data map(var%tiles(1))
!$omp target firstprivate(ptiles, ptiles1, pden1, pden2)
if (any (var%tiles(1)%den1 /= reshape([1,2,3,4],[2,2]))) stop 1
if (any (var%tiles(1)%den2 /= reshape([11,22,33,44],[2,2]))) stop 2
var%tiles(1)%den1 = var%tiles(1)%den1 + 5
var%tiles(1)%den2 = var%tiles(1)%den2 + 7
if (is_self_map) then
if (.not. c_associated (ptiles, c_loc(var%tiles))) stop 3
if (.not. c_associated (ptiles1, c_loc(var%tiles(1)))) stop 4
if (.not. c_associated (pden1, c_loc(var%tiles(1)%den1))) stop 5
if (.not. c_associated (pden2, c_loc(var%tiles(1)%den2))) stop 6
else
if (c_associated (ptiles, c_loc(var%tiles))) stop 3
if (c_associated (ptiles1, c_loc(var%tiles(1)))) stop 4
if (c_associated (pden1, c_loc(var%tiles(1)%den1))) stop 5
if (c_associated (pden2, c_loc(var%tiles(1)%den2))) stop 6
endif
!$omp end target
if (is_self_map) then
if (any (var%tiles(1)%den1 /= 5 + reshape([1,2,3,4],[2,2]))) stop 7
if (any (var%tiles(1)%den2 /= 7 + reshape([11,22,33,44],[2,2]))) stop 8
else
if (any (var%tiles(1)%den1 /= reshape([1,2,3,4],[2,2]))) stop 7
if (any (var%tiles(1)%den2 /= reshape([11,22,33,44],[2,2]))) stop 8
endif
!$omp target exit data map(var%tiles(1))
if (any (var%tiles(1)%den1 /= 5 + reshape([1,2,3,4],[2,2]))) stop 7
if (any (var%tiles(1)%den2 /= 7 + reshape([11,22,33,44],[2,2]))) stop 8
end
|