[llvm-branch-commits] [flang] 36bf2de - [flang][openacc] Update serial construct clauses for OpenACC 3.1

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 17 07:55:40 PST 2020


Author: Valentin Clement
Date: 2020-12-17T10:50:47-05:00
New Revision: 36bf2de8d866e2b448d17f4d2cb4bb96819d82b7

URL: https://github.com/llvm/llvm-project/commit/36bf2de8d866e2b448d17f4d2cb4bb96819d82b7
DIFF: https://github.com/llvm/llvm-project/commit/36bf2de8d866e2b448d17f4d2cb4bb96819d82b7.diff

LOG: [flang][openacc] Update serial construct clauses for OpenACC 3.1

Update the allowed clauses for the SERIAL construct for the new OpenACC 3.1
specification.

Reviewed By: sameeranjoshi

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

Added: 
    

Modified: 
    flang/test/Semantics/acc-clause-validity.f90
    llvm/include/llvm/Frontend/OpenACC/ACC.td

Removed: 
    


################################################################################
diff  --git a/flang/test/Semantics/acc-clause-validity.f90 b/flang/test/Semantics/acc-clause-validity.f90
index 1f98d0f2559f..a5c6193d32f5 100644
--- a/flang/test/Semantics/acc-clause-validity.f90
+++ b/flang/test/Semantics/acc-clause-validity.f90
@@ -3,8 +3,8 @@
 ! Check OpenACC clause validity for the following construct and directive:
 !   2.6.5 Data
 !   2.5.1 Parallel
-!   2.5.2 Kernels
-!   2.5.3 Serial
+!   2.5.2 Serial
+!   2.5.3 Kernels
 !   2.9 Loop
 !   2.12 Atomic
 !   2.13 Declare
@@ -780,6 +780,170 @@ program openacc_clause_validity
   end do
   !$acc end parallel loop
 
+  !$acc serial
+  !$acc end serial
+
+  !$acc serial async
+  !$acc end serial
+
+  !$acc serial async(1)
+  !$acc end serial
+
+  !ERROR: At most one ASYNC clause can appear on the SERIAL directive
+  !$acc serial async(1) async(2)
+  !$acc end serial
+
+  !$acc serial async(async1)
+  !$acc end serial
+
+  !$acc serial wait
+  !$acc end serial
+
+  !$acc serial wait(1)
+  !$acc end serial
+
+  !$acc serial wait(wait1)
+  !$acc end serial
+
+  !$acc serial wait(1,2)
+  !$acc end serial
+
+  !$acc serial wait(wait1, wait2)
+  !$acc end serial
+
+  !$acc serial wait(wait1) wait(wait2)
+  !$acc end serial
+
+  !ERROR: NUM_GANGS clause is not allowed on the SERIAL directive
+  !$acc serial num_gangs(8)
+  !$acc end serial
+
+  !ERROR: NUM_WORKERS clause is not allowed on the SERIAL directive
+  !$acc serial num_workers(8)
+  !$acc end serial
+
+  !ERROR: VECTOR_LENGTH clause is not allowed on the SERIAL directive
+  !$acc serial vector_length(128)
+  !$acc end serial
+
+  !$acc serial if(.true.)
+  !$acc end serial
+
+  !ERROR: At most one IF clause can appear on the SERIAL directive
+  !$acc serial if(.true.) if(ifCondition)
+  !$acc end serial
+
+  !$acc serial if(ifCondition)
+  !$acc end serial
+
+  !$acc serial self
+  !$acc end serial
+
+  !$acc serial self(.true.)
+  !$acc end serial
+
+  !$acc serial self(ifCondition)
+  !$acc end serial
+
+  !$acc serial loop reduction(+: reduction_r)
+  do i = 1, N
+    reduction_r = a(i) + i
+  end do
+
+  !$acc serial loop reduction(*: reduction_r)
+  do i = 1, N
+    reduction_r = reduction_r * (a(i) + i)
+  end do
+
+  !$acc serial loop reduction(min: reduction_r)
+  do i = 1, N
+    reduction_r = min(reduction_r, a(i) * i)
+  end do
+
+  !$acc serial loop reduction(max: reduction_r)
+  do i = 1, N
+    reduction_r = max(reduction_r, a(i) * i)
+  end do
+
+  !$acc serial loop reduction(iand: b)
+  do i = 1, N
+    b = iand(b, c(i))
+  end do
+
+  !$acc serial loop reduction(ior: b)
+  do i = 1, N
+    b = ior(b, c(i))
+  end do
+
+  !$acc serial loop reduction(ieor: b)
+  do i = 1, N
+    b = ieor(b, c(i))
+  end do
+
+  !$acc serial loop reduction(.and.: reduction_l)
+  do i = 1, N
+    reduction_l = d(i) .and. e(i)
+  end do
+
+  !$acc serial loop reduction(.or.: reduction_l)
+  do i = 1, N
+    reduction_l = d(i) .or. e(i)
+  end do
+
+  !$acc serial loop reduction(.eqv.: reduction_l)
+  do i = 1, N
+    reduction_l = d(i) .eqv. e(i)
+  end do
+
+  !$acc serial loop reduction(.neqv.: reduction_l)
+  do i = 1, N
+    reduction_l = d(i) .neqv. e(i)
+  end do
+
+  !$acc serial reduction(.neqv.: reduction_l)
+  !$acc loop reduction(.neqv.: reduction_l)
+  do i = 1, N
+    reduction_l = d(i) .neqv. e(i)
+  end do
+  !$acc end serial
+
+  !$acc serial copy(aa) copyin(bb) copyout(cc)
+  !$acc end serial
+
+  !$acc serial copy(aa, bb) copyout(zero: cc)
+  !$acc end serial
+
+  !$acc serial present(aa, bb) create(cc)
+  !$acc end serial
+
+  !$acc serial copyin(readonly: aa, bb) create(zero: cc)
+  !$acc end serial
+
+  !$acc serial deviceptr(aa, bb) no_create(cc)
+  !$acc end serial
+
+  !$acc serial attach(aa, bb, cc)
+  !$acc end serial
+
+  !$acc serial firstprivate(bb, cc)
+  !$acc end serial
+
+  !$acc serial private(aa)
+  !$acc end serial
+
+  !$acc serial default(none)
+  !$acc end serial
+
+  !$acc serial default(present)
+  !$acc end serial
+
+  !ERROR: At most one DEFAULT clause can appear on the SERIAL directive
+  !$acc serial default(present) default(none)
+  !$acc end serial
+
+  !$acc serial device_type(*) async wait
+  !$acc end serial
+
   !$acc serial device_type(*) async
   do i = 1, N
     a(i) = 3.14

diff  --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td
index 10c21c851853..a1ba90d13f4f 100644
--- a/llvm/include/llvm/Frontend/OpenACC/ACC.td
+++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td
@@ -341,6 +341,8 @@ def ACC_Parallel : Directive<"parallel"> {
 
 // 2.5.2
 def ACC_Serial : Directive<"serial"> {
+  // Spec line 950-951: clause is as for the parallel construct except that the
+  // num_gangs, num_workers, and vector_length clauses are not permitted.
   let allowedClauses = [
     VersionedClause<ACCC_Attach>,
     VersionedClause<ACCC_Copy>,
@@ -349,10 +351,10 @@ def ACC_Serial : Directive<"serial"> {
     VersionedClause<ACCC_Create>,
     VersionedClause<ACCC_DevicePtr>,
     VersionedClause<ACCC_DeviceType>,
-    VersionedClause<ACCC_FirstPrivate>,
     VersionedClause<ACCC_NoCreate>,
     VersionedClause<ACCC_Present>,
     VersionedClause<ACCC_Private>,
+    VersionedClause<ACCC_FirstPrivate>,
     VersionedClause<ACCC_Wait>
   ];
   let allowedOnceClauses = [


        


More information about the llvm-branch-commits mailing list