1 ! RUN: %python %S/../test_errors.py %s %flang -fopenacc
3 ! Check OpenACC clause validity for the following construct and directive:
6 program openacc_loop_validity
11 real(8), dimension(10) :: arr
16 integer :: i
, j
, k
, b
, gang_size
, vector_size
, worker_size
17 integer, parameter :: N
= 256
18 integer, dimension(N
) :: c
19 logical, dimension(N
) :: d
, e
21 integer :: wait1
, wait2
23 logical :: reduction_l
24 real(8), dimension(N
, N
) :: aa
, bb
, cc
25 logical :: ifCondition
= .TRUE
.
27 type(atype
), dimension(10) :: ta
29 real(8), dimension(N
) :: a
, f
, g
, h
38 !$acc parallel device_type(*) num_gangs(2)
53 !$acc loop independent
67 !ERROR: At most one VECTOR clause can appear on the LOOP directive or in group separated by the DEVICE_TYPE clause
68 !$acc loop vector vector(128)
89 !$acc loop vector(vector_size)
96 !$acc loop vector(length: vector_size)
103 !ERROR: At most one WORKER clause can appear on the LOOP directive or in group separated by the DEVICE_TYPE clause
104 !$acc loop worker worker(10)
118 !$acc loop worker(10)
125 !$acc loop worker(worker_size)
132 !$acc loop worker(num: worker_size)
139 !ERROR: At most one GANG clause can appear on the LOOP directive or in group separated by the DEVICE_TYPE clause
140 !$acc loop gang gang(gang_size)
146 !$acc loop gang device_type(default) gang(gang_size)
151 !ERROR: At most one GANG clause can appear on the PARALLEL LOOP directive or in group separated by the DEVICE_TYPE clause
152 !$acc parallel loop gang gang(gang_size)
157 !$acc parallel loop gang device_type(default) gang(gang_size)
163 !$acc loop gang(gang_size)
170 !$acc loop gang(num: gang_size)
177 !$acc loop gang(gang_size, static:*)
184 !$acc loop gang(num: gang_size, static:*)
191 !$acc loop gang(num: gang_size, static: gang_size)
198 !$acc loop private(b, a(:))
212 !$acc loop tile(2, 2)
221 !ERROR: The parameter of the COLLAPSE clause must be a constant positive integer expression
222 !$acc loop collapse(-1)
231 !ERROR: Clause PRIVATE is not allowed after clause DEVICE_TYPE on the LOOP directive
232 !$acc loop device_type(*) private(i)
239 !ERROR: Clause GANG is not allowed if clause SEQ appears on the LOOP directive
247 !ERROR: Clause WORKER is not allowed if clause SEQ appears on the LOOP directive
248 !$acc loop worker seq
255 !ERROR: Clause VECTOR is not allowed if clause SEQ appears on the LOOP directive
256 !$acc loop vector seq
262 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the PARALLEL directive
263 !$acc parallel device_type(*) if(.TRUE.)
270 !$acc loop collapse(2)
272 !ERROR: Loop control is not present in the DO LOOP
278 !ERROR: The num argument is not allowed when dim is specified
279 !$acc loop gang(1, dim: 2)
288 !$acc loop collapse(2)
290 !ERROR: LOOP directive not expected in COLLAPSE loop nest
303 !$acc loop gang device_type(nvidia) gang(num: 8)
307 !$acc loop vector device_type(default) vector(16)
311 !$acc loop worker device_type(*) worker(8)
315 !$acc loop device_type(multicore) collapse(2)
321 !ERROR: Trip count must be computable and invariant
322 !$acc loop collapse(2)
328 !ERROR: Trip count must be computable and invariant
329 !$acc loop collapse(2)
335 !ERROR: Trip count must be computable and invariant
336 !$acc loop collapse(2)
342 !ERROR: Trip count must be computable and invariant
343 !$acc parallel loop collapse(2)
349 !ERROR: Trip count must be computable and invariant
350 !$acc loop collapse(3)
358 end program openacc_loop_validity