diff mbox series

Use existing middle end checking for Fortran OpenACC loop clauses

Message ID 87a7lesvp0.fsf@euler.schwinge.homeip.net
State New
Headers show
Series Use existing middle end checking for Fortran OpenACC loop clauses | expand

Commit Message

Thomas Schwinge Dec. 9, 2018, 12:58 p.m. UTC
Hi!

Committed to trunk in r266922:

commit fd1f371dd476ba3e76fb62eb76f1c1e23bd77b33
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sun Dec 9 12:47:58 2018 +0000

    Use existing middle end checking for Fortran OpenACC loop clauses
    
    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.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266922 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/fortran/ChangeLog                              |  3 +
 gcc/fortran/openmp.c                               | 70 ----------------------
 gcc/testsuite/ChangeLog                            |  4 ++
 gcc/testsuite/gfortran.dg/goacc/loop-2-kernels.f95 | 40 ++++++-------
 .../gfortran.dg/goacc/loop-2-parallel.f95          | 40 ++++++-------
 .../gfortran.dg/goacc/nested-parallelism.f90       | 12 ++--
 6 files changed, 53 insertions(+), 116 deletions(-)



Grüße
 Thomas

Comments

Thomas Schwinge Nov. 6, 2020, 1:16 p.m. UTC | #1
Hi!

On 2018-12-09T13:58:51+0100, I wrote:
> Committed to trunk in r266922:

>     Use existing middle end checking for Fortran OpenACC loop clauses
>
>     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.

Similar to that, I've noticed inconsistent diagnostics in C/C++ vs.
Fortran for OpenACC 'loop' clauses with arguments only allowed inside
OpenACC 'kernels' regions, so I pushed "[Fortran] Remove OpenACC 'loop'
inside 'parallel' special-case code" to master branch in commit
4c27f900950ed0ecb2897a8931c5cc348b1980be, and backported to
releases/gcc-10 in commit f41ca73aa11f28ad7d847ac5bf7e07f8bc763721, see
attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
diff mbox series

Patch

diff --git gcc/fortran/ChangeLog gcc/fortran/ChangeLog
index ae1871ec7f8d..c6eb05174f69 100644
--- gcc/fortran/ChangeLog
+++ gcc/fortran/ChangeLog
@@ -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.
diff --git gcc/fortran/openmp.c gcc/fortran/openmp.c
index d97b8bfbb142..261a54a6015e 100644
--- gcc/fortran/openmp.c
+++ gcc/fortran/openmp.c
@@ -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 "
diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index 7bee068aabf3..192a29ee971c 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -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...
diff --git gcc/testsuite/gfortran.dg/goacc/loop-2-kernels.f95 gcc/testsuite/gfortran.dg/goacc/loop-2-kernels.f95
index 25a6be162fdd..874c62d42786 100644
--- gcc/testsuite/gfortran.dg/goacc/loop-2-kernels.f95
+++ gcc/testsuite/gfortran.dg/goacc/loop-2-kernels.f95
@@ -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
diff --git gcc/testsuite/gfortran.dg/goacc/loop-2-parallel.f95 gcc/testsuite/gfortran.dg/goacc/loop-2-parallel.f95
index 6338f10fc617..db8187e5903c 100644
--- gcc/testsuite/gfortran.dg/goacc/loop-2-parallel.f95
+++ gcc/testsuite/gfortran.dg/goacc/loop-2-parallel.f95
@@ -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
diff --git gcc/testsuite/gfortran.dg/goacc/nested-parallelism.f90 gcc/testsuite/gfortran.dg/goacc/nested-parallelism.f90
index 6ebef6a4547a..1c192892c160 100644
--- gcc/testsuite/gfortran.dg/goacc/nested-parallelism.f90
+++ gcc/testsuite/gfortran.dg/goacc/nested-parallelism.f90
@@ -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