[PATCH] D98733: [fix][Flang][OpenMP] Allow ordered construct within a non-worksharing loop

Arnamoy B via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 16 12:05:50 PDT 2021


arnamoy10 created this revision.
arnamoy10 added reviewers: kiranchandramohan, clementval, tskeith, sameeranjoshi, SouraVX, bryanpkc.
arnamoy10 added a project: Flang.
Herald added subscribers: jdoerfert, guansong, yaxunl.
Herald added a reviewer: sscalpone.
arnamoy10 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

This patch fixes a bug to allow ordered construct within a non-worksharing loop

Also adds a test case for the fix


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98733

Files:
  flang/lib/Semantics/check-omp-structure.cpp
  flang/test/Semantics/omp-ordered-simd.f90


Index: flang/test/Semantics/omp-ordered-simd.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/omp-ordered-simd.f90
@@ -0,0 +1,20 @@
+! RUN: %S/test_errors.sh %s %t %flang -fopenmp
+! OpenMP Version 4.5
+! orderd SIMD should be allowed within a non-worksharing SIMD loop.
+
+SUBROUTINE WORK(I)
+  INTEGER I
+END SUBROUTINE WORK
+
+SUBROUTINE ORDERED_GOOD(N)
+  INTEGER N
+  !$OMP SIMD
+  DO I = 1,N
+    IF (I <= 10) THEN
+      !$OMP ORDERED SIMD
+      CALL WORK(I)
+      !$OMP END ORDERED
+    ENDIF
+  END DO
+  !$OMP END SIMD 
+END SUBROUTINE ORDERED_GOOD
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -343,7 +343,8 @@
 void OmpStructureChecker::CheckIfDoOrderedClause(
     const parser::OmpBlockDirective &blkDirective) {
   if (blkDirective.v == llvm::omp::OMPD_ordered) {
-    if (!FindClauseParent(llvm::omp::Clause::OMPC_ordered)) {
+    if (llvm::omp::doSet.test(GetContextParent().directive) &&
+        !FindClauseParent(llvm::omp::Clause::OMPC_ordered)) {
       context_.Say(blkDirective.source,
           "The ORDERED clause must be present on the loop"
           " construct if any ORDERED region ever binds"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98733.331059.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210316/2c69ce02/attachment.bin>


More information about the llvm-commits mailing list