[flang-commits] [flang] [Flang][OpenMP] : Add a temporary lowering for workshare directive (PR #78268)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Tue Feb 27 10:56:37 PST 2024
https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/78268
>From fddca995366bdbf53e9c761f17363c9e6bb4915e Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Tue, 16 Jan 2024 12:45:23 +0000
Subject: [PATCH] [Flang][OpenMP] : Add a temporary lowering for workshare
directive
As a temporary solution, lower workshare to the single directive.
---
flang/lib/Lower/OpenMP/OpenMP.cpp | 9 ++++--
flang/test/Lower/OpenMP/workshare.f90 | 42 +++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 2 deletions(-)
create mode 100644 flang/test/Lower/OpenMP/workshare.f90
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 7953bf83cba0fe..d9c3148d0e3d34 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -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;
@@ -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)
diff --git a/flang/test/Lower/OpenMP/workshare.f90 b/flang/test/Lower/OpenMP/workshare.f90
new file mode 100644
index 00000000000000..1e11677a15e1f0
--- /dev/null
+++ b/flang/test/Lower/OpenMP/workshare.f90
@@ -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
More information about the flang-commits
mailing list