Debian Codegraph @

flang/test/Lower/OpenMP/wsloop-chunks.f90

raw
1 ! This test checks that chunk size is passed correctly when lowering of
2 ! OpenMP DO Directive(Worksharing) with chunk size
3
4 ! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
5
6 program wsloop
7 integer :: i
8 integer :: chunk
9
10 ! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "wsloop"} {
11 ! CHECK: %[[CHUNK_REF:.*]] = fir.alloca i32 {bindc_name = "chunk", uniq_name = "_QFEchunk"}
12 ! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[CHUNK_REF]] {uniq_name = "_QFEchunk"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
13
14 !$OMP DO SCHEDULE(static, 4)
15
16 do i=1, 9
17 print*, i
18
19 ! CHECK: %[[VAL_2:.*]] = arith.constant 4 : i32
20 ! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i32
21 ! CHECK: %[[VAL_4:.*]] = arith.constant 9 : i32
22 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32
23 ! CHECK: omp.wsloop schedule(static = %[[VAL_2]] : i32) nowait {
24 ! CHECK-NEXT: omp.loop_nest (%[[ARG0:.*]]) : i32 = (%[[VAL_3]]) to (%[[VAL_4]]) inclusive step (%[[VAL_5]]) {
25 ! CHECK: fir.store %[[ARG0]] to %[[STORE_IV:.*]]#1 : !fir.ref<i32>
26 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[STORE_IV]]#0 : !fir.ref<i32>
27 ! CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
28 ! CHECK: omp.yield
29 ! CHECK: }
30 ! CHECK: omp.terminator
31 ! CHECK: }
32
33 end do
34 !$OMP END DO NOWAIT
35 !$OMP DO SCHEDULE(static, 2+2)
36
37 do i=1, 9
38 print*, i*2
39
40 ! CHECK: %[[VAL_14:.*]] = arith.constant 4 : i32
41 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : i32
42 ! CHECK: %[[VAL_16:.*]] = arith.constant 9 : i32
43 ! CHECK: %[[VAL_17:.*]] = arith.constant 1 : i32
44 ! CHECK: omp.wsloop schedule(static = %[[VAL_14]] : i32) nowait {
45 ! CHECK-NEXT: omp.loop_nest (%[[ARG1:.*]]) : i32 = (%[[VAL_15]]) to (%[[VAL_16]]) inclusive step (%[[VAL_17]]) {
46 ! CHECK: fir.store %[[ARG1]] to %[[STORE_IV1:.*]]#1 : !fir.ref<i32>
47 ! CHECK: %[[VAL_24:.*]] = arith.constant 2 : i32
48 ! CHECK: %[[LOAD_IV1:.*]] = fir.load %[[STORE_IV1]]#0 : !fir.ref<i32>
49 ! CHECK: %[[VAL_25:.*]] = arith.muli %[[VAL_24]], %[[LOAD_IV1]] : i32
50 ! CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[VAL_25]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
51 ! CHECK: omp.yield
52 ! CHECK: }
53 ! CHECK: omp.terminator
54 ! CHECK: }
55
56 end do
57 !$OMP END DO NOWAIT
58 chunk = 6
59 !$OMP DO SCHEDULE(static, chunk)
60
61 do i=1, 9
62 print*, i*3
63 end do
64 !$OMP END DO NOWAIT
65 ! CHECK: %[[VAL_28:.*]] = arith.constant 6 : i32
66 ! CHECK: hlfir.assign %[[VAL_28]] to %[[VAL_0]]#0 : i32, !fir.ref<i32>
67 ! CHECK: %[[VAL_29:.*]] = fir.load %[[VAL_0]]#0 : !fir.ref<i32>
68 ! CHECK: %[[VAL_30:.*]] = arith.constant 1 : i32
69 ! CHECK: %[[VAL_31:.*]] = arith.constant 9 : i32
70 ! CHECK: %[[VAL_32:.*]] = arith.constant 1 : i32
71 ! CHECK: omp.wsloop schedule(static = %[[VAL_29]] : i32) nowait {
72 ! CHECK-NEXT: omp.loop_nest (%[[ARG2:.*]]) : i32 = (%[[VAL_30]]) to (%[[VAL_31]]) inclusive step (%[[VAL_32]]) {
73 ! CHECK: fir.store %[[ARG2]] to %[[STORE_IV2:.*]]#1 : !fir.ref<i32>
74 ! CHECK: %[[VAL_39:.*]] = arith.constant 3 : i32
75 ! CHECK: %[[LOAD_IV2:.*]] = fir.load %[[STORE_IV2]]#0 : !fir.ref<i32>
76 ! CHECK: %[[VAL_40:.*]] = arith.muli %[[VAL_39]], %[[LOAD_IV2]] : i32
77 ! CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[VAL_40]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
78 ! CHECK: omp.yield
79 ! CHECK: }
80 ! CHECK: omp.terminator
81 ! CHECK: }
82 ! CHECK: return
83 ! CHECK: }
84
85 end