[PATCH] D90185: [flang][openacc] Fix ambiguity in the self clause parsing

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 12:40:42 PDT 2020


clementval created this revision.
clementval added reviewers: kiranchandramohan, kiranktp, SouraVX, jdoerfert, tskeith, klausler.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
clementval requested review of this revision.

In the OpenACC specification, there are two different self clause. One for the
update directive with a var-list argument. This clause is a synonym of the host clause.
The second self clause is present for most of the compute construct and takes an optional
condition. To solve this ambiguity, the self clause for the update directive is directly
translated to a host clause during the parsing. The self clause in AccClause refers always
to the compute construct clause.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90185

Files:
  flang/lib/Parser/openacc-parsers.cpp
  flang/test/Semantics/acc-clause-validity.f90


Index: flang/test/Semantics/acc-clause-validity.f90
===================================================================
--- flang/test/Semantics/acc-clause-validity.f90
+++ flang/test/Semantics/acc-clause-validity.f90
@@ -31,7 +31,7 @@
 
   !ERROR: At least one clause is required on the DECLARE directive
   !$acc declare
-  real(8), dimension(N) :: a
+  real(8), dimension(N) :: a, f, g, h
 
   !$acc init
   !$acc init if(.TRUE.)
@@ -83,6 +83,8 @@
   !ERROR: Unmatched PARALLEL directive
   !$acc end parallel
 
+  !$acc update self(a, f) host(g) device(h)
+
   !$acc update device(i) device_type(*) async
 
   !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the UPDATE directive
@@ -108,6 +110,21 @@
     a(i) = 3.14
   end do
 
+  !$acc parallel loop self
+  do i = 1, N
+    a(i) = 3.14
+  end do
+
+  !$acc parallel loop self(.true.)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+
+  !$acc parallel loop self(ifCondition)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+
   !$acc parallel loop tile(2, 2)
   do i = 1, N
     do j = 1, N
Index: flang/lib/Parser/openacc-parsers.cpp
===================================================================
--- flang/lib/Parser/openacc-parsers.cpp
+++ flang/lib/Parser/openacc-parsers.cpp
@@ -98,8 +98,13 @@
                        parenthesized(construct<AccObjectListWithReduction>(
                            Parser<AccReductionOperator>{} / ":",
                            Parser<AccObjectList>{})))) ||
+    // SELF clause is either a simple optional condition for compute construct
+    // or a synonym of the HOST clause for the update directive 2.14.4 holding
+    // an object list.
     "SELF" >> construct<AccClause>(construct<AccClause::Self>(
                   maybe(parenthesized(scalarLogicalExpr)))) ||
+    construct<AccClause>(
+        construct<AccClause::Host>(parenthesized(Parser<AccObjectList>{}))) ||
     "SEQ" >> construct<AccClause>(construct<AccClause::Seq>()) ||
     "TILE" >> construct<AccClause>(construct<AccClause::Tile>(
                   parenthesized(Parser<AccTileExprList>{}))) ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90185.300763.patch
Type: text/x-patch
Size: 2079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201026/e9c75d4c/attachment.bin>


More information about the llvm-commits mailing list