The OpenMP worksharing loop operation in the dialect is a proper loop operation and not a container of a loop. So we have to lower the parse-tree OpenMP loop construct and the do-loop inside the construct to a omp.wsloop operation and there should not be a fir.do_loop inside it. This is achieved by skipping fir.do_loop creation and calling genFIR for the nested evaluations in the lowering of the do construct. Note: Handling of more clauses, parallel do, storage of loop index variable etc will come in separate patches. Part of the upstreaming effort to move LLVM Flang from fir-dev branch of https://github.com/flang-compiler/f18-llvm-project to the LLVM Project. Reviewed By: peixin Differential Revision: https://reviews.llvm.org/D125024 Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com> Co-authored-by: Shraiysh Vaishay <Shraiysh.Vaishay@amd.com>
64 lines
2.1 KiB
Fortran
64 lines
2.1 KiB
Fortran
! This test checks lowering of OpenMP DO Directive (Worksharing).
|
|
|
|
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
|
|
|
|
!CHECK-LABEL: func @_QPsimple_loop()
|
|
subroutine simple_loop
|
|
integer :: i
|
|
! CHECK: omp.parallel
|
|
!$OMP PARALLEL
|
|
! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
|
|
! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
|
|
! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
|
|
! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
|
|
!$OMP DO
|
|
do i=1, 9
|
|
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[I]]) : (!fir.ref<i8>, i32) -> i1
|
|
print*, i
|
|
end do
|
|
! CHECK: omp.yield
|
|
!$OMP END DO
|
|
! CHECK: omp.terminator
|
|
!$OMP END PARALLEL
|
|
end subroutine
|
|
|
|
!CHECK-LABEL: func @_QPsimple_loop_with_step()
|
|
subroutine simple_loop_with_step
|
|
integer :: i
|
|
! CHECK: omp.parallel
|
|
!$OMP PARALLEL
|
|
! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
|
|
! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
|
|
! CHECK: %[[WS_STEP:.*]] = arith.constant 2 : i32
|
|
! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
|
|
!$OMP DO
|
|
do i=1, 9, 2
|
|
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[I]]) : (!fir.ref<i8>, i32) -> i1
|
|
print*, i
|
|
end do
|
|
! CHECK: omp.yield
|
|
!$OMP END DO
|
|
! CHECK: omp.terminator
|
|
!$OMP END PARALLEL
|
|
end subroutine
|
|
|
|
!CHECK-LABEL: func @_QPloop_with_schedule_nowait()
|
|
subroutine loop_with_schedule_nowait
|
|
integer :: i
|
|
! CHECK: omp.parallel
|
|
!$OMP PARALLEL
|
|
! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
|
|
! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
|
|
! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
|
|
! CHECK: omp.wsloop schedule(runtime) nowait for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
|
|
!$OMP DO SCHEDULE(runtime)
|
|
do i=1, 9
|
|
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[I]]) : (!fir.ref<i8>, i32) -> i1
|
|
print*, i
|
|
end do
|
|
! CHECK: omp.yield
|
|
!$OMP END DO NOWAIT
|
|
! CHECK: omp.terminator
|
|
!$OMP END PARALLEL
|
|
end subroutine
|