Use existing middle end checking for Fortran OpenACC loop clauses
authorThomas Schwinge <thomas@codesourcery.com>
Sun, 9 Dec 2018 12:47:58 +0000 (13:47 +0100)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Sun, 9 Dec 2018 12:47:58 +0000 (13:47 +0100)
Don't duplicate in the Fortran front end what's generically being checked in
the middle end.

gcc/fortran/
* openmp.c (resolve_oacc_loop_blocks): Remove checking of OpenACC
loop clauses.
gcc/testsuite/
* gfortran.dg/goacc/loop-2-kernels.f95: Update.
* gfortran.dg/goacc/loop-2-parallel.f95: Likewise.
* gfortran.dg/goacc/nested-parallelism.f90: Likewise.

From-SVN: r266922

gcc/fortran/ChangeLog
gcc/fortran/openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/loop-2-kernels.f95
gcc/testsuite/gfortran.dg/goacc/loop-2-parallel.f95
gcc/testsuite/gfortran.dg/goacc/nested-parallelism.f90

index ae1871e..c6eb051 100644 (file)
@@ -1,5 +1,8 @@
 2018-12-09  Thomas Schwinge  <thomas@codesourcery.com>
 
+       * openmp.c (resolve_oacc_loop_blocks): Remove checking of OpenACC
+       loop clauses.
+
        PR fortran/88420
        * openmp.c (resolve_oacc_loop_blocks): Remove "Clause SEQ
        conflicts with INDEPENDENT" diagnostic.
index d97b8bf..261a54a 100644 (file)
@@ -5659,12 +5659,6 @@ oacc_is_parallel (gfc_code *code)
   return code->op == EXEC_OACC_PARALLEL || code->op == EXEC_OACC_PARALLEL_LOOP;
 }
 
-static bool
-oacc_is_kernels (gfc_code *code)
-{
-  return code->op == EXEC_OACC_KERNELS || code->op == EXEC_OACC_KERNELS_LOOP;
-}
-
 static gfc_statement
 omp_code_to_statement (gfc_code *code)
 {
@@ -5846,73 +5840,9 @@ resolve_oacc_params_in_parallel (gfc_code *code, const char *clause,
 static void
 resolve_oacc_loop_blocks (gfc_code *code)
 {
-  fortran_omp_context *c;
-
   if (!oacc_is_loop (code))
     return;
 
-  if (code->op == EXEC_OACC_LOOP)
-    for (c = omp_current_ctx; c; c = c->previous)
-      {
-       if (oacc_is_loop (c->code))
-         {
-           if (code->ext.omp_clauses->gang)
-             {
-               if (c->code->ext.omp_clauses->gang)
-                 gfc_error ("Loop parallelized across gangs is not allowed "
-                            "inside another loop parallelized across gangs at %L",
-                            &code->loc);
-               if (c->code->ext.omp_clauses->worker)
-                 gfc_error ("Loop parallelized across gangs is not allowed "
-                            "inside loop parallelized across workers at %L",
-                            &code->loc);
-               if (c->code->ext.omp_clauses->vector)
-                 gfc_error ("Loop parallelized across gangs is not allowed "
-                            "inside loop parallelized across vectors at %L",
-                            &code->loc);
-             }
-           if (code->ext.omp_clauses->worker)
-             {
-               if (c->code->ext.omp_clauses->worker)
-                 gfc_error ("Loop parallelized across workers is not allowed "
-                            "inside another loop parallelized across workers at %L",
-                            &code->loc);
-               if (c->code->ext.omp_clauses->vector)
-                 gfc_error ("Loop parallelized across workers is not allowed "
-                            "inside another loop parallelized across vectors at %L",
-                            &code->loc);
-             }
-           if (code->ext.omp_clauses->vector)
-             if (c->code->ext.omp_clauses->vector)
-               gfc_error ("Loop parallelized across vectors is not allowed "
-                          "inside another loop parallelized across vectors at %L",
-                          &code->loc);
-         }
-
-       if (oacc_is_parallel (c->code) || oacc_is_kernels (c->code))
-         break;
-      }
-
-  if (code->ext.omp_clauses->seq)
-    {
-      if (code->ext.omp_clauses->gang)
-       gfc_error ("Clause SEQ conflicts with GANG at %L", &code->loc);
-      if (code->ext.omp_clauses->worker)
-       gfc_error ("Clause SEQ conflicts with WORKER at %L", &code->loc);
-      if (code->ext.omp_clauses->vector)
-       gfc_error ("Clause SEQ conflicts with VECTOR at %L", &code->loc);
-      if (code->ext.omp_clauses->par_auto)
-       gfc_error ("Clause SEQ conflicts with AUTO at %L", &code->loc);
-    }
-  if (code->ext.omp_clauses->par_auto)
-    {
-      if (code->ext.omp_clauses->gang)
-       gfc_error ("Clause AUTO conflicts with GANG at %L", &code->loc);
-      if (code->ext.omp_clauses->worker)
-       gfc_error ("Clause AUTO conflicts with WORKER at %L", &code->loc);
-      if (code->ext.omp_clauses->vector)
-       gfc_error ("Clause AUTO conflicts with VECTOR at %L", &code->loc);
-    }
   if (code->ext.omp_clauses->tile_list && code->ext.omp_clauses->gang
       && code->ext.omp_clauses->worker && code->ext.omp_clauses->vector)
     gfc_error ("Tiled loop cannot be parallelized across gangs, workers and "
index 7bee068..192a29e 100644 (file)
@@ -1,5 +1,9 @@
 2018-12-09  Thomas Schwinge  <thomas@codesourcery.com>
 
+       * gfortran.dg/goacc/loop-2-kernels.f95: Update.
+       * gfortran.dg/goacc/loop-2-parallel.f95: Likewise.
+       * gfortran.dg/goacc/nested-parallelism.f90: Likewise.
+
        * gfortran.dg/goacc/loop-2.f95: Split into...
        * gfortran.dg/goacc/loop-2-kernels-nested.f95: ... this new
        file...
index 25a6be1..874c62d 100644 (file)
@@ -31,11 +31,11 @@ program test
       !$acc loop worker 
       DO j = 1,10
       ENDDO
-      !$acc loop gang ! { dg-error "not allowed" }
+      !$acc loop gang ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
       DO j = 1,10
       ENDDO
     ENDDO
-    !$acc loop seq gang ! { dg-error "conflicts with" }
+    !$acc loop seq gang ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
 
@@ -53,14 +53,14 @@ program test
       !$acc loop vector 
       DO j = 1,10
       ENDDO
-      !$acc loop worker ! { dg-error "not allowed" }
+      !$acc loop worker ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
       DO j = 1,10
       ENDDO
-      !$acc loop gang ! { dg-error "not allowed" }
+      !$acc loop gang ! { dg-error "" "TODO" { xfail *-*-* } }
       DO j = 1,10
       ENDDO
     ENDDO
-    !$acc loop seq worker ! { dg-error "conflicts with" }
+    !$acc loop seq worker ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
     !$acc loop gang worker
@@ -78,17 +78,17 @@ program test
     ENDDO
     !$acc loop vector
     DO i = 1,10
-      !$acc loop vector ! { dg-error "not allowed" }
+      !$acc loop vector ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
       DO j = 1,10
       ENDDO
-      !$acc loop worker ! { dg-error "not allowed" }
+      !$acc loop worker ! { dg-error "" "TODO" { xfail *-*-* } }
       DO j = 1,10
       ENDDO
-      !$acc loop gang ! { dg-error "not allowed" }
+      !$acc loop gang ! { dg-error "" "TODO" { xfail *-*-* } }
       DO j = 1,10
       ENDDO
     ENDDO
-    !$acc loop seq vector ! { dg-error "conflicts with" }
+    !$acc loop seq vector ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
     !$acc loop gang vector
@@ -101,16 +101,16 @@ program test
     !$acc loop auto
     DO i = 1,10
     ENDDO
-    !$acc loop seq auto ! { dg-error "conflicts with" }
+    !$acc loop seq auto ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
-    !$acc loop gang auto ! { dg-error "conflicts with" }
+    !$acc loop gang auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
-    !$acc loop worker auto ! { dg-error "conflicts with" }
+    !$acc loop worker auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
-    !$acc loop vector auto ! { dg-error "conflicts with" }
+    !$acc loop vector auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
   !$acc end kernels
@@ -133,7 +133,7 @@ program test
   !$acc kernels loop gang(static:*)
   DO i = 1,10
   ENDDO
-  !$acc kernels loop seq gang ! { dg-error "conflicts with" }
+  !$acc kernels loop seq gang ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
 
@@ -146,7 +146,7 @@ program test
   !$acc kernels loop worker(num:5)
   DO i = 1,10
   ENDDO
-  !$acc kernels loop seq worker ! { dg-error "conflicts with" }
+  !$acc kernels loop seq worker ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
   !$acc kernels loop gang worker
@@ -162,7 +162,7 @@ program test
   !$acc kernels loop vector(length:5)
   DO i = 1,10
   ENDDO
-  !$acc kernels loop seq vector ! { dg-error "conflicts with" }
+  !$acc kernels loop seq vector ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
   !$acc kernels loop gang vector
@@ -175,16 +175,16 @@ program test
   !$acc kernels loop auto
   DO i = 1,10
   ENDDO
-  !$acc kernels loop seq auto ! { dg-error "conflicts with" }
+  !$acc kernels loop seq auto ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
-  !$acc kernels loop gang auto ! { dg-error "conflicts with" }
+  !$acc kernels loop gang auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
-  !$acc kernels loop worker auto ! { dg-error "conflicts with" }
+  !$acc kernels loop worker auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
-  !$acc kernels loop vector auto ! { dg-error "conflicts with" }
+  !$acc kernels loop vector auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
 end
index 6338f10..db8187e 100644 (file)
@@ -25,11 +25,11 @@ program test
       !$acc loop worker 
       DO j = 1,10
       ENDDO
-      !$acc loop gang ! { dg-error "not allowed" }
+      !$acc loop gang ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
       DO j = 1,10
       ENDDO
     ENDDO
-    !$acc loop seq gang ! { dg-error "conflicts with" }
+    !$acc loop seq gang ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
 
@@ -41,14 +41,14 @@ program test
       !$acc loop vector 
       DO j = 1,10
       ENDDO
-      !$acc loop worker ! { dg-error "not allowed" }
+      !$acc loop worker ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
       DO j = 1,10
       ENDDO
-      !$acc loop gang ! { dg-error "not allowed" }
+      !$acc loop gang ! { dg-error "incorrectly nested OpenACC loop parallelism" }
       DO j = 1,10
       ENDDO
     ENDDO
-    !$acc loop seq worker ! { dg-error "conflicts with" }
+    !$acc loop seq worker ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
     !$acc loop gang worker
@@ -60,17 +60,17 @@ program test
     ENDDO
     !$acc loop vector
     DO i = 1,10
-      !$acc loop vector ! { dg-error "not allowed" }
+      !$acc loop vector ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
       DO j = 1,10
       ENDDO
-      !$acc loop worker ! { dg-error "not allowed" }
+      !$acc loop worker ! { dg-error "incorrectly nested OpenACC loop parallelism" }
       DO j = 1,10
       ENDDO
-      !$acc loop gang ! { dg-error "not allowed" }
+      !$acc loop gang ! { dg-error "incorrectly nested OpenACC loop parallelism" }
       DO j = 1,10
       ENDDO
     ENDDO
-    !$acc loop seq vector ! { dg-error "conflicts with" }
+    !$acc loop seq vector ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
     !$acc loop gang vector
@@ -83,16 +83,16 @@ program test
     !$acc loop auto
     DO i = 1,10
     ENDDO
-    !$acc loop seq auto ! { dg-error "conflicts with" }
+    !$acc loop seq auto ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
-    !$acc loop gang auto ! { dg-error "conflicts with" }
+    !$acc loop gang auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
-    !$acc loop worker auto ! { dg-error "conflicts with" }
+    !$acc loop worker auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
-    !$acc loop vector auto ! { dg-error "conflicts with" }
+    !$acc loop vector auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
     DO i = 1,10
     ENDDO
   !$acc end parallel
@@ -109,14 +109,14 @@ program test
   !$acc parallel loop gang(static:*)
   DO i = 1,10
   ENDDO
-  !$acc parallel loop seq gang ! { dg-error "conflicts with" }
+  !$acc parallel loop seq gang ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
 
   !$acc parallel loop worker
   DO i = 1,10
   ENDDO
-  !$acc parallel loop seq worker ! { dg-error "conflicts with" }
+  !$acc parallel loop seq worker ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
   !$acc parallel loop gang worker
@@ -126,7 +126,7 @@ program test
   !$acc parallel loop vector
   DO i = 1,10
   ENDDO
-  !$acc parallel loop seq vector ! { dg-error "conflicts with" }
+  !$acc parallel loop seq vector ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
   !$acc parallel loop gang vector
@@ -139,16 +139,16 @@ program test
   !$acc parallel loop auto
   DO i = 1,10
   ENDDO
-  !$acc parallel loop seq auto ! { dg-error "conflicts with" }
+  !$acc parallel loop seq auto ! { dg-error "'seq' overrides other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
-  !$acc parallel loop gang auto ! { dg-error "conflicts with" }
+  !$acc parallel loop gang auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
-  !$acc parallel loop worker auto ! { dg-error "conflicts with" }
+  !$acc parallel loop worker auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
-  !$acc parallel loop vector auto ! { dg-error "conflicts with" }
+  !$acc parallel loop vector auto ! { dg-error "'auto' conflicts with other OpenACC loop specifiers" }
   DO i = 1,10
   ENDDO
 end
index 6ebef6a..1c19289 100644 (file)
@@ -6,7 +6,7 @@ program np
 
   !$acc parallel loop gang
   do i = 1, n
-     !$acc loop gang ! { dg-error "gangs is not allowed inside another loop parallelized across gangs" }
+     !$acc loop gang ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
      do j = 1, n
      end do
 
@@ -21,11 +21,11 @@ program np
   
   !$acc parallel loop worker
   do i = 1, n
-     !$acc loop gang ! { dg-error "gangs is not allowed inside loop parallelized across workers" }
+     !$acc loop gang ! { dg-error "incorrectly nested OpenACC loop parallelism" }
      do j = 1, n
      end do
 
-     !$acc loop worker ! { dg-error "workers is not allowed inside another loop parallelized across workers" }
+     !$acc loop worker ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
      do j = 1, n
      end do
 
@@ -36,15 +36,15 @@ program np
 
   !$acc parallel loop vector
   do i = 1, n
-     !$acc loop gang ! { dg-error "gangs is not allowed inside loop parallelized across vectors" }
+     !$acc loop gang ! { dg-error "incorrectly nested OpenACC loop parallelism" }
      do j = 1, n
      end do
 
-     !$acc loop worker ! { dg-error "workers is not allowed inside another loop parallelized across vectors" }
+     !$acc loop worker ! { dg-error "incorrectly nested OpenACC loop parallelism" }
      do j = 1, n
      end do
 
-     !$acc loop vector ! { dg-error "vectors is not allowed inside another loop parallelized across vectors" }
+     !$acc loop vector ! { dg-error "inner loop uses same OpenACC parallelism as containing loop" }
      do j = 1, n
      end do     
   end do