[LLVM] Fix Maintainers.md formatting (NFC)
[llvm-project.git] / flang / test / Lower / OpenACC / acc-kernels-loop.f90
blobe5791f0e5b3921b5017043c2f764c3fc1ad4f4d6
1 ! This test checks lowering of OpenACC kernels loop combined directive.
3 ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
5 subroutine acc_kernels_loop
6 integer :: i, j
8 integer :: async = 1
9 integer :: wait1 = 1
10 integer :: wait2 = 2
11 integer :: numGangs = 1
12 integer :: numWorkers = 10
13 integer :: vectorLength = 128
14 logical :: ifCondition = .TRUE.
15 integer, parameter :: n = 10
16 real, dimension(n) :: a, b, c
17 real, dimension(n, n) :: d, e
18 real, pointer :: f, g
19 integer :: reduction_i
20 real :: reduction_r
22 integer :: gangNum = 8
23 integer :: gangStatic = 8
24 integer :: vectorNum = 128
25 integer, parameter :: tileSize = 2
27 ! CHECK: %[[A:.*]] = fir.alloca !fir.array<10xf32> {{{.*}}uniq_name = "{{.*}}Ea"}
28 ! CHECK: %[[DECLA:.*]]:2 = hlfir.declare %[[A]]
29 ! CHECK: %[[B:.*]] = fir.alloca !fir.array<10xf32> {{{.*}}uniq_name = "{{.*}}Eb"}
30 ! CHECK: %[[DECLB:.*]]:2 = hlfir.declare %[[B]]
31 ! CHECK: %[[C:.*]] = fir.alloca !fir.array<10xf32> {{{.*}}uniq_name = "{{.*}}Ec"}
32 ! CHECK: %[[DECLC:.*]]:2 = hlfir.declare %[[C]]
33 ! CHECK: %[[F:.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "f", uniq_name = "{{.*}}Ef"}
34 ! CHECK: %[[DECLF:.*]]:2 = hlfir.declare %[[F]]
35 ! CHECK: %[[G:.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "g", uniq_name = "{{.*}}Eg"}
36 ! CHECK: %[[DECLG:.*]]:2 = hlfir.declare %[[G]]
37 ! CHECK: %[[IFCONDITION:.*]] = fir.address_of(@{{.*}}ifcondition) : !fir.ref<!fir.logical<4>>
38 ! CHECK: %[[DECLIFCONDITION:.*]]:2 = hlfir.declare %[[IFCONDITION]]
40 !$acc kernels
41 !$acc loop
42 DO i = 1, n
43 a(i) = b(i)
44 END DO
45 !$acc end kernels
47 ! CHECK: acc.kernels {
48 ! CHECK: acc.loop private{{.*}} {
49 ! CHECK: acc.yield
50 ! CHECK-NEXT: }{{$}}
51 ! CHECK: acc.terminator
52 ! CHECK-NEXT: }{{$}}
54 !$acc kernels loop
55 DO i = 1, n
56 a(i) = b(i)
57 END DO
59 ! CHECK: acc.kernels combined(loop) {
60 ! CHECK: acc.loop combined(kernels) private{{.*}} {
61 ! CHECK: acc.yield
62 ! CHECK-NEXT: }{{$}}
63 ! CHECK: acc.terminator
64 ! CHECK-NEXT: }{{$}}
66 !$acc kernels loop async
67 DO i = 1, n
68 a(i) = b(i)
69 END DO
70 !$acc end kernels loop
72 ! CHECK: acc.kernels {{.*}} {
73 ! CHECK: acc.loop {{.*}} {
74 ! CHECK: acc.yield
75 ! CHECK-NEXT: }{{$}}
76 ! CHECK: acc.terminator
77 ! CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
79 !$acc kernels loop async(1)
80 DO i = 1, n
81 a(i) = b(i)
82 END DO
84 ! CHECK: [[ASYNC1:%.*]] = arith.constant 1 : i32
85 ! CHECK: acc.kernels {{.*}} async([[ASYNC1]] : i32) {
86 ! CHECK: acc.loop {{.*}} {
87 ! CHECK: acc.yield
88 ! CHECK-NEXT: }{{$}}
89 ! CHECK: acc.terminator
90 ! CHECK-NEXT: }{{$}}
92 !$acc kernels loop async(async)
93 DO i = 1, n
94 a(i) = b(i)
95 END DO
97 ! CHECK: [[ASYNC2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
98 ! CHECK: acc.kernels {{.*}} async([[ASYNC2]] : i32) {
99 ! CHECK: acc.loop {{.*}} {
100 ! CHECK: acc.yield
101 ! CHECK-NEXT: }{{$}}
102 ! CHECK: acc.terminator
103 ! CHECK-NEXT: }{{$}}
105 !$acc kernels loop wait
106 DO i = 1, n
107 a(i) = b(i)
108 END DO
110 ! CHECK: acc.kernels {{.*}} wait {
111 ! CHECK: acc.loop {{.*}} {
112 ! CHECK: acc.yield
113 ! CHECK-NEXT: }{{$}}
114 ! CHECK: acc.terminator
115 ! CHECK-NEXT: }
117 !$acc kernels loop wait(1)
118 DO i = 1, n
119 a(i) = b(i)
120 END DO
122 ! CHECK: [[WAIT1:%.*]] = arith.constant 1 : i32
123 ! CHECK: acc.kernels {{.*}} wait({[[WAIT1]] : i32}) {
124 ! CHECK: acc.loop
125 ! CHECK: acc.yield
126 ! CHECK-NEXT: }{{$}}
127 ! CHECK: acc.terminator
128 ! CHECK-NEXT: }{{$}}
130 !$acc kernels loop wait(1, 2)
131 DO i = 1, n
132 a(i) = b(i)
133 END DO
135 ! CHECK: [[WAIT2:%.*]] = arith.constant 1 : i32
136 ! CHECK: [[WAIT3:%.*]] = arith.constant 2 : i32
137 ! CHECK: acc.kernels {{.*}} wait({[[WAIT2]] : i32, [[WAIT3]] : i32}) {
138 ! CHECK: acc.loop
139 ! CHECK: acc.yield
140 ! CHECK-NEXT: }{{$}}
141 ! CHECK: acc.terminator
142 ! CHECK-NEXT: }{{$}}
144 !$acc kernels loop wait(wait1, wait2)
145 DO i = 1, n
146 a(i) = b(i)
147 END DO
149 ! CHECK: [[WAIT4:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
150 ! CHECK: [[WAIT5:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
151 ! CHECK: acc.kernels {{.*}} wait({[[WAIT4]] : i32, [[WAIT5]] : i32}) {
152 ! CHECK: acc.loop
153 ! CHECK: acc.yield
154 ! CHECK-NEXT: }{{$}}
155 ! CHECK: acc.terminator
156 ! CHECK-NEXT: }{{$}}
158 !$acc kernels loop num_gangs(1)
159 DO i = 1, n
160 a(i) = b(i)
161 END DO
163 ! CHECK: [[NUMGANGS1:%.*]] = arith.constant 1 : i32
164 ! CHECK: acc.kernels {{.*}} num_gangs({[[NUMGANGS1]] : i32}) {
165 ! CHECK: acc.loop
166 ! CHECK: acc.yield
167 ! CHECK-NEXT: }{{$}}
168 ! CHECK: acc.terminator
169 ! CHECK-NEXT: }{{$}}
171 !$acc kernels loop num_gangs(numGangs)
172 DO i = 1, n
173 a(i) = b(i)
174 END DO
176 ! CHECK: [[NUMGANGS2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
177 ! CHECK: acc.kernels {{.*}} num_gangs({[[NUMGANGS2]] : i32}) {
178 ! CHECK: acc.loop
179 ! CHECK: acc.yield
180 ! CHECK-NEXT: }{{$}}
181 ! CHECK: acc.terminator
182 ! CHECK-NEXT: }{{$}}
184 !$acc kernels loop num_workers(10)
185 DO i = 1, n
186 a(i) = b(i)
187 END DO
189 ! CHECK: [[NUMWORKERS1:%.*]] = arith.constant 10 : i32
190 ! CHECK: acc.kernels {{.*}} num_workers([[NUMWORKERS1]] : i32) {
191 ! CHECK: acc.loop {{.*}} {
192 ! CHECK: acc.yield
193 ! CHECK-NEXT: }{{$}}
194 ! CHECK: acc.terminator
195 ! CHECK-NEXT: }{{$}}
197 !$acc kernels loop num_workers(numWorkers)
198 DO i = 1, n
199 a(i) = b(i)
200 END DO
202 ! CHECK: [[NUMWORKERS2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
203 ! CHECK: acc.kernels {{.*}} num_workers([[NUMWORKERS2]] : i32) {
204 ! CHECK: acc.loop {{.*}} {
205 ! CHECK: acc.yield
206 ! CHECK-NEXT: }{{$}}
207 ! CHECK: acc.terminator
208 ! CHECK-NEXT: }{{$}}
210 !$acc kernels loop vector_length(128)
211 DO i = 1, n
212 a(i) = b(i)
213 END DO
215 ! CHECK: [[VECTORLENGTH1:%.*]] = arith.constant 128 : i32
216 ! CHECK: acc.kernels {{.*}} vector_length([[VECTORLENGTH1]] : i32) {
217 ! CHECK: acc.loop {{.*}} {
218 ! CHECK: acc.yield
219 ! CHECK-NEXT: }{{$}}
220 ! CHECK: acc.terminator
221 ! CHECK-NEXT: }{{$}}
223 !$acc kernels loop vector_length(vectorLength)
224 DO i = 1, n
225 a(i) = b(i)
226 END DO
228 ! CHECK: [[VECTORLENGTH2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
229 ! CHECK: acc.kernels {{.*}} vector_length([[VECTORLENGTH2]] : i32) {
230 ! CHECK: acc.loop {{.*}} {
231 ! CHECK: acc.yield
232 ! CHECK-NEXT: }{{$}}
233 ! CHECK: acc.terminator
234 ! CHECK-NEXT: }{{$}}
236 !$acc kernels loop if(.TRUE.)
237 DO i = 1, n
238 a(i) = b(i)
239 END DO
241 ! CHECK: [[IF1:%.*]] = arith.constant true
242 ! CHECK: acc.kernels {{.*}} if([[IF1]]) {
243 ! CHECK: acc.loop {{.*}} {
244 ! CHECK: acc.yield
245 ! CHECK-NEXT: }{{$}}
246 ! CHECK: acc.terminator
247 ! CHECK-NEXT: }{{$}}
249 !$acc kernels loop if(ifCondition)
250 DO i = 1, n
251 a(i) = b(i)
252 END DO
254 ! CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
255 ! CHECK: [[IF2:%.*]] = fir.convert [[IFCOND]] : (!fir.logical<4>) -> i1
256 ! CHECK: acc.kernels {{.*}} if([[IF2]]) {
257 ! CHECK: acc.loop {{.*}} {
258 ! CHECK: acc.yield
259 ! CHECK-NEXT: }{{$}}
260 ! CHECK: acc.terminator
261 ! CHECK-NEXT: }{{$}}
263 !$acc kernels loop self(.TRUE.)
264 DO i = 1, n
265 a(i) = b(i)
266 END DO
268 ! CHECK: [[SELF1:%.*]] = arith.constant true
269 ! CHECK: acc.kernels {{.*}} self([[SELF1]]) {
270 ! CHECK: acc.loop {{.*}} {
271 ! CHECK: acc.yield
272 ! CHECK-NEXT: }{{$}}
273 ! CHECK: acc.terminator
274 ! CHECK-NEXT: }{{$}}
276 !$acc kernels loop self
277 DO i = 1, n
278 a(i) = b(i)
279 END DO
281 ! CHECK: acc.kernels {{.*}}{
282 ! CHECK: acc.loop {{.*}} {
283 ! CHECK: acc.yield
284 ! CHECK-NEXT: }{{$}}
285 ! CHECK: acc.terminator
286 ! CHECK-NEXT: } attributes {selfAttr}
288 !$acc kernels loop self(ifCondition)
289 DO i = 1, n
290 a(i) = b(i)
291 END DO
294 ! CHECK: %[[SELF2:.*]] = fir.convert %[[DECLIFCONDITION]]#1 : (!fir.ref<!fir.logical<4>>) -> i1
295 ! CHECK: acc.kernels {{.*}} self(%[[SELF2]]) {
296 ! CHECK: acc.loop {{.*}} {
297 ! CHECK: acc.yield
298 ! CHECK-NEXT: }{{$}}
299 ! CHECK: acc.terminator
300 ! CHECK-NEXT: }{{$}}
302 !$acc kernels loop copy(a, b)
303 DO i = 1, n
304 a(i) = b(i)
305 END DO
308 ! CHECK: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copy>, name = "a"}
309 ! CHECK: %[[COPYIN_B:.*]] = acc.copyin varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copy>, name = "b"}
310 ! CHECK: acc.kernels {{.*}} dataOperands(%[[COPYIN_A]], %[[COPYIN_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
311 ! CHECK: acc.loop {{.*}} {
312 ! CHECK: acc.yield
313 ! CHECK-NEXT: }{{$}}
314 ! CHECK: acc.terminator
315 ! CHECK-NEXT: }{{$}}
316 ! CHECK: acc.copyout accPtr(%[[COPYIN_A]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) to varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) {dataClause = #acc<data_clause acc_copy>, name = "a"}
317 ! CHECK: acc.copyout accPtr(%[[COPYIN_B]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) to varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) {dataClause = #acc<data_clause acc_copy>, name = "b"}
319 !$acc kernels loop copy(a) copy(b)
320 DO i = 1, n
321 a(i) = b(i)
322 END DO
324 ! CHECK: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copy>, name = "a"}
325 ! CHECK: %[[COPYIN_B:.*]] = acc.copyin varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copy>, name = "b"}
326 ! CHECK: acc.kernels {{.*}} dataOperands(%[[COPYIN_A]], %[[COPYIN_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
327 ! CHECK: acc.loop {{.*}} {
328 ! CHECK: acc.yield
329 ! CHECK-NEXT: }{{$}}
330 ! CHECK: acc.terminator
331 ! CHECK-NEXT: }{{$}}
332 ! CHECK: acc.copyout accPtr(%[[COPYIN_A]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) to varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) {dataClause = #acc<data_clause acc_copy>, name = "a"}
333 ! CHECK: acc.copyout accPtr(%[[COPYIN_B]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) to varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) {dataClause = #acc<data_clause acc_copy>, name = "b"}
335 !$acc kernels loop copyin(a) copyin(readonly: b)
336 DO i = 1, n
337 a(i) = b(i)
338 END DO
340 ! CHECK: %[[COPYIN_A:.*]] = acc.copyin varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
341 ! CHECK: %[[COPYIN_B:.*]] = acc.copyin varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copyin_readonly>, name = "b"}
342 ! CHECK: acc.kernels {{.*}} dataOperands(%[[COPYIN_A]], %[[COPYIN_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
343 ! CHECK: acc.loop {{.*}} {
344 ! CHECK: acc.yield
345 ! CHECK-NEXT: }{{$}}
346 ! CHECK: acc.terminator
347 ! CHECK-NEXT: }{{$}}
349 !$acc kernels loop copyout(a) copyout(zero: b)
350 DO i = 1, n
351 a(i) = b(i)
352 END DO
354 ! CHECK: %[[CREATE_A:.*]] = acc.create varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copyout>, name = "a"}
355 ! CHECK: %[[CREATE_B:.*]] = acc.create varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_copyout>, name = "b"}
356 ! CHECK: acc.kernels {{.*}} dataOperands(%[[CREATE_A]], %[[CREATE_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
357 ! CHECK: acc.loop {{.*}} {
358 ! CHECK: acc.yield
359 ! CHECK-NEXT: }{{$}}
360 ! CHECK: acc.terminator
361 ! CHECK-NEXT: }{{$}}
362 ! CHECK: acc.copyout accPtr(%[[CREATE_A]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) to varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) {name = "a"}
363 ! CHECK: acc.copyout accPtr(%[[CREATE_B]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) to varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) {name = "b"}
365 !$acc kernels loop create(b) create(zero: a)
366 DO i = 1, n
367 a(i) = b(i)
368 END DO
370 ! CHECK: %[[CREATE_B:.*]] = acc.create varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
371 ! CHECK: %[[CREATE_A:.*]] = acc.create varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {dataClause = #acc<data_clause acc_create_zero>, name = "a"}
372 ! CHECK: acc.kernels {{.*}} dataOperands(%[[CREATE_B]], %[[CREATE_A]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
373 ! CHECK: acc.loop {{.*}} {
374 ! CHECK: acc.yield
375 ! CHECK-NEXT: }{{$}}
376 ! CHECK: acc.terminator
377 ! CHECK-NEXT: }{{$}}
378 ! CHECK: acc.delete accPtr(%[[CREATE_B]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) {dataClause = #acc<data_clause acc_create>, name = "b"}
379 ! CHECK: acc.delete accPtr(%[[CREATE_A]] : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) {dataClause = #acc<data_clause acc_create_zero>, name = "a"}
381 !$acc kernels loop no_create(a, b)
382 DO i = 1, n
383 a(i) = b(i)
384 END DO
386 ! CHECK: %[[NOCREATE_A:.*]] = acc.nocreate varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
387 ! CHECK: %[[NOCREATE_B:.*]] = acc.nocreate varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
388 ! CHECK: acc.kernels {{.*}} dataOperands(%[[NOCREATE_A]], %[[NOCREATE_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
389 ! CHECK: acc.loop {{.*}} {
390 ! CHECK: acc.yield
391 ! CHECK-NEXT: }{{$}}
392 ! CHECK: acc.terminator
393 ! CHECK-NEXT: }{{$}}
395 !$acc kernels loop present(a, b)
396 DO i = 1, n
397 a(i) = b(i)
398 END DO
400 ! CHECK: %[[PRESENT_A:.*]] = acc.present varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
401 ! CHECK: %[[PRESENT_B:.*]] = acc.present varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
402 ! CHECK: acc.kernels {{.*}} dataOperands(%[[PRESENT_A]], %[[PRESENT_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
403 ! CHECK: acc.loop {{.*}} {
404 ! CHECK: acc.yield
405 ! CHECK-NEXT: }{{$}}
406 ! CHECK: acc.terminator
407 ! CHECK-NEXT: }{{$}}
409 !$acc kernels loop deviceptr(a) deviceptr(b)
410 DO i = 1, n
411 a(i) = b(i)
412 END DO
414 ! CHECK: %[[DEVICEPTR_A:.*]] = acc.deviceptr varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
415 ! CHECK: %[[DEVICEPTR_B:.*]] = acc.deviceptr varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
416 ! CHECK: acc.kernels {{.*}} dataOperands(%[[DEVICEPTR_A]], %[[DEVICEPTR_B]] : !fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>) {
417 ! CHECK: acc.loop {{.*}} {
418 ! CHECK: acc.yield
419 ! CHECK-NEXT: }{{$}}
420 ! CHECK: acc.terminator
421 ! CHECK-NEXT: }{{$}}
423 !$acc kernels loop attach(f, g)
424 DO i = 1, n
425 a(i) = b(i)
426 END DO
428 ! CHECK: %[[BOX_F:.*]] = fir.load %[[DECLF]]#0 : !fir.ref<!fir.box<!fir.ptr<f32>>>
429 ! CHECK: %[[BOX_ADDR_F:.*]] = fir.box_addr %[[BOX_F]] : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>
430 ! CHECK: %[[ATTACH_F:.*]] = acc.attach varPtr(%[[BOX_ADDR_F]] : !fir.ptr<f32>) -> !fir.ptr<f32> {name = "f"}
431 ! CHECK: %[[BOX_G:.*]] = fir.load %[[DECLG]]#0 : !fir.ref<!fir.box<!fir.ptr<f32>>>
432 ! CHECK: %[[BOX_ADDR_G:.*]] = fir.box_addr %[[BOX_G]] : (!fir.box<!fir.ptr<f32>>) -> !fir.ptr<f32>
433 ! CHECK: %[[ATTACH_G:.*]] = acc.attach varPtr(%[[BOX_ADDR_G]] : !fir.ptr<f32>) -> !fir.ptr<f32> {name = "g"}
434 ! CHECK: acc.kernels {{.*}} dataOperands(%[[ATTACH_F]], %[[ATTACH_G]] : !fir.ptr<f32>, !fir.ptr<f32>) {
435 ! CHECK: acc.loop {{.*}} {
436 ! CHECK: acc.yield
437 ! CHECK-NEXT: }{{$}}
438 ! CHECK: acc.terminator
439 ! CHECK-NEXT: }{{$}}
441 !$acc kernels loop seq
442 DO i = 1, n
443 a(i) = b(i)
444 END DO
446 ! CHECK: acc.kernels {{.*}} {
447 ! CHECK: acc.loop {{.*}} {
448 ! CHECK: acc.yield
449 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>, seq = [#acc.device_type<none>]}
450 ! CHECK: acc.terminator
451 ! CHECK-NEXT: }{{$}}
453 !$acc kernels loop auto
454 DO i = 1, n
455 a(i) = b(i)
456 END DO
458 ! CHECK: acc.kernels {{.*}} {
459 ! CHECK: acc.loop {{.*}} {
460 ! CHECK: acc.yield
461 ! CHECK-NEXT: } attributes {auto_ = [#acc.device_type<none>], inclusiveUpperbound = array<i1: true>}
462 ! CHECK: acc.terminator
463 ! CHECK-NEXT: }{{$}}
465 !$acc kernels loop independent
466 DO i = 1, n
467 a(i) = b(i)
468 END DO
470 ! CHECK: acc.kernels {{.*}} {
471 ! CHECK: acc.loop {{.*}} {
472 ! CHECK: acc.yield
473 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>, independent = [#acc.device_type<none>]}
474 ! CHECK: acc.terminator
475 ! CHECK-NEXT: }{{$}}
477 !$acc kernels loop gang
478 DO i = 1, n
479 a(i) = b(i)
480 END DO
482 ! CHECK: acc.kernels {{.*}} {
483 ! CHECK: acc.loop {{.*}} gang {{.*}} {
484 ! CHECK: acc.yield
485 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>}{{$}}
486 ! CHECK: acc.terminator
487 ! CHECK-NEXT: }{{$}}
489 !$acc kernels loop gang(num: 8)
490 DO i = 1, n
491 a(i) = b(i)
492 END DO
494 ! CHECK: acc.kernels {{.*}} {
495 ! CHECK: [[GANGNUM1:%.*]] = arith.constant 8 : i32
496 ! CHECK-NEXT: acc.loop {{.*}} gang({num=[[GANGNUM1]] : i32}) {{.*}} {
497 ! CHECK: acc.yield
498 ! CHECK-NEXT: }{{$}}
499 ! CHECK: acc.terminator
500 ! CHECK-NEXT: }{{$}}
502 !$acc kernels loop gang(num: gangNum)
503 DO i = 1, n
504 a(i) = b(i)
505 END DO
507 ! CHECK: acc.kernels {{.*}} {
508 ! CHECK: [[GANGNUM2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
509 ! CHECK-NEXT: acc.loop {{.*}} gang({num=[[GANGNUM2]] : i32}) {{.*}} {
510 ! CHECK: acc.yield
511 ! CHECK-NEXT: }{{$}}
512 ! CHECK: acc.terminator
513 ! CHECK-NEXT: }{{$}}
515 !$acc kernels loop gang(num: gangNum, static: gangStatic)
516 DO i = 1, n
517 a(i) = b(i)
518 END DO
520 ! CHECK: acc.kernels {{.*}} {
521 ! CHECK: acc.loop {{.*}} gang({num=%{{.*}} : i32, static=%{{.*}} : i32})
522 ! CHECK: acc.yield
523 ! CHECK-NEXT: }{{$}}
524 ! CHECK: acc.terminator
525 ! CHECK-NEXT: }{{$}}
527 !$acc kernels loop vector
528 DO i = 1, n
529 a(i) = b(i)
530 END DO
532 ! CHECK: acc.kernels {{.*}} {
533 ! CHECK: acc.loop {{.*}} vector {{.*}} {
534 ! CHECK: acc.yield
535 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>}{{$}}
536 ! CHECK: acc.terminator
537 ! CHECK-NEXT: }{{$}}
539 !$acc kernels loop vector(128)
540 DO i = 1, n
541 a(i) = b(i)
542 END DO
544 ! CHECK: acc.kernels {{.*}} {
545 ! CHECK: [[CONSTANT128:%.*]] = arith.constant 128 : i32
546 ! CHECK: acc.loop {{.*}} vector([[CONSTANT128]] : i32) {{.*}} {
547 ! CHECK: acc.yield
548 ! CHECK-NEXT: }{{$}}
549 ! CHECK: acc.terminator
550 ! CHECK-NEXT: }{{$}}
552 !$acc kernels loop vector(vectorLength)
553 DO i = 1, n
554 a(i) = b(i)
555 END DO
557 ! CHECK: acc.kernels {{.*}} {
558 ! CHECK: [[VECTORLENGTH:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
559 ! CHECK: acc.loop {{.*}} vector([[VECTORLENGTH]] : i32) {{.*}} {
560 ! CHECK: acc.yield
561 ! CHECK-NEXT: }{{$}}
562 ! CHECK: acc.terminator
563 ! CHECK-NEXT: }{{$}}
565 !$acc kernels loop worker
566 DO i = 1, n
567 a(i) = b(i)
568 END DO
570 ! CHECK: acc.kernels {{.*}} {
571 ! CHECK: acc.loop {{.*}} worker {{.*}} {
572 ! CHECK: acc.yield
573 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>}{{$}}
574 ! CHECK: acc.terminator
575 ! CHECK-NEXT: }{{$}}
577 !$acc kernels loop worker(128)
578 DO i = 1, n
579 a(i) = b(i)
580 END DO
582 ! CHECK: acc.kernels {{.*}} {
583 ! CHECK: [[WORKER128:%.*]] = arith.constant 128 : i32
584 ! CHECK: acc.loop {{.*}} worker([[WORKER128]] : i32) {{.*}} {
585 ! CHECK: acc.yield
586 ! CHECK-NEXT: }{{$}}
587 ! CHECK: acc.terminator
588 ! CHECK-NEXT: }{{$}}
590 !$acc kernels loop collapse(2)
591 DO i = 1, n
592 DO j = 1, n
593 d(i, j) = e(i, j)
594 END DO
595 END DO
597 ! CHECK: acc.kernels {{.*}} {
598 ! CHECK: acc.loop {{.*}} {
599 ! CHECK: acc.yield
600 ! CHECK-NEXT: } attributes {collapse = [2], collapseDeviceType = [#acc.device_type<none>], inclusiveUpperbound = array<i1: true, true>}
601 ! CHECK: acc.terminator
602 ! CHECK-NEXT: }{{$}}
604 !$acc kernels loop
605 DO i = 1, n
606 !$acc loop
607 DO j = 1, n
608 d(i, j) = e(i, j)
609 END DO
610 END DO
612 ! CHECK: acc.kernels {{.*}} {
613 ! CHECK: acc.loop {{.*}} {
614 ! CHECK: acc.loop {{.*}} {
615 ! CHECK: acc.yield
616 ! CHECK-NEXT: }{{$}}
617 ! CHECK: acc.yield
618 ! CHECK-NEXT: }{{$}}
619 ! CHECK: acc.terminator
620 ! CHECK-NEXT: }{{$}}
622 !$acc kernels loop tile(2)
623 DO i = 1, n
624 a(i) = b(i)
625 END DO
627 ! CHECK: acc.kernels {{.*}} {
628 ! CHECK: [[TILESIZE:%.*]] = arith.constant 2 : i32
629 ! CHECK: acc.loop {{.*}} tile({[[TILESIZE]] : i32}) {{.*}} {
630 ! CHECK: acc.yield
631 ! CHECK-NEXT: }{{$}}
632 ! CHECK: acc.terminator
633 ! CHECK-NEXT: }{{$}}
635 !$acc kernels loop tile(*)
636 DO i = 1, n
637 a(i) = b(i)
638 END DO
640 ! CHECK: acc.kernels {{.*}} {
641 ! CHECK: [[TILESIZEM1:%.*]] = arith.constant -1 : i32
642 ! CHECK: acc.loop {{.*}} tile({[[TILESIZEM1]] : i32}) {{.*}} {
643 ! CHECK: acc.yield
644 ! CHECK-NEXT: }{{$}}
645 ! CHECK: acc.terminator
646 ! CHECK-NEXT: }{{$}}
648 !$acc kernels loop tile(2, 2)
649 DO i = 1, n
650 DO j = 1, n
651 d(i, j) = e(i, j)
652 END DO
653 END DO
655 ! CHECK: acc.kernels {{.*}} {
656 ! CHECK: [[TILESIZE1:%.*]] = arith.constant 2 : i32
657 ! CHECK: [[TILESIZE2:%.*]] = arith.constant 2 : i32
658 ! CHECK: acc.loop {{.*}} tile({[[TILESIZE1]] : i32, [[TILESIZE2]] : i32}) {{.*}} {
659 ! CHECK: acc.yield
660 ! CHECK-NEXT: }{{$}}
661 ! CHECK: acc.terminator
662 ! CHECK-NEXT: }{{$}}
664 !$acc kernels loop tile(tileSize)
665 DO i = 1, n
666 a(i) = b(i)
667 END DO
669 ! CHECK: acc.kernels {{.*}} {
670 ! CHECK: acc.loop {{.*}} tile({%{{.*}} : i32}) {{.*}} {
671 ! CHECK: acc.yield
672 ! CHECK-NEXT: }{{$}}
673 ! CHECK: acc.terminator
674 ! CHECK-NEXT: }{{$}}
676 !$acc kernels loop tile(tileSize, tileSize)
677 DO i = 1, n
678 DO j = 1, n
679 d(i, j) = e(i, j)
680 END DO
681 END DO
683 ! CHECK: acc.kernels {{.*}} {
684 ! CHECK: acc.loop {{.*}} tile({%{{.*}} : i32, %{{.*}} : i32}) {{.*}} {
685 ! CHECK: acc.yield
686 ! CHECK-NEXT: }{{$}}
687 ! CHECK: acc.terminator
688 ! CHECK-NEXT: }{{$}}
690 !$acc kernels loop reduction(+:reduction_r) reduction(*:reduction_i)
691 do i = 1, n
692 reduction_r = reduction_r + a(i)
693 reduction_i = 1
694 end do
696 ! CHECK: %[[COPYINREDR:.*]] = acc.copyin varPtr(%{{.*}} : !fir.ref<f32>) -> !fir.ref<f32> {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_r"}
697 ! CHECK: %[[COPYINREDI:.*]] = acc.copyin varPtr(%{{.*}} : !fir.ref<i32>) -> !fir.ref<i32> {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_i"}
698 ! CHECK: acc.kernels {{.*}} dataOperands(%[[COPYINREDR]], %[[COPYINREDI]] : !fir.ref<f32>, !fir.ref<i32>) {
699 ! CHECK: acc.loop {{.*}} reduction(@reduction_add_ref_f32 -> %{{.*}} : !fir.ref<f32>, @reduction_mul_ref_i32 -> %{{.*}} : !fir.ref<i32>) {{.*}} {
700 ! CHECK: acc.yield
701 ! CHECK-NEXT: }{{$}}
702 ! CHECK: acc.terminator
703 ! CHECK-NEXT: }{{$}}
704 ! CHECK: acc.copyout accPtr(%[[COPYINREDR]] : !fir.ref<f32>) to varPtr(%{{.*}} : !fir.ref<f32>) {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_r"}
705 ! CHECK: acc.copyout accPtr(%[[COPYINREDI]] : !fir.ref<i32>) to varPtr(%{{.*}} : !fir.ref<i32>) {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_i"}
707 end subroutine