[PATCH] D105874: [flang][OpenMP] Add semantic check for reduction clause in taskloop simd construct

Peixin Qiao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 12 23:34:01 PDT 2021


peixin created this revision.
peixin added reviewers: kiranchandramohan, clementval, richard.barton.arm, jdoerfert, praveen, sameeranjoshi, SouraVX, sscalpone, arnamoy10.
peixin added a project: LLVM.
Herald added subscribers: guansong, yaxunl.
peixin requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1.

This patch implements the following semantic check:

  Taskloop simd construct restrictions: No reduction clause can be specified.

Also fix several typos.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105874

Files:
  flang/lib/Semantics/check-omp-structure.cpp
  flang/test/Semantics/omp-clause-validity01.f90
  flang/test/Semantics/omp-taskloop-simd01.f90


Index: flang/test/Semantics/omp-taskloop-simd01.f90
===================================================================
--- flang/test/Semantics/omp-taskloop-simd01.f90
+++ flang/test/Semantics/omp-taskloop-simd01.f90
@@ -1,5 +1,4 @@
 ! RUN: %S/test_errors.sh %s %t %flang -fopenmp
-! XFAIL: *
 
 ! OpenMP Version 4.5
 ! 2.9.3 taskloop simd Construct
Index: flang/test/Semantics/omp-clause-validity01.f90
===================================================================
--- flang/test/Semantics/omp-clause-validity01.f90
+++ flang/test/Semantics/omp-clause-validity01.f90
@@ -7,8 +7,6 @@
 !    2.7.1 Loop construct
 !    ...
 
-! TODO: all the internal errors
-
   integer :: b = 128
   integer :: z, c = 32
   integer, parameter :: num = 16
@@ -87,7 +85,7 @@
   do i = 1, N
      z = 2
   enddo
-   !$omp end target data
+  !$omp end target data
 
   !ERROR: SCHEDULE clause is not allowed on the PARALLEL directive
   !$omp parallel schedule(static)
@@ -177,7 +175,7 @@
       exit outofparallel
     end do inner
   end do outer
-  !$end omp do
+  !$omp end do
   !$omp end parallel
   end do outofparallel
 
@@ -545,6 +543,7 @@
   enddo
   !$omp end taskloop simd
 
+  !ERROR: Unexpected clause specified for !$OMP taskloop simd
   !$omp taskloop simd reduction(+:a)
   do i = 1, N
      a = a + 3.14
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -931,7 +931,7 @@
 // 3. Checks on clauses which are not in 'struct OmpClause' from parse-tree.h.
 
 void OmpStructureChecker::Leave(const parser::OmpClauseList &) {
-  // 2.7 Loop Construct Restriction
+  // 2.7.1 Loop Construct Restriction
   if (llvm::omp::doSet.test(GetContext().directive)) {
     if (auto *clause{FindClause(llvm::omp::Clause::OMPC_schedule)}) {
       // only one schedule clause is allowed
@@ -1028,6 +1028,14 @@
         llvm::omp::Clause::OMPC_copyprivate, {llvm::omp::Clause::OMPC_nowait});
   }
 
+  // 2.9.3 Taskloop Simd Construct Restriction
+  if (GetContext().directive == llvm::omp::Directive::OMPD_taskloop_simd) {
+    if (auto *clause{FindClause(llvm::omp::Clause::OMPC_reduction)}) {
+      context_.Say(clause->source,
+          "Unexpected clause specified for !$OMP taskloop simd"_err_en_US);
+    }
+  }
+
   CheckRequireAtLeastOneOf();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105874.358169.patch
Type: text/x-patch
Size: 2411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210713/7e118f21/attachment.bin>


More information about the llvm-commits mailing list