Skip to content

[Flang][OpenMP] : Add a temporary lowering for workshare directive #78268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,11 @@ genOMP(Fortran::lower::AbstractConverter &converter,
/*outerCombined=*/false);
break;
case llvm::omp::Directive::OMPD_workshare:
TODO(currentLocation, "Workshare construct");
// FIXME: Workshare is not a commonly used OpenMP construct, an
// implementation for this feature will come later. For the codes
// that use this construct, add a single construct for now.
genSingleOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
beginClauseList, endClauseList);
break;
default:
singleDirective = false;
Expand Down Expand Up @@ -1775,7 +1779,8 @@ genOMP(Fortran::lower::AbstractConverter &converter,
}
if ((llvm::omp::workShareSet & llvm::omp::blockConstructSet)
.test(directive.v)) {
TODO(currentLocation, "Workshare construct");
genSingleOp(converter, semaCtx, eval, /*genNested=*/false, currentLocation,
beginClauseList, endClauseList);
combinedDirective = true;
}
if (!combinedDirective)
Expand Down
42 changes: 42 additions & 0 deletions flang/test/Lower/OpenMP/workshare.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s

!CHECK-LABEL: func @_QPsb1
subroutine sb1(arr)
integer :: arr(:)
!CHECK: omp.parallel {
!$omp parallel
!CHECK: omp.single {
!$omp workshare
arr = 0
!$omp end workshare
!CHECK: }
!$omp end parallel
!CHECK: }
end subroutine

!CHECK-LABEL: func @_QPsb2
subroutine sb2(arr)
integer :: arr(:)
!CHECK: omp.parallel {
!$omp parallel
!CHECK: omp.single nowait {
!$omp workshare
arr = 0
!$omp end workshare nowait
!CHECK: }
!$omp end parallel
!CHECK: }
end subroutine

!CHECK-LABEL: func @_QPsb3
subroutine sb3(arr)
integer :: arr(:)
!CHECK: omp.parallel {
!CHECK: omp.single {
!$omp parallel workshare
arr = 0
!$omp end parallel workshare
!CHECK: }
!CHECK: }
end subroutine