[flang-commits] [flang] [llvm] [LLVM][OpenMP] Add "nowait" clause as valid for "workshare" (PR #88426)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Fri Apr 12 06:30:38 PDT 2024


https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/88426

>From ffcb82c3d19418dff0d518c70f080a8b660ca980 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 11 Apr 2024 14:05:30 -0500
Subject: [PATCH 1/2] [LLVM][OpenMP] "nowait" clause is valid for "workshare"

Add the "if" clause to the list of allowed clauses for the "workshare"
directive.
---
 llvm/include/llvm/Frontend/OpenMP/OMP.td | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index d9a931438b4292..e91169e8da1aa5 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -2115,6 +2115,9 @@ def OMP_scope : Directive<"scope"> {
   let association = AS_Block;
 }
 def OMP_Workshare : Directive<"workshare"> {
+  let allowedOnceClauses = [
+    VersionedClause<OMPC_NoWait>
+  ];
   let association = AS_Block;
 }
 def OMP_ParallelWorkshare : Directive<"parallel workshare"> {

>From 7bea1f342518d6dbe234ce4eabf6d27f3b8d6891 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Fri, 12 Apr 2024 08:26:33 -0500
Subject: [PATCH 2/2] Disallow "nowait" on "!$omp workshare" in parser

---
 flang/lib/Semantics/check-omp-structure.h         | 1 +
 flang/test/Semantics/OpenMP/clause-validity01.f90 | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h
index 33243d926cf167..8287653458e1cf 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -42,6 +42,7 @@ static const OmpDirectiveSet noWaitClauseNotAllowedSet{
     Directive::OMPD_do_simd,
     Directive::OMPD_sections,
     Directive::OMPD_single,
+    Directive::OMPD_workshare,
 };
 } // namespace omp
 } // namespace llvm
diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90
index 977a529864615f..74f154bb0ad67d 100644
--- a/flang/test/Semantics/OpenMP/clause-validity01.f90
+++ b/flang/test/Semantics/OpenMP/clause-validity01.f90
@@ -342,6 +342,9 @@
   a = 1.0
   !ERROR: COPYPRIVATE clause is not allowed on the END WORKSHARE directive
   !$omp end workshare nowait copyprivate(a)
+  !$omp workshare nowait
+  !ERROR: NOWAIT clause is not allowed on the WORKSHARE directive, use it on OMP END WORKSHARE directive
+  !$omp end workshare
   !$omp end parallel
 
 ! 2.8.1 simd-clause -> safelen-clause |



More information about the flang-commits mailing list