[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-kernels-loop.f90
blob5b3b9c205229b9350ee00f6c3bae6928719f9f19
1 ! RUN: %S/../test_errors.sh %s %t %flang -fopenacc
2 ! REQUIRES: shell
4 ! Check OpenACC clause validity for the following construct and directive:
5 ! 2.11 Kernels Loop
7 program openacc_kernels_loop_validity
9 implicit none
11 type atype
12 real(8), dimension(10) :: arr
13 real(8) :: s
14 end type atype
16 integer :: i, j, b, gang_size, vector_size, worker_size
17 integer, parameter :: N = 256
18 integer, dimension(N) :: c
19 logical, dimension(N) :: d, e
20 integer :: async1
21 integer :: wait1, wait2
22 real :: reduction_r
23 logical :: reduction_l
24 real(8), dimension(N, N) :: aa, bb, cc
25 real(8), dimension(:), allocatable :: dd
26 real(8), pointer :: p
27 logical :: ifCondition = .TRUE.
28 type(atype) :: t
29 type(atype), dimension(10) :: ta
31 real(8), dimension(N) :: a, f, g, h
33 !$acc kernels loop
34 do i = 1, N
35 a(i) = 3.14
36 end do
38 !$acc kernels loop num_gangs(8)
39 do i = 1, N
40 a(i) = 3.14
41 end do
43 !$acc kernels loop num_gangs(gang_size)
44 do i = 1, N
45 a(i) = 3.14
46 end do
48 !$acc kernels loop num_gangs(8)
49 do i = 1, N
50 a(i) = 3.14
51 end do
53 !$acc kernels loop num_workers(worker_size)
54 do i = 1, N
55 a(i) = 3.14
56 end do
58 !$acc kernels loop num_workers(8)
59 do i = 1, N
60 a(i) = 3.14
61 end do
63 !$acc kernels loop vector_length(vector_size)
64 do i = 1, N
65 a(i) = 3.14
66 end do
68 !$acc kernels loop vector_length(128)
69 do i = 1, N
70 a(i) = 3.14
71 end do
73 !$acc kernels loop num_gangs(gang_size)
74 do i = 1, N
75 a(i) = 3.14
76 end do
79 !$acc kernels loop if(.TRUE.)
80 do i = 1, N
81 a(i) = 3.14
82 end do
84 !$acc kernels loop if(ifCondition)
85 do i = 1, N
86 a(i) = 3.14
87 end do
89 !$acc kernels loop
90 do i = 1, N
91 a(i) = 3.14
92 end do
93 !ERROR: Unmatched END SERIAL LOOP directive
94 !$acc end serial loop
96 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the KERNELS LOOP directive
97 !$acc kernels loop device_type(*) if(.TRUE.)
98 do i = 1, N
99 a(i) = 3.14
100 end do
101 !$acc end kernels loop
103 !$acc kernels loop async
104 do i = 1, N
105 a(i) = 3.14
106 end do
108 !$acc kernels loop async(1)
109 do i = 1, N
110 a(i) = 3.14
111 end do
113 !$acc kernels loop async(async1)
114 do i = 1, N
115 a(i) = 3.14
116 end do
118 !$acc kernels loop wait(wait1)
119 do i = 1, N
120 a(i) = 3.14
121 end do
123 !$acc kernels loop wait(wait1, wait2)
124 do i = 1, N
125 a(i) = 3.14
126 end do
128 !$acc kernels loop wait(wait1) wait(wait2)
129 do i = 1, N
130 a(i) = 3.14
131 end do
133 !$acc kernels loop wait(1, 2) async(3)
134 do i = 1, N
135 a(i) = 3.14
136 end do
138 !$acc kernels loop wait(queues: 1, 2) async(3)
139 do i = 1, N
140 a(i) = 3.14
141 end do
143 !$acc kernels loop wait(devnum: 1: 1, 2) async(3)
144 do i = 1, N
145 a(i) = 3.14
146 end do
148 !$acc kernels loop wait(devnum: 1: queues: 1, 2) async(3)
149 do i = 1, N
150 a(i) = 3.14
151 end do
153 !$acc kernels loop num_gangs(8)
154 do i = 1, N
155 a(i) = 3.14
156 end do
158 !$acc kernels loop num_workers(8)
159 do i = 1, N
160 a(i) = 3.14
161 end do
163 !$acc kernels loop vector_length(128)
164 do i = 1, N
165 a(i) = 3.14
166 end do
168 !$acc kernels loop if(.true.)
169 do i = 1, N
170 a(i) = 3.14
171 end do
173 !$acc kernels loop if(ifCondition)
174 do i = 1, N
175 a(i) = 3.14
176 end do
178 !ERROR: At most one IF clause can appear on the KERNELS LOOP directive
179 !$acc kernels loop if(.true.) if(ifCondition)
180 do i = 1, N
181 a(i) = 3.14
182 end do
184 !$acc kernels loop self
185 do i = 1, N
186 a(i) = 3.14
187 end do
189 !$acc kernels loop self(.true.)
190 do i = 1, N
191 a(i) = 3.14
192 end do
194 !$acc kernels loop self(ifCondition)
195 do i = 1, N
196 a(i) = 3.14
197 end do
199 !$acc kernels loop copy(aa) copyin(bb) copyout(cc)
200 do i = 1, N
201 a(i) = 3.14
202 end do
204 !$acc kernels loop copy(aa, bb) copyout(zero: cc)
205 do i = 1, N
206 a(i) = 3.14
207 end do
209 !$acc kernels loop present(aa, bb) create(cc)
210 do i = 1, N
211 a(i) = 3.14
212 end do
214 !$acc kernels loop copyin(readonly: aa, bb) create(zero: cc)
215 do i = 1, N
216 a(i) = 3.14
217 end do
219 !$acc kernels loop deviceptr(aa, bb) no_create(cc)
220 do i = 1, N
221 a(i) = 3.14
222 end do
224 !ERROR: Argument `aa` on the ATTACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
225 !$acc kernels loop attach(aa, dd, p)
226 do i = 1, N
227 a(i) = 3.14
228 end do
230 !$acc kernels loop private(aa, bb, cc)
231 do i = 1, N
232 a(i) = 3.14
233 end do
235 !$acc kernels loop default(none)
236 do i = 1, N
237 a(i) = 3.14
238 end do
240 !$acc kernels loop default(present)
241 do i = 1, N
242 a(i) = 3.14
243 end do
245 !ERROR: At most one DEFAULT clause can appear on the KERNELS LOOP directive
246 !$acc kernels loop default(none) default(present)
247 do i = 1, N
248 a(i) = 3.14
249 end do
251 !$acc kernels loop device_type(*)
252 do i = 1, N
253 a(i) = 3.14
254 end do
256 !$acc kernels loop device_type(1)
257 do i = 1, N
258 a(i) = 3.14
259 end do
261 !$acc kernels loop device_type(1, 3)
262 do i = 1, N
263 a(i) = 3.14
264 end do
266 !$acc kernels loop device_type(*) async wait num_gangs(8) num_workers(8) vector_length(128)
267 do i = 1, N
268 a(i) = 3.14
269 end do
271 !$acc kernels loop device_type(*) async
272 do i = 1, N
273 a(i) = 3.14
274 end do
276 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the KERNELS LOOP directive
277 !$acc kernels loop device_type(*) if(.TRUE.)
278 do i = 1, N
279 a(i) = 3.14
280 end do
282 end program openacc_kernels_loop_validity