[flang-commits] [flang] [llvm] [clang] [libcxx] [mlir] [Flang][OpenMP] : Add a temporary lowering for workshare directive (PR #78268)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Tue Jan 16 04:49:42 PST 2024
https://github.com/kiranchandramohan updated https://github.com/llvm/llvm-project/pull/78268
>From 71c3449d872247e3af05de545e907407ac7ac9f9 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.cpp | 6 +++++-
flang/test/Lower/OpenMP/workshare.f90 | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Lower/OpenMP/workshare.f90
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 4f7c99a6d2b840..24531c9f70685f 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -3312,7 +3312,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, eval, currentLocation, beginClauseList,
+ endClauseList);
break;
default: {
// Codegen for combined directives
diff --git a/flang/test/Lower/OpenMP/workshare.f90 b/flang/test/Lower/OpenMP/workshare.f90
new file mode 100644
index 00000000000000..7f63c99ab05965
--- /dev/null
+++ b/flang/test/Lower/OpenMP/workshare.f90
@@ -0,0 +1,16 @@
+
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-LABEL: func @_QPsb
+subroutine sb(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
More information about the flang-commits
mailing list