1 ! Miscellaneous tests for private variables.
6 ! Test of gang-private variables declared on loop directive.
9 integer :: x
, i
, arr(32)
15 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
16 !$acc loop gang private(x)
24 if (arr(i
) .ne
. i
* 3) call abort
29 ! Test of gang-private variables declared on loop directive, with broadcasting
30 ! to partitioned workers.
33 integer :: x
, i
, j
, arr(0:32*32)
39 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
40 !$acc loop gang private(x)
46 arr(i
* 32 + j
) = arr(i
* 32 + j
) + x
52 if (arr(i
) .ne
. i
+ (i
/ 32) * 2) call abort
57 ! Test of gang-private variables declared on loop directive, with broadcasting
58 ! to partitioned vectors.
61 integer :: x
, i
, j
, arr(0:32*32)
67 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
68 !$acc loop gang private(x)
74 arr(i
* 32 + j
) = arr(i
* 32 + j
) + x
80 if (arr(i
) .ne
. i
+ (i
/ 32) * 2) call abort
85 ! Test of gang-private addressable variable declared on loop directive, with
86 ! broadcasting to partitioned workers.
90 integer x
, y
, z
, attr(13)
93 integer i
, j
, arr(0:32*32)
100 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
101 !$acc loop gang private(pt)
110 arr(i
* 32 + j
) = arr(i
* 32 + j
) + pt
%x
+ pt
%y
+ pt
%z
+ pt
%attr(5);
115 do i
= 0, 32 * 32 - 1
116 if (arr(i
) .ne
. i
+ (i
/ 32) * 13) call abort
121 ! Test of vector-private variables declared on loop directive.
124 integer :: x
, i
, j
, k
, idx
, arr(0:32*32*32)
130 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
135 !$acc loop vector private(x)
138 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
140 !$acc loop vector private(x)
143 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
152 idx
= i
* 1024 + j
* 32 + k
153 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
162 ! Test of vector-private variables declared on loop directive. Array type.
165 integer :: i
, j
, k
, idx
, arr(0:32*32*32), pt(2)
171 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
176 !$acc loop vector private(x, pt)
178 pt(1) = ieor(i
, j
* 3)
179 pt(2) = ior(i
, j
* 5)
180 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + pt(1) * k
181 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + pt(2) * k
190 idx
= i
* 1024 + j
* 32 + k
191 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
200 ! Test of worker-private variables declared on a loop directive.
203 integer :: x
, i
, j
, arr(0:32*32)
210 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
211 !$acc loop gang private(x)
213 !$acc loop worker private(x)
216 arr(i
* 32 + j
) = arr(i
* 32 + j
) + x
221 do i
= 0, 32 * 32 - 1
222 if (arr(i
) .ne
. i
+ ieor(i
/ 32, mod(i
, 32) * 3)) call abort
227 ! Test of worker-private variables declared on a loop directive, broadcasting
228 ! to vector-partitioned mode.
231 integer :: x
, i
, j
, k
, idx
, arr(0:32*32*32)
237 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
240 !$acc loop worker private(x)
246 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
255 idx
= i
* 1024 + j
* 32 + k
256 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
) call abort
263 ! Test of worker-private variables declared on a loop directive, broadcasting
264 ! to vector-partitioned mode. Back-to-back worker loops.
267 integer :: x
, i
, j
, k
, idx
, arr(0:32*32*32)
273 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
276 !$acc loop worker private(x)
282 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
286 !$acc loop worker private(x)
292 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
301 idx
= i
* 1024 + j
* 32 + k
302 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
311 ! Test of worker-private variables declared on a loop directive, broadcasting
312 ! to vector-partitioned mode. Successive vector loops. */
315 integer :: x
, i
, j
, k
, idx
, arr(0:32*32*32)
321 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
324 !$acc loop worker private(x)
330 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
337 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
346 idx
= i
* 1024 + j
* 32 + k
347 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
356 ! Test of worker-private variables declared on a loop directive, broadcasting
357 ! to vector-partitioned mode. Addressable worker variable.
360 integer :: i
, j
, k
, idx
, arr(0:32*32*32)
362 integer, pointer :: p
368 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
371 !$acc loop worker private(x, p)
378 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
385 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + x
* k
394 idx
= i
* 1024 + j
* 32 + k
395 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
404 ! Test of worker-private variables declared on a loop directive, broadcasting
405 ! to vector-partitioned mode. Aggregate worker variable.
412 integer :: i
, j
, k
, idx
, arr(0:32*32*32)
419 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
422 !$acc loop worker private(pt)
424 pt
%x
= ieor(i
, j
* 3)
429 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + pt
%x
* k
434 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + pt
%y
* k
443 idx
= i
* 1024 + j
* 32 + k
444 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
453 ! Test of worker-private variables declared on loop directive, broadcasting
454 ! to vector-partitioned mode. Array worker variable.
457 integer :: i
, j
, k
, idx
, arr(0:32*32*32), pt(2)
463 !$acc parallel copy(arr) num_gangs(32) num_workers(8) vector_length(32)
466 !$acc loop worker private(pt)
468 pt(1) = ieor(i
, j
* 3)
469 pt(2) = ior(i
, j
* 5)
473 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + pt(1) * k
478 arr(i
* 1024 + j
* 32 + k
) = arr(i
* 1024 + j
* 32 + k
) + pt(2) * k
487 idx
= i
* 1024 + j
* 32 + k
488 if (arr(idx
) .ne
. idx
+ ieor(i
, j
* 3) * k
+ ior(i
, j
* 5) * k
) then
497 ! Test of gang-private variables declared on the parallel directive.
502 integer, parameter :: n
= 32
509 !$acc parallel private(x) copy(arr) num_gangs(n) num_workers(8) vector_length(32)
510 !$acc loop gang(static:1)
515 !$acc loop gang(static:1)
517 if (acc_on_device (acc_device_host
) .eqv
. .TRUE
.) x
= i
* 2
523 if (arr(i
) .ne
. (3 + i
* 2)) call abort