4 integer, allocatable
:: aaa(:,:,:)
7 allocate (aaa(-4:10,-3:8,2))
8 aaa(:,:,:) = reshape ([(i
, i
= 1, size(aaa
))], shape(aaa
))
10 do i
= 0, omp_get_num_devices()
11 !$omp target data map(to: aaa) device(i)
12 call test_addr (aaa
, i
)
13 call test_ptr (aaa
, i
)
20 subroutine test_addr (aaaa
, dev
)
22 integer, target
, allocatable
:: aaaa(:,:,:), bbbb(:,:,:)
29 !$omp target device(dev) map(to: is_shared)
33 allocate (bbbb(-4:10,-3:8,2))
34 bbbb(:,:,:) = reshape ([(-i
, i
= 1, size(bbbb
))], shape(bbbb
))
35 !$omp target enter data map(to: bbbb) device(dev)
36 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 1
37 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 2
38 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 3
39 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 4
40 if (any (aaaa
/= -bbbb
)) error
stop 5
41 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
44 !$omp parallel do shared(bbbb, aaaa)
46 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 5
47 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 6
48 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 7
49 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 8
50 if (any (aaaa
/= -bbbb
)) error
stop 5
51 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
54 !$omp target data use_device_addr(bbbb, aaaa) device(dev)
55 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 9
56 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 10
57 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 11
58 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 12
60 if (any (aaaa
/= -bbbb
)) error
stop 5
61 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
64 if (is_shared
.neqv
. c_associated (ptr
, c_loc (aaaa
))) error
stop
66 !$omp target has_device_addr(bbbb, aaaa) device(dev)
67 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 9
68 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 10
69 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 11
70 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 12
71 if (any (aaaa
/= -bbbb
)) error
stop 5
72 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
77 !$omp target exit data map(delete: bbbb) device(dev)
79 end subroutine test_addr
81 subroutine test_ptr (aaaa
, dev
)
83 integer, target
, allocatable
:: aaaa(:,:,:), bbbb(:,:,:)
90 !$omp target device(dev) map(to: is_shared)
94 allocate (bbbb(-4:10,-3:8,2))
95 bbbb(:,:,:) = reshape ([(-i
, i
= 1, size(bbbb
))], shape(bbbb
))
96 !$omp target enter data map(to: bbbb) device(dev)
97 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 1
98 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 2
99 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 3
100 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 4
101 if (any (aaaa
/= -bbbb
)) error
stop 5
102 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
105 !$omp parallel do shared(bbbb, aaaa)
107 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 5
108 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 6
109 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 7
110 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 8
111 if (any (aaaa
/= -bbbb
)) error
stop 5
112 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
115 !$omp target data use_device_ptr(bbbb, aaaa) device(dev)
116 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 9
117 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 10
118 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 11
119 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 12
121 if (any (aaaa
/= -bbbb
)) error
stop 5
122 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
125 if (is_shared
.neqv
. c_associated (ptr
, c_loc (aaaa
))) error
stop
127 ! Uses has_device_addr due to PR fortran/105318
128 !!$omp target is_device_ptr(bbbb, aaaa) device(dev)
129 !$omp target has_device_addr(bbbb, aaaa) device(dev)
130 if (any (lbound (aaaa
) /= [-4, -3, 1])) error
stop 9
131 if (any (shape (aaaa
) /= [15, 12, 2])) error
stop 10
132 if (any (lbound (bbbb
) /= [-4, -3, 1])) error
stop 11
133 if (any (shape (bbbb
) /= [15, 12, 2])) error
stop 12
134 if (any (aaaa
/= -bbbb
)) error
stop 5
135 if (any (aaaa
/= reshape ([(i
, i
= 1, size(aaaa
))], shape(aaaa
)))) &
138 !$omp end target data
140 !$omp target exit data map(delete: bbbb) device(dev)
142 end subroutine test_ptr