| 1 |
! This test checks lowering of OpenMP DO Directive (Worksharing). |
| 2 |
|
| 3 |
! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s |
| 4 |
|
| 5 |
!CHECK-LABEL: func @_QPsimple_loop() |
| 6 |
subroutine simple_loop |
| 7 |
integer :: i |
| 8 |
! CHECK: omp.parallel |
| 9 |
!$OMP PARALLEL |
| 10 |
! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}} |
| 11 |
! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loopEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 12 |
! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32 |
| 13 |
! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32 |
| 14 |
! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32 |
| 15 |
! CHECK: omp.wsloop { |
| 16 |
! CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) { |
| 17 |
!$OMP DO |
| 18 |
do i=1, 9 |
| 19 |
! CHECK: fir.store %[[I]] to %[[IV_DECL:.*]]#1 : !fir.ref<i32> |
| 20 |
! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32> |
| 21 |
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 22 |
print*, i |
| 23 |
end do |
| 24 |
! CHECK: omp.yield |
| 25 |
! CHECK: omp.terminator |
| 26 |
!$OMP END DO |
| 27 |
! CHECK: omp.terminator |
| 28 |
!$OMP END PARALLEL |
| 29 |
end subroutine |
| 30 |
|
| 31 |
!CHECK-LABEL: func @_QPsimple_loop_with_step() |
| 32 |
subroutine simple_loop_with_step |
| 33 |
integer :: i |
| 34 |
! CHECK: omp.parallel |
| 35 |
!$OMP PARALLEL |
| 36 |
! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}} |
| 37 |
! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loop_with_stepEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 38 |
! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32 |
| 39 |
! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32 |
| 40 |
! CHECK: %[[WS_STEP:.*]] = arith.constant 2 : i32 |
| 41 |
! CHECK: omp.wsloop { |
| 42 |
! CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) { |
| 43 |
! CHECK: fir.store %[[I]] to %[[IV_DECL]]#1 : !fir.ref<i32> |
| 44 |
! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32> |
| 45 |
!$OMP DO |
| 46 |
do i=1, 9, 2 |
| 47 |
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 48 |
print*, i |
| 49 |
end do |
| 50 |
! CHECK: omp.yield |
| 51 |
! CHECK: omp.terminator |
| 52 |
!$OMP END DO |
| 53 |
! CHECK: omp.terminator |
| 54 |
!$OMP END PARALLEL |
| 55 |
end subroutine |
| 56 |
|
| 57 |
!CHECK-LABEL: func @_QPloop_with_schedule_nowait() |
| 58 |
subroutine loop_with_schedule_nowait |
| 59 |
integer :: i |
| 60 |
! CHECK: omp.parallel |
| 61 |
!$OMP PARALLEL |
| 62 |
! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}} |
| 63 |
! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFloop_with_schedule_nowaitEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 64 |
! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32 |
| 65 |
! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32 |
| 66 |
! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32 |
| 67 |
! CHECK: omp.wsloop schedule(runtime) nowait { |
| 68 |
! CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) { |
| 69 |
!$OMP DO SCHEDULE(runtime) |
| 70 |
do i=1, 9 |
| 71 |
! CHECK: fir.store %[[I]] to %[[IV_DECL]]#1 : !fir.ref<i32> |
| 72 |
! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32> |
| 73 |
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1 |
| 74 |
print*, i |
| 75 |
end do |
| 76 |
! CHECK: omp.yield |
| 77 |
! CHECK: omp.terminator |
| 78 |
!$OMP END DO NOWAIT |
| 79 |
! CHECK: omp.terminator |
| 80 |
!$OMP END PARALLEL |
| 81 |
end subroutine |