[flang-commits] [flang] 832c8a7 - [flang][openacc] Fix gang-argument parsing and add validity tests for !$acc loop

via flang-commits flang-commits at lists.llvm.org
Thu Aug 27 19:33:12 PDT 2020


Author: Valentin Clement
Date: 2020-08-27T22:33:05-04:00
New Revision: 832c8a72988a3d5889a1ae16322df39f0215d5a2

URL: https://github.com/llvm/llvm-project/commit/832c8a72988a3d5889a1ae16322df39f0215d5a2
DIFF: https://github.com/llvm/llvm-project/commit/832c8a72988a3d5889a1ae16322df39f0215d5a2.diff

LOG: [flang][openacc] Fix gang-argument parsing and add validity tests for !$acc loop

This patch fix the prasing for the gang-arg values for the gang clause. It also adds
some clause validity tests for the loop construct.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D86584

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/openacc-parsers.cpp b/flang/lib/Parser/openacc-parsers.cpp
index 78ed940aa094..01c258325f2c 100644
--- a/flang/lib/Parser/openacc-parsers.cpp
+++ b/flang/lib/Parser/openacc-parsers.cpp
@@ -145,13 +145,11 @@ TYPE_PARSER(construct<AccTileExpr>(scalarIntConstantExpr) ||
         "*" >> construct<std::optional<ScalarIntConstantExpr>>()))
 TYPE_PARSER(construct<AccTileExprList>(nonemptyList(Parser<AccTileExpr>{})))
 
-// 2.9 (1607) gang-arg is one of:
-//   [num:]int-expr
-//   static:size-expr
-TYPE_PARSER(construct<AccGangArgument>(maybe(scalarIntExpr),
-                maybe(","_tok / "STATIC:" >> Parser<AccSizeExpr>{})) ||
-    construct<AccGangArgument>(maybe("NUM:" >> scalarIntExpr),
-        maybe(","_tok / "STATIC:" >> Parser<AccSizeExpr>{})))
+// 2.9 (1607) gang-arg is:
+//   [[num:]int-expr][[,]static:size-expr]
+TYPE_PARSER(construct<AccGangArgument>(
+    maybe(("NUM:"_tok >> scalarIntExpr || scalarIntExpr)),
+    maybe(", STATIC:" >> Parser<AccSizeExpr>{})))
 
 // 2.5.13 Reduction
 // Operator for reduction

diff  --git a/flang/test/Semantics/acc-clause-validity.f90 b/flang/test/Semantics/acc-clause-validity.f90
index 9e5d2c71e2a8..9683a4e02c74 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -18,7 +18,7 @@ program openacc_clause_validity
 
   implicit none
 
-  integer :: i, j, b
+  integer :: i, j, b, gang_size, vector_size, worker_size
   integer, parameter :: N = 256
   integer, dimension(N) :: c
   logical, dimension(N) :: d, e
@@ -28,7 +28,7 @@ program openacc_clause_validity
 
   !ERROR: At least one clause is required on the DECLARE directive
   !$acc declare
-  real(8) :: a(256)
+  real(8), dimension(N) :: a
 
   !ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive
   !$acc enter data
@@ -110,6 +110,141 @@ program openacc_clause_validity
   end do
   !$acc end parallel
 
+  !$acc parallel
+  !$acc loop seq
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop independent
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop auto
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop vector
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop vector(10)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop vector(vector_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop vector(length: vector_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop worker
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop worker(10)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop worker(worker_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop worker(num: worker_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop gang(gang_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop gang(num: gang_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop gang(gang_size, static:*)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop gang(num: gang_size, static:*)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop gang(num: gang_size, static: gang_size)
+  do i = 1, N
+    a(i) = 3.14
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop private(b, a(:))
+  do i = 1, N
+    a(i) = b
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop tile(*)
+  do i = 1, N
+    a(i) = b
+  end do
+  !$acc end parallel
+
+  !$acc parallel
+  !$acc loop tile(2, 2)
+  do i = 1, N
+    do j = 1, N
+      a(i) = b
+    end do
+  end do
+  !$acc end parallel
+
   !$acc parallel
   !ERROR: The parameter of the COLLAPSE clause must be a constant positive integer expression
   !$acc loop collapse(-1)


        


More information about the flang-commits mailing list