[rtsan] Add fork/execve interceptors (#117198)
[llvm-project.git] / flang / test / Lower / OpenACC / acc-parallel-loop.f90
blob48ceda0710e8dba9547d5e0b4b75cd4cb5e5f1d3
1 ! This test checks lowering of OpenACC parallel loop combined directive.
3 ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
5 ! CHECK-LABEL: func.func @_QPacc_parallel_loop()
7 subroutine acc_parallel_loop
8 integer :: i, j
10 integer :: async = 1
11 integer :: wait1 = 1
12 integer :: wait2 = 2
13 integer :: numGangs = 1
14 integer :: numWorkers = 10
15 integer :: vectorLength = 128
16 logical :: ifCondition = .TRUE.
17 integer, parameter :: n = 10
18 real, dimension(n) :: a, b, c
19 real, dimension(n, n) :: d, e
20 real, pointer :: f, g
21 integer :: reduction_i
22 real :: reduction_r
24 integer :: gangNum = 8
25 integer :: gangStatic = 8
26 integer :: vectorNum = 128
27 integer, parameter :: tileSize = 2
29 ! CHECK: %[[A:.*]] = fir.alloca !fir.array<10xf32> {{{.*}}uniq_name = "{{.*}}Ea"}
30 ! CHECK: %[[DECLA:.*]]:2 = hlfir.declare %[[A]]
31 ! CHECK: %[[B:.*]] = fir.alloca !fir.array<10xf32> {{{.*}}uniq_name = "{{.*}}Eb"}
32 ! CHECK: %[[DECLB:.*]]:2 = hlfir.declare %[[B]]
33 ! CHECK: %[[C:.*]] = fir.alloca !fir.array<10xf32> {{{.*}}uniq_name = "{{.*}}Ec"}
34 ! CHECK: %[[DECLC:.*]]:2 = hlfir.declare %[[C]]
35 ! CHECK: %[[F:.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "f", uniq_name = "{{.*}}Ef"}
36 ! CHECK: %[[DECLF:.*]]:2 = hlfir.declare %[[F]]
37 ! CHECK: %[[G:.*]] = fir.alloca !fir.box<!fir.ptr<f32>> {bindc_name = "g", uniq_name = "{{.*}}Eg"}
38 ! CHECK: %[[DECLG:.*]]:2 = hlfir.declare %[[G]]
39 ! CHECK: %[[IFCONDITION:.*]] = fir.address_of(@{{.*}}ifcondition) : !fir.ref<!fir.logical<4>>
40 ! CHECK: %[[DECLIFCONDITION:.*]]:2 = hlfir.declare %[[IFCONDITION]]
42 !$acc parallel
43 !$acc loop
44 DO i = 1, n
45 a(i) = b(i)
46 END DO
47 !$acc end parallel
49 ! CHECK: acc.parallel {
50 ! CHECK: acc.loop private{{.*}} {
51 ! CHECK: acc.yield
52 ! CHECK-NEXT: }{{$}}
53 ! CHECK: acc.yield
54 ! CHECK-NEXT: }{{$}}
56 !$acc parallel loop
57 DO i = 1, n
58 a(i) = b(i)
59 END DO
61 ! CHECK: acc.parallel combined(loop) {
62 ! CHECK: acc.loop combined(parallel) private{{.*}} {
63 ! CHECK: acc.yield
64 ! CHECK-NEXT: }{{$}}
65 ! CHECK: acc.yield
66 ! CHECK-NEXT: }{{$}}
68 !$acc parallel loop async
69 DO i = 1, n
70 a(i) = b(i)
71 END DO
72 !$acc end parallel loop
74 ! CHECK: acc.parallel {{.*}} {
75 ! CHECK: acc.loop {{.*}} {
76 ! CHECK: acc.yield
77 ! CHECK-NEXT: }{{$}}
78 ! CHECK: acc.yield
79 ! CHECK-NEXT: } attributes {asyncOnly = [#acc.device_type<none>]}
81 !$acc parallel loop async(1)
82 DO i = 1, n
83 a(i) = b(i)
84 END DO
86 ! CHECK: [[ASYNC1:%.*]] = arith.constant 1 : i32
87 ! CHECK: acc.parallel {{.*}} async([[ASYNC1]] : i32) {
88 ! CHECK: acc.loop {{.*}} {
89 ! CHECK: acc.yield
90 ! CHECK-NEXT: }{{$}}
91 ! CHECK: acc.yield
92 ! CHECK-NEXT: }{{$}}
94 !$acc parallel loop async(async)
95 DO i = 1, n
96 a(i) = b(i)
97 END DO
99 ! CHECK: [[ASYNC2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
100 ! CHECK: acc.parallel {{.*}} async([[ASYNC2]] : i32) {
101 ! CHECK: acc.loop {{.*}} {
102 ! CHECK: acc.yield
103 ! CHECK-NEXT: }{{$}}
104 ! CHECK: acc.yield
105 ! CHECK-NEXT: }{{$}}
107 !$acc parallel loop wait
108 DO i = 1, n
109 a(i) = b(i)
110 END DO
112 ! CHECK: acc.parallel {{.*}} wait {
113 ! CHECK: acc.loop {{.*}} {
114 ! CHECK: acc.yield
115 ! CHECK-NEXT: }{{$}}
116 ! CHECK: acc.yield
117 ! CHECK-NEXT: }
119 !$acc parallel loop wait(1)
120 DO i = 1, n
121 a(i) = b(i)
122 END DO
124 ! CHECK: [[WAIT1:%.*]] = arith.constant 1 : i32
125 ! CHECK: acc.parallel {{.*}} wait({[[WAIT1]] : i32}) {
126 ! CHECK: acc.loop
127 ! CHECK: acc.yield
128 ! CHECK-NEXT: }{{$}}
129 ! CHECK: acc.yield
130 ! CHECK-NEXT: }{{$}}
132 !$acc parallel loop wait(1, 2)
133 DO i = 1, n
134 a(i) = b(i)
135 END DO
137 ! CHECK: [[WAIT2:%.*]] = arith.constant 1 : i32
138 ! CHECK: [[WAIT3:%.*]] = arith.constant 2 : i32
139 ! CHECK: acc.parallel {{.*}} wait({[[WAIT2]] : i32, [[WAIT3]] : i32}) {
140 ! CHECK: acc.loop
141 ! CHECK: acc.yield
142 ! CHECK-NEXT: }{{$}}
143 ! CHECK: acc.yield
144 ! CHECK-NEXT: }{{$}}
146 !$acc parallel loop wait(wait1, wait2)
147 DO i = 1, n
148 a(i) = b(i)
149 END DO
151 ! CHECK: [[WAIT4:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
152 ! CHECK: [[WAIT5:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
153 ! CHECK: acc.parallel {{.*}} wait({[[WAIT4]] : i32, [[WAIT5]] : i32}) {
154 ! CHECK: acc.loop
155 ! CHECK: acc.yield
156 ! CHECK-NEXT: }{{$}}
157 ! CHECK: acc.yield
158 ! CHECK-NEXT: }{{$}}
160 !$acc parallel loop num_gangs(1)
161 DO i = 1, n
162 a(i) = b(i)
163 END DO
165 ! CHECK: [[NUMGANGS1:%.*]] = arith.constant 1 : i32
166 ! CHECK: acc.parallel {{.*}} num_gangs({[[NUMGANGS1]] : i32}) {
167 ! CHECK: acc.loop
168 ! CHECK: acc.yield
169 ! CHECK-NEXT: }{{$}}
170 ! CHECK: acc.yield
171 ! CHECK-NEXT: }{{$}}
173 !$acc parallel loop num_gangs(numGangs)
174 DO i = 1, n
175 a(i) = b(i)
176 END DO
178 ! CHECK: [[NUMGANGS2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
179 ! CHECK: acc.parallel {{.*}} num_gangs({[[NUMGANGS2]] : i32}) {
180 ! CHECK: acc.loop
181 ! CHECK: acc.yield
182 ! CHECK-NEXT: }{{$}}
183 ! CHECK: acc.yield
184 ! CHECK-NEXT: }{{$}}
186 !$acc parallel loop num_workers(10)
187 DO i = 1, n
188 a(i) = b(i)
189 END DO
191 ! CHECK: [[NUMWORKERS1:%.*]] = arith.constant 10 : i32
192 ! CHECK: acc.parallel {{.*}} num_workers([[NUMWORKERS1]] : i32) {
193 ! CHECK: acc.loop {{.*}} {
194 ! CHECK: acc.yield
195 ! CHECK-NEXT: }{{$}}
196 ! CHECK: acc.yield
197 ! CHECK-NEXT: }{{$}}
199 !$acc parallel loop num_workers(numWorkers)
200 DO i = 1, n
201 a(i) = b(i)
202 END DO
204 ! CHECK: [[NUMWORKERS2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
205 ! CHECK: acc.parallel {{.*}} num_workers([[NUMWORKERS2]] : i32) {
206 ! CHECK: acc.loop {{.*}} {
207 ! CHECK: acc.yield
208 ! CHECK-NEXT: }{{$}}
209 ! CHECK: acc.yield
210 ! CHECK-NEXT: }{{$}}
212 !$acc parallel loop vector_length(128)
213 DO i = 1, n
214 a(i) = b(i)
215 END DO
217 ! CHECK: [[VECTORLENGTH1:%.*]] = arith.constant 128 : i32
218 ! CHECK: acc.parallel {{.*}} vector_length([[VECTORLENGTH1]] : i32) {
219 ! CHECK: acc.loop {{.*}} {
220 ! CHECK: acc.yield
221 ! CHECK-NEXT: }{{$}}
222 ! CHECK: acc.yield
223 ! CHECK-NEXT: }{{$}}
225 !$acc parallel loop vector_length(vectorLength)
226 DO i = 1, n
227 a(i) = b(i)
228 END DO
230 ! CHECK: [[VECTORLENGTH2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
231 ! CHECK: acc.parallel {{.*}} vector_length([[VECTORLENGTH2]] : i32) {
232 ! CHECK: acc.loop {{.*}} {
233 ! CHECK: acc.yield
234 ! CHECK-NEXT: }{{$}}
235 ! CHECK: acc.yield
236 ! CHECK-NEXT: }{{$}}
238 !$acc parallel loop if(.TRUE.)
239 DO i = 1, n
240 a(i) = b(i)
241 END DO
243 ! CHECK: [[IF1:%.*]] = arith.constant true
244 ! CHECK: acc.parallel {{.*}} if([[IF1]]) {
245 ! CHECK: acc.loop {{.*}} {
246 ! CHECK: acc.yield
247 ! CHECK-NEXT: }{{$}}
248 ! CHECK: acc.yield
249 ! CHECK-NEXT: }{{$}}
251 !$acc parallel loop if(ifCondition)
252 DO i = 1, n
253 a(i) = b(i)
254 END DO
256 ! CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
257 ! CHECK: [[IF2:%.*]] = fir.convert [[IFCOND]] : (!fir.logical<4>) -> i1
258 ! CHECK: acc.parallel {{.*}} if([[IF2]]) {
259 ! CHECK: acc.loop {{.*}} {
260 ! CHECK: acc.yield
261 ! CHECK-NEXT: }{{$}}
262 ! CHECK: acc.yield
263 ! CHECK-NEXT: }{{$}}
265 !$acc parallel loop self(.TRUE.)
266 DO i = 1, n
267 a(i) = b(i)
268 END DO
270 ! CHECK: [[SELF1:%.*]] = arith.constant true
271 ! CHECK: acc.parallel {{.*}} self([[SELF1]]) {
272 ! CHECK: acc.loop {{.*}} {
273 ! CHECK: acc.yield
274 ! CHECK-NEXT: }{{$}}
275 ! CHECK: acc.yield
276 ! CHECK-NEXT: }{{$}}
278 !$acc parallel loop self
279 DO i = 1, n
280 a(i) = b(i)
281 END DO
283 ! CHECK: acc.parallel {{.*}} {
284 ! CHECK: acc.loop {{.*}} {
285 ! CHECK: acc.yield
286 ! CHECK-NEXT: }{{$}}
287 ! CHECK: acc.yield
288 ! CHECK-NEXT: } attributes {selfAttr}
290 !$acc parallel loop self(ifCondition)
291 DO i = 1, n
292 a(i) = b(i)
293 END DO
295 ! CHECK: %[[SELF2:.*]] = fir.convert %[[DECLIFCONDITION]]#1 : (!fir.ref<!fir.logical<4>>) -> i1
296 ! CHECK: acc.parallel {{.*}} self(%[[SELF2]]) {
297 ! CHECK: acc.loop {{.*}} {
298 ! CHECK: acc.yield
299 ! CHECK-NEXT: }{{$}}
300 ! CHECK: acc.yield
301 ! CHECK-NEXT: }{{$}}
303 !$acc parallel loop copy(a, b)
304 DO i = 1, n
305 a(i) = b(i)
306 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.parallel {{.*}} 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.yield
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 parallel 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.parallel {{.*}} 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.yield
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 parallel 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.parallel {{.*}} 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.yield
347 ! CHECK-NEXT: }{{$}}
349 !$acc parallel 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.parallel {{.*}} 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.yield
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 parallel 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.parallel {{.*}} 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.yield
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 parallel 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.parallel {{.*}} 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.yield
393 ! CHECK-NEXT: }{{$}}
395 !$acc parallel 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.parallel {{.*}} 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.yield
407 ! CHECK-NEXT: }{{$}}
409 !$acc parallel 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.parallel {{.*}} 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.yield
421 ! CHECK-NEXT: }{{$}}
423 !$acc parallel 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.parallel {{.*}} 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.yield
439 ! CHECK-NEXT: }{{$}}
441 !$acc parallel loop private(a) firstprivate(b)
442 DO i = 1, n
443 a(i) = b(i)
444 END DO
446 ! CHECK: %[[ACC_PRIVATE_B:.*]] = acc.firstprivate varPtr(%[[DECLB]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "b"}
447 ! CHECK: acc.parallel {{.*}} firstprivate(@firstprivatization_section_ext10_ref_10xf32 -> %[[ACC_PRIVATE_B]] : !fir.ref<!fir.array<10xf32>>) {
448 ! CHECK: %[[ACC_PRIVATE_A:.*]] = acc.private varPtr(%[[DECLA]]#0 : !fir.ref<!fir.array<10xf32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<10xf32>> {name = "a"}
449 ! CHECK: acc.loop {{.*}} private({{.*}}@privatization_ref_10xf32 -> %[[ACC_PRIVATE_A]] : !fir.ref<!fir.array<10xf32>>)
450 ! CHECK-NOT: fir.do_loop
451 ! CHECK: acc.yield
452 ! CHECK-NEXT: }{{$}}
453 ! CHECK: acc.yield
454 ! CHECK-NEXT: }{{$}}
456 !$acc parallel loop seq
457 DO i = 1, n
458 a(i) = b(i)
459 END DO
461 ! CHECK: acc.parallel {{.*}} {
462 ! CHECK: acc.loop {{.*}} {
463 ! CHECK: acc.yield
464 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>, seq = [#acc.device_type<none>]}
465 ! CHECK: acc.yield
466 ! CHECK-NEXT: }{{$}}
468 !$acc parallel loop auto
469 DO i = 1, n
470 a(i) = b(i)
471 END DO
473 ! CHECK: acc.parallel {{.*}} {
474 ! CHECK: acc.loop {{.*}} {
475 ! CHECK: acc.yield
476 ! CHECK-NEXT: } attributes {auto_ = [#acc.device_type<none>], inclusiveUpperbound = array<i1: true>}
477 ! CHECK: acc.yield
478 ! CHECK-NEXT: }{{$}}
480 !$acc parallel loop independent
481 DO i = 1, n
482 a(i) = b(i)
483 END DO
485 ! CHECK: acc.parallel {{.*}} {
486 ! CHECK: acc.loop {{.*}} {
487 ! CHECK: acc.yield
488 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>, independent = [#acc.device_type<none>]}
489 ! CHECK: acc.yield
490 ! CHECK-NEXT: }{{$}}
492 !$acc parallel loop gang
493 DO i = 1, n
494 a(i) = b(i)
495 END DO
497 ! CHECK: acc.parallel {{.*}} {
498 ! CHECK: acc.loop {{.*}} gang
499 ! CHECK: acc.yield
500 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>}{{$}}
501 ! CHECK: acc.yield
502 ! CHECK-NEXT: }{{$}}
504 !$acc parallel loop gang(num: 8)
505 DO i = 1, n
506 a(i) = b(i)
507 END DO
509 ! CHECK: acc.parallel {{.*}} {
510 ! CHECK: [[GANGNUM1:%.*]] = arith.constant 8 : i32
511 ! CHECK-NEXT: acc.loop {{.*}} gang({num=[[GANGNUM1]] : i32})
512 ! CHECK: acc.yield
513 ! CHECK-NEXT: }{{$}}
514 ! CHECK: acc.yield
515 ! CHECK-NEXT: }{{$}}
517 !$acc parallel loop gang(num: gangNum)
518 DO i = 1, n
519 a(i) = b(i)
520 END DO
522 ! CHECK: acc.parallel {{.*}} {
523 ! CHECK: [[GANGNUM2:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
524 ! CHECK-NEXT: acc.loop {{.*}} gang({num=[[GANGNUM2]] : i32})
525 ! CHECK: acc.yield
526 ! CHECK-NEXT: }{{$}}
527 ! CHECK: acc.yield
528 ! CHECK-NEXT: }{{$}}
530 !$acc parallel loop gang(num: gangNum, static: gangStatic)
531 DO i = 1, n
532 a(i) = b(i)
533 END DO
535 ! CHECK: acc.parallel {{.*}} {
536 ! CHECK: acc.loop {{.*}} gang({num=%{{.*}} : i32, static=%{{.*}} : i32})
537 ! CHECK: acc.yield
538 ! CHECK-NEXT: }{{$}}
539 ! CHECK: acc.yield
540 ! CHECK-NEXT: }{{$}}
542 !$acc parallel loop vector
543 DO i = 1, n
544 a(i) = b(i)
545 END DO
547 ! CHECK: acc.parallel {{.*}} {
548 ! CHECK: acc.loop {{.*}} vector
549 ! CHECK: acc.yield
550 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>}{{$}}
551 ! CHECK: acc.yield
552 ! CHECK-NEXT: }{{$}}
554 !$acc parallel loop vector(128)
555 DO i = 1, n
556 a(i) = b(i)
557 END DO
559 ! CHECK: acc.parallel {{.*}} {
560 ! CHECK: [[CONSTANT128:%.*]] = arith.constant 128 : i32
561 ! CHECK: acc.loop {{.*}} vector([[CONSTANT128]] : i32) {{.*}} {
562 ! CHECK: acc.yield
563 ! CHECK-NEXT: }{{$}}
564 ! CHECK: acc.yield
565 ! CHECK-NEXT: }{{$}}
567 !$acc parallel loop vector(vectorLength)
568 DO i = 1, n
569 a(i) = b(i)
570 END DO
572 ! CHECK: acc.parallel {{.*}} {
573 ! CHECK: [[VECTORLENGTH:%.*]] = fir.load %{{.*}} : !fir.ref<i32>
574 ! CHECK: acc.loop {{.*}} vector([[VECTORLENGTH]] : i32) {{.*}} {
575 ! CHECK-NOT: fir.do_loop
576 ! CHECK: acc.yield
577 ! CHECK-NEXT: }{{$}}
578 ! CHECK: acc.yield
579 ! CHECK-NEXT: }{{$}}
581 !$acc parallel loop worker
582 DO i = 1, n
583 a(i) = b(i)
584 END DO
586 ! CHECK: acc.parallel {{.*}} {
587 ! CHECK: acc.loop {{.*}} worker {{.*}} {
588 ! CHECK-NOT: fir.do_loop
589 ! CHECK: acc.yield
590 ! CHECK-NEXT: } attributes {inclusiveUpperbound = array<i1: true>}{{$}}
591 ! CHECK: acc.yield
592 ! CHECK-NEXT: }{{$}}
594 !$acc parallel loop worker(128)
595 DO i = 1, n
596 a(i) = b(i)
597 END DO
599 ! CHECK: acc.parallel {{.*}}{
600 ! CHECK: [[WORKER128:%.*]] = arith.constant 128 : i32
601 ! CHECK: acc.loop {{.*}} worker([[WORKER128]] : i32) {{.*}} {
602 ! CHECK-NOT: fir.do_loop
603 ! CHECK: acc.yield
604 ! CHECK-NEXT: }{{$}}
605 ! CHECK: acc.yield
606 ! CHECK-NEXT: }{{$}}
608 !$acc parallel loop collapse(2)
609 DO i = 1, n
610 DO j = 1, n
611 d(i, j) = e(i, j)
612 END DO
613 END DO
615 ! CHECK: acc.parallel {{.*}} {
616 ! CHECK: acc.loop {{.*}} {
617 ! CHECK: acc.yield
618 ! CHECK-NEXT: } attributes {collapse = [2], collapseDeviceType = [#acc.device_type<none>], inclusiveUpperbound = array<i1: true, true>}
619 ! CHECK: acc.yield
620 ! CHECK-NEXT: }{{$}}
622 !$acc parallel loop
623 DO i = 1, n
624 !$acc loop
625 DO j = 1, n
626 d(i, j) = e(i, j)
627 END DO
628 END DO
630 ! CHECK: acc.parallel {{.*}} {
631 ! CHECK: acc.loop {{.*}} {
632 ! CHECK: acc.loop {{.*}} {
633 ! CHECK: acc.yield
634 ! CHECK-NEXT: }{{$}}
635 ! CHECK: acc.yield
636 ! CHECK-NEXT: }{{$}}
637 ! CHECK: acc.yield
638 ! CHECK-NEXT: }{{$}}
640 !$acc parallel loop tile(2)
641 DO i = 1, n
642 a(i) = b(i)
643 END DO
645 ! CHECK: acc.parallel {{.*}} {
646 ! CHECK: [[TILESIZE:%.*]] = arith.constant 2 : i32
647 ! CHECK: acc.loop {{.*}} tile({[[TILESIZE]] : i32}) {{.*}} {
648 ! CHECK: acc.yield
649 ! CHECK-NEXT: }{{$}}
650 ! CHECK: acc.yield
651 ! CHECK-NEXT: }{{$}}
653 !$acc parallel loop tile(*)
654 DO i = 1, n
655 a(i) = b(i)
656 END DO
658 ! CHECK: acc.parallel {{.*}} {
659 ! CHECK: [[TILESIZEM1:%.*]] = arith.constant -1 : i32
660 ! CHECK: acc.loop {{.*}} tile({[[TILESIZEM1]] : i32}) {{.*}} {
661 ! CHECK: acc.yield
662 ! CHECK-NEXT: }{{$}}
663 ! CHECK: acc.yield
664 ! CHECK-NEXT: }{{$}}
666 !$acc parallel loop tile(2, 2)
667 DO i = 1, n
668 DO j = 1, n
669 d(i, j) = e(i, j)
670 END DO
671 END DO
673 ! CHECK: acc.parallel {{.*}} {
674 ! CHECK: [[TILESIZE1:%.*]] = arith.constant 2 : i32
675 ! CHECK: [[TILESIZE2:%.*]] = arith.constant 2 : i32
676 ! CHECK: acc.loop {{.*}} tile({[[TILESIZE1]] : i32, [[TILESIZE2]] : i32}) {{.*}} {
677 ! CHECK: acc.yield
678 ! CHECK-NEXT: }{{$}}
679 ! CHECK: acc.yield
680 ! CHECK-NEXT: }{{$}}
682 !$acc parallel loop tile(tileSize)
683 DO i = 1, n
684 a(i) = b(i)
685 END DO
687 ! CHECK: acc.parallel {{.*}} {
688 ! CHECK: acc.loop {{.*}} tile({%{{.*}} : i32}) {{.*}} {
689 ! CHECK: acc.yield
690 ! CHECK-NEXT: }{{$}}
691 ! CHECK: acc.yield
692 ! CHECK-NEXT: }{{$}}
694 !$acc parallel loop tile(tileSize, tileSize)
695 DO i = 1, n
696 DO j = 1, n
697 d(i, j) = e(i, j)
698 END DO
699 END DO
701 ! CHECK: acc.parallel {{.*}} {
702 ! CHECK: acc.loop {{.*}} tile({%{{.*}} : i32, %{{.*}} : i32}) {{.*}} {
703 ! CHECK: acc.yield
704 ! CHECK-NEXT: }{{$}}
705 ! CHECK: acc.yield
706 ! CHECK-NEXT: }{{$}}
708 !$acc parallel loop reduction(+:reduction_r) reduction(*:reduction_i)
709 do i = 1, n
710 reduction_r = reduction_r + a(i)
711 reduction_i = 1
712 end do
714 ! CHECK: %[[COPYINREDR:.*]] = acc.copyin varPtr(%{{.*}} : !fir.ref<f32>) -> !fir.ref<f32> {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_r"}
715 ! CHECK: %[[COPYINREDI:.*]] = acc.copyin varPtr(%{{.*}} : !fir.ref<i32>) -> !fir.ref<i32> {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_i"}
716 ! CHECK: acc.parallel {{.*}} dataOperands(%[[COPYINREDR]], %[[COPYINREDI]] : !fir.ref<f32>, !fir.ref<i32>) {
717 ! CHECK: acc.loop {{.*}} reduction(@reduction_add_ref_f32 -> %{{.*}} : !fir.ref<f32>, @reduction_mul_ref_i32 -> %{{.*}} : !fir.ref<i32>) {{.*}}
718 ! CHECK: acc.yield
719 ! CHECK-NEXT: }{{$}}
720 ! CHECK: acc.yield
721 ! CHECK-NEXT: }{{$}}
722 ! CHECK: acc.copyout accPtr(%[[COPYINREDR]] : !fir.ref<f32>) to varPtr(%{{.*}} : !fir.ref<f32>) {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_r"}
723 ! CHECK: acc.copyout accPtr(%[[COPYINREDI]] : !fir.ref<i32>) to varPtr(%{{.*}} : !fir.ref<i32>) {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_i"}
726 !$acc parallel loop
727 do 10 i=0, n
728 10 continue
729 ! CHECK: acc.parallel
730 ! CHECK: acc.loop
731 ! CHECK-NOT: fir.do_loop
733 end subroutine acc_parallel_loop