xref: /llvm-project/flang/test/Lower/OpenMP/wsloop-chunks.f90 (revision 937cbce14c9aa956342a9c818c26a8a557802843)
15b66987cSKiran Chandramohan! This test checks that chunk size is passed correctly when lowering of
25b66987cSKiran Chandramohan! OpenMP DO Directive(Worksharing) with chunk size
35b66987cSKiran Chandramohan
45b66987cSKiran Chandramohan! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
55b66987cSKiran Chandramohan
65b66987cSKiran Chandramohanprogram wsloop
75b66987cSKiran Chandramohan        integer :: i
85b66987cSKiran Chandramohan        integer :: chunk
95b66987cSKiran Chandramohan
105b66987cSKiran Chandramohan! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "wsloop"} {
115b66987cSKiran Chandramohan! CHECK:         %[[CHUNK_REF:.*]] = fir.alloca i32 {bindc_name = "chunk", uniq_name = "_QFEchunk"}
125b66987cSKiran Chandramohan! CHECK:         %[[VAL_0:.*]]:2 = hlfir.declare %[[CHUNK_REF]] {uniq_name = "_QFEchunk"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
135b66987cSKiran Chandramohan
145b66987cSKiran Chandramohan!$OMP DO SCHEDULE(static, 4)
155b66987cSKiran Chandramohan
165b66987cSKiran Chandramohando i=1, 9
175b66987cSKiran Chandramohan  print*, i
185b66987cSKiran Chandramohan
192b56005fSSergio Afonso! CHECK:         %[[VAL_2:.*]] = arith.constant 4 : i32
202b56005fSSergio Afonso! CHECK:         %[[VAL_3:.*]] = arith.constant 1 : i32
212b56005fSSergio Afonso! CHECK:         %[[VAL_4:.*]] = arith.constant 9 : i32
222b56005fSSergio Afonso! CHECK:         %[[VAL_5:.*]] = arith.constant 1 : i32
23*937cbce1SKareem Ergawy! CHECK:         omp.wsloop nowait schedule(static = %[[VAL_2]] : i32) {
242b56005fSSergio Afonso! CHECK-NEXT:      omp.loop_nest (%[[ARG0:.*]]) : i32 = (%[[VAL_3]]) to (%[[VAL_4]]) inclusive step (%[[VAL_5]]) {
255b66987cSKiran Chandramohan! CHECK:             fir.store %[[ARG0]] to %[[STORE_IV:.*]]#1 : !fir.ref<i32>
265b66987cSKiran Chandramohan! CHECK:             %[[LOAD_IV:.*]] = fir.load %[[STORE_IV]]#0 : !fir.ref<i32>
275b66987cSKiran Chandramohan! CHECK:             {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
285b66987cSKiran Chandramohan! CHECK:             omp.yield
295b66987cSKiran Chandramohan! CHECK:           }
30ca4dbc27SSergio Afonso! CHECK:         }
315b66987cSKiran Chandramohan
325b66987cSKiran Chandramohanend do
335b66987cSKiran Chandramohan!$OMP END DO NOWAIT
345b66987cSKiran Chandramohan!$OMP DO SCHEDULE(static, 2+2)
355b66987cSKiran Chandramohan
365b66987cSKiran Chandramohando i=1, 9
375b66987cSKiran Chandramohan  print*, i*2
385b66987cSKiran Chandramohan
392b56005fSSergio Afonso! CHECK:         %[[VAL_14:.*]] = arith.constant 4 : i32
402b56005fSSergio Afonso! CHECK:         %[[VAL_15:.*]] = arith.constant 1 : i32
412b56005fSSergio Afonso! CHECK:         %[[VAL_16:.*]] = arith.constant 9 : i32
422b56005fSSergio Afonso! CHECK:         %[[VAL_17:.*]] = arith.constant 1 : i32
43*937cbce1SKareem Ergawy! CHECK:         omp.wsloop nowait schedule(static = %[[VAL_14]] : i32) {
442b56005fSSergio Afonso! CHECK-NEXT:      omp.loop_nest (%[[ARG1:.*]]) : i32 = (%[[VAL_15]]) to (%[[VAL_16]]) inclusive step (%[[VAL_17]]) {
455b66987cSKiran Chandramohan! CHECK:             fir.store %[[ARG1]] to %[[STORE_IV1:.*]]#1 : !fir.ref<i32>
465b66987cSKiran Chandramohan! CHECK:             %[[VAL_24:.*]] = arith.constant 2 : i32
475b66987cSKiran Chandramohan! CHECK:             %[[LOAD_IV1:.*]] = fir.load %[[STORE_IV1]]#0 : !fir.ref<i32>
485b66987cSKiran Chandramohan! CHECK:             %[[VAL_25:.*]] = arith.muli %[[VAL_24]], %[[LOAD_IV1]] : i32
495b66987cSKiran Chandramohan! CHECK:             {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[VAL_25]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
505b66987cSKiran Chandramohan! CHECK:             omp.yield
515b66987cSKiran Chandramohan! CHECK:           }
52ca4dbc27SSergio Afonso! CHECK:         }
535b66987cSKiran Chandramohan
545b66987cSKiran Chandramohanend do
555b66987cSKiran Chandramohan!$OMP END DO NOWAIT
565b66987cSKiran Chandramohanchunk = 6
575b66987cSKiran Chandramohan!$OMP DO SCHEDULE(static, chunk)
585b66987cSKiran Chandramohan
595b66987cSKiran Chandramohando i=1, 9
605b66987cSKiran Chandramohan   print*, i*3
615b66987cSKiran Chandramohanend do
625b66987cSKiran Chandramohan!$OMP END DO NOWAIT
635b66987cSKiran Chandramohan! CHECK:         %[[VAL_28:.*]] = arith.constant 6 : i32
645b66987cSKiran Chandramohan! CHECK:         hlfir.assign %[[VAL_28]] to %[[VAL_0]]#0 : i32, !fir.ref<i32>
652b56005fSSergio Afonso! CHECK:         %[[VAL_29:.*]] = fir.load %[[VAL_0]]#0 : !fir.ref<i32>
662b56005fSSergio Afonso! CHECK:         %[[VAL_30:.*]] = arith.constant 1 : i32
672b56005fSSergio Afonso! CHECK:         %[[VAL_31:.*]] = arith.constant 9 : i32
682b56005fSSergio Afonso! CHECK:         %[[VAL_32:.*]] = arith.constant 1 : i32
69*937cbce1SKareem Ergawy! CHECK:         omp.wsloop nowait schedule(static = %[[VAL_29]] : i32) {
702b56005fSSergio Afonso! CHECK-NEXT:      omp.loop_nest (%[[ARG2:.*]]) : i32 = (%[[VAL_30]]) to (%[[VAL_31]]) inclusive step (%[[VAL_32]]) {
715b66987cSKiran Chandramohan! CHECK:             fir.store %[[ARG2]] to %[[STORE_IV2:.*]]#1 : !fir.ref<i32>
725b66987cSKiran Chandramohan! CHECK:             %[[VAL_39:.*]] = arith.constant 3 : i32
735b66987cSKiran Chandramohan! CHECK:             %[[LOAD_IV2:.*]] = fir.load %[[STORE_IV2]]#0 : !fir.ref<i32>
745b66987cSKiran Chandramohan! CHECK:             %[[VAL_40:.*]] = arith.muli %[[VAL_39]], %[[LOAD_IV2]] : i32
755b66987cSKiran Chandramohan! CHECK:             {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[VAL_40]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
765b66987cSKiran Chandramohan! CHECK:             omp.yield
775b66987cSKiran Chandramohan! CHECK:           }
78ca4dbc27SSergio Afonso! CHECK:         }
795b66987cSKiran Chandramohan! CHECK:         return
805b66987cSKiran Chandramohan! CHECK:       }
815b66987cSKiran Chandramohan
825b66987cSKiran Chandramohanend
83