[flang-commits] [PATCH] D94087: [flang][openmp]At most one threads, simd and depend clause can appear on OpenMP ORDERED construct.

sameeran joshi via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Jan 5 07:29:48 PST 2021


sameeranjoshi created this revision.
sameeranjoshi added reviewers: kiranchandramohan, clementval, kiranktp.
Herald added subscribers: guansong, yaxunl.
sameeranjoshi requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: LLVM.

Section 2.17.9 from omp 5.0 has a few restrictions related to ORDERED construct.

- At most one threads clause can appear on an ordered construct.
- At most one simd clause can appear on an ordered construct.
- At most one depend(source) clause can appear on an ordered construct.

This patch implements them by changing the TableGen file(OMP.td).
The dependencies Simd and Threads clauses were missing semantic checks and were added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94087

Files:
  flang/lib/Semantics/check-omp-structure.cpp
  flang/lib/Semantics/check-omp-structure.h
  flang/test/Semantics/omp-clause-validity01.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td


Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -455,7 +455,7 @@
   ];
 }
 def OMP_Ordered : Directive<"ordered"> {
-  let allowedClauses = [
+  let allowedOnceClauses = [
     VersionedClause<OMPC_Threads>,
     VersionedClause<OMPC_Simd>,
     VersionedClause<OMPC_Depend>
Index: flang/test/Semantics/omp-clause-validity01.f90
===================================================================
--- flang/test/Semantics/omp-clause-validity01.f90
+++ flang/test/Semantics/omp-clause-validity01.f90
@@ -485,6 +485,14 @@
   !$omp ordered depend(source)
   !ERROR: Internal: no symbol found for 'i'
   !$omp ordered depend(sink:i-1)
+  !ERROR: At most one DEPEND clause can appear on the ORDERED directive
+  !$omp ordered depend(source) depend(source)
+  !ERROR: At most one THREADS clause can appear on the ORDERED directive
+  !$omp ordered threads threads
+  !$omp end ordered
+  !ERROR: At most one SIMD clause can appear on the ORDERED directive
+  !$omp ordered simd simd
+  !$omp end ordered
   !$omp flush (c)
   !$omp flush acq_rel
   !$omp flush release
Index: flang/lib/Semantics/check-omp-structure.h
===================================================================
--- flang/lib/Semantics/check-omp-structure.h
+++ flang/lib/Semantics/check-omp-structure.h
@@ -155,8 +155,10 @@
   void Enter(const parser::OmpClause::Reduction &);
   void Enter(const parser::OmpClause::Safelen &);
   void Enter(const parser::OmpClause::Shared &);
+  void Enter(const parser::OmpClause::Simd &);
   void Enter(const parser::OmpClause::Simdlen &);
   void Enter(const parser::OmpClause::TaskReduction &);
+  void Enter(const parser::OmpClause::Threads &);
   void Enter(const parser::OmpClause::ThreadLimit &);
   void Enter(const parser::OmpClause::To &);
   void Enter(const parser::OmpClause::Link &);
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -433,6 +433,8 @@
 CHECK_SIMPLE_CLAUSE(Hint, OMPC_hint)
 CHECK_SIMPLE_CLAUSE(ProcBind, OMPC_proc_bind)
 CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule)
+CHECK_SIMPLE_CLAUSE(Simd, OMPC_simd)
+CHECK_SIMPLE_CLAUSE(Threads, OMPC_threads)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94087.314606.patch
Type: text/x-patch
Size: 2535 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210105/78298064/attachment.bin>


More information about the flang-commits mailing list