-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Flang][OpenMP] Lower schedule modifiers for worksharing loop
Add support for lowering the schedule modifiers (simd, monotonic, non-monotonic) in worksharing loops. Note: This is part of upstreaming from the fir-dev branch of https://github.com/flang-compiler/f18-llvm-project. Reviewed By: peixin Differential Revision: https://reviews.llvm.org/D127311 Co-authored-by: Mats Petersson <mats.petersson@arm.com> Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
- Loading branch information
1 parent
5f0d4f2
commit 8b951e6
Showing
4 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
! This test checks lowering of OpenMP DO Directive (Worksharing) with | ||
! monotonic schedule modifier. | ||
|
||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
|
||
program wsloop_dynamic | ||
integer :: i | ||
!CHECK-LABEL: func @_QQmain() | ||
|
||
!$OMP PARALLEL | ||
!CHECK: omp.parallel { | ||
|
||
!$OMP DO SCHEDULE(monotonic:dynamic) | ||
!CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned} | ||
!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(dynamic, monotonic) nowait for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) | ||
!CHECK: fir.store %[[I]] to %[[ALLOCA_IV:.*]] : !fir.ref<i32> | ||
|
||
do i=1, 9 | ||
print*, i | ||
!CHECK: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput | ||
!CHECK: %[[LOAD:.*]] = fir.load %[[ALLOCA_IV]] : !fir.ref<i32> | ||
!CHECK: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[LOAD]]) : (!fir.ref<i8>, i32) -> i1 | ||
!CHECK: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref<i8>) -> i32 | ||
end do | ||
!CHECK: omp.yield | ||
!CHECK: omp.terminator | ||
!CHECK: } | ||
|
||
!$OMP END DO NOWAIT | ||
!$OMP END PARALLEL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
! This test checks lowering of OpenMP DO Directive(Worksharing) with | ||
! non-monotonic schedule modifier. | ||
|
||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
|
||
program wsloop_dynamic | ||
integer :: i | ||
!CHECK-LABEL: func @_QQmain() | ||
|
||
|
||
!$OMP PARALLEL | ||
!CHECK: omp.parallel { | ||
|
||
!$OMP DO SCHEDULE(nonmonotonic:dynamic) | ||
!CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned} | ||
!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(dynamic, nonmonotonic) nowait for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) | ||
!CHECK: fir.store %[[I]] to %[[ALLOCA_IV]] : !fir.ref<i32> | ||
|
||
do i=1, 9 | ||
print*, i | ||
!CHECK: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput | ||
!CHECK: %[[LOAD:.*]] = fir.load %[[ALLOCA_IV]] : !fir.ref<i32> | ||
!CHECK: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[LOAD]]) : (!fir.ref<i8>, i32) -> i1 | ||
!CHECK: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref<i8>) -> i32 | ||
end do | ||
!CHECK: omp.yield | ||
!CHECK: } | ||
!CHECK: omp.terminator | ||
!CHECK: } | ||
|
||
!$OMP END DO NOWAIT | ||
!$OMP END PARALLEL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
! This test checks lowering of OpenMP DO Directive(Worksharing) with | ||
! simd schedule modifier. | ||
|
||
! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s | ||
|
||
program wsloop_dynamic | ||
integer :: i | ||
!CHECK-LABEL: func @_QQmain() | ||
|
||
!$OMP PARALLEL | ||
!CHECK: omp.parallel { | ||
|
||
!$OMP DO SCHEDULE(simd: runtime) | ||
!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, simd) nowait for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) | ||
!CHECK: fir.store %[[I]] to %[[STORE:.*]] : !fir.ref<i32> | ||
|
||
do i=1, 9 | ||
print*, i | ||
!CHECK: %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput | ||
!CHECK: %[[LOAD:.*]] = fir.load %[[STORE]] : !fir.ref<i32> | ||
!CHECK: fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[LOAD]]) : (!fir.ref<i8>, i32) -> i1 | ||
!CHECK: fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) : (!fir.ref<i8>) -> i32 | ||
end do | ||
!CHECK: omp.yield | ||
!CHECK: } | ||
!CHECK: omp.terminator | ||
!CHECK: } | ||
|
||
!$OMP END DO NOWAIT | ||
!$OMP END PARALLEL | ||
end |