[openacc] Add warning for unused acc routine parallelism

Message ID e6aa5413-c551-e52c-d945-c36c07733e1c@codesourcery.com
State New
Headers show
Series
  • [openacc] Add warning for unused acc routine parallelism
Related show

Commit Message

Cesar Philippidis Oct. 2, 2018, 3:12 p.m.
This patch teaches omp-general to be a little more verbose when it comes
time to reporting the missing usage of gang, worker, and vector clauses
on acc routines. As before, the Fortran FE does this directly so that it
can handle modules. Therefore, this primarily handle the C and C++ cases
(although certain Fortran routines fall though to this).

Is this OK for trunk? I bootstrapped and regtested it for x86_64 Linux
with nvptx offloading. This patch only touches the OpenACC code path.

Thanks,
Cesar

Patch

[OpenACC] Add warning for unused acc routine parallelism

(was [OpenACC] Don't error on implicitly private induction variables in gfortran)

2018-XX-YY  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* omp-general.c (oacc_verify_routine_clauses): New warning.

	gcc/testsuite/
	* c-c++-common/goacc-gomp/nesting-fail-1.c: Update test.
	* c-c++-common/goacc/Wparentheses-1.c: Likewise.
	* c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c: Likewise.
	* c-c++-common/goacc/builtin-goacc-parlevel-id-size.c: Likewise.
	* c-c++-common/goacc/nesting-fail-1.c: Likewise.
	* c-c++-common/goacc/routine-1.c: Likewise.
	* c-c++-common/goacc/routine-level-of-parallelism-1.c: Likewise.
	* c-c++-common/goacc/routine-level-of-parallelism-2.c: Likewise.
	* c-c++-common/goacc/routine-nohost-1.c: Likewise.
	* c-c++-common/goacc/routine-nohost-2.c: Likewise.
	* g++.dg/goacc/routine-1.C: Likewise.
	* g++.dg/goacc/routine-2.C: Likewise.
	* gfortran.dg/goacc/pr72741-2.f: Likewise.
	* gfortran.dg/goacc/routine-9.f90: Likewise.
	* gfortran.dg/goacc/routine-without-clauses.f90: New test.

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/declare-2.c: Update test.
	* testsuite/libgomp.oacc-c-c++-common/declare-3.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/declare-4.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/host_data-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/mode-transitions.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-1.c: Likewise.
	* testsuite/libgomp.oacc-c-c++-common/routine-3.c: Likewise.

(cherry picked from gomp-4_0-branch r244980)
---
 gcc/omp-general.c                             |  6 ++-
 .../c-c++-common/goacc-gomp/nesting-fail-1.c  |  4 +-
 .../c-c++-common/goacc/Wparentheses-1.c       |  4 +-
 .../goacc/builtin-goacc-parlevel-id-size-2.c  |  2 +
 .../goacc/builtin-goacc-parlevel-id-size.c    |  2 +
 .../c-c++-common/goacc/nesting-fail-1.c       |  2 +-
 gcc/testsuite/c-c++-common/goacc/routine-1.c  |  4 ++
 .../goacc/routine-level-of-parallelism-1.c    |  8 ++--
 .../goacc/routine-level-of-parallelism-2.c    | 34 ++++++++--------
 .../c-c++-common/goacc/routine-nohost-1.c     | 20 +++++-----
 .../c-c++-common/goacc/routine-nohost-2.c     | 40 +++++++++----------
 gcc/testsuite/g++.dg/goacc/routine-1.C        |  6 +--
 gcc/testsuite/g++.dg/goacc/routine-2.C        | 10 ++---
 gcc/testsuite/gfortran.dg/goacc/pr72741-2.f   |  4 +-
 gcc/testsuite/gfortran.dg/goacc/routine-9.f90 | 22 +++++-----
 .../goacc/routine-without-clauses.f90         | 34 ++++++++++++++++
 .../libgomp.oacc-c-c++-common/declare-2.c     |  4 +-
 .../libgomp.oacc-c-c++-common/declare-3.c     |  2 +-
 .../libgomp.oacc-c-c++-common/declare-4.c     |  2 +-
 .../libgomp.oacc-c-c++-common/host_data-1.c   |  2 +-
 .../loop-dim-default.c                        |  2 +-
 .../mode-transitions.c                        |  2 +-
 .../parallel-loop-2.h                         |  2 +-
 .../libgomp.oacc-c-c++-common/routine-1.c     |  2 +-
 .../libgomp.oacc-c-c++-common/routine-3.c     |  2 +-
 25 files changed, 132 insertions(+), 90 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/routine-without-clauses.f90

diff --git a/gcc/omp-general.c b/gcc/omp-general.c
index 5c91ce73a50..d290766329f 100644
--- a/gcc/omp-general.c
+++ b/gcc/omp-general.c
@@ -613,8 +613,10 @@  oacc_verify_routine_clauses (tree fndecl, tree *clauses, location_t loc,
       }
   if (c_level == NULL_TREE)
     {
-      /* OpenACC 2.5 makes this an error; for the current OpenACC 2.0a
-	 implementation add an implicit "seq" clause.  */
+      /* OpenACC 2.5 expects the user to supply one parallelism clause.  */
+      warning_at (loc, 0, "expecting one of %<gang%>, %<worker%>, %<vector%> "
+		  "or %<seq%> clauses");
+      inform (loc, "assigning %<seq%> parallelism to this routine");
       c_level = build_omp_clause (loc, OMP_CLAUSE_SEQ);
       OMP_CLAUSE_CHAIN (c_level) = *clauses;
       *clauses = c_level;
diff --git a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
index 1a3324200e2..57eaa0296d6 100644
--- a/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
+++ b/gcc/testsuite/c-c++-common/goacc-gomp/nesting-fail-1.c
@@ -362,7 +362,7 @@  f_acc_data (void)
   }
 }
 
-#pragma acc routine
+#pragma acc routine seq
 void
 f_acc_loop (void)
 {
@@ -436,7 +436,7 @@  f_acc_loop (void)
     }
 }
 
-#pragma acc routine
+#pragma acc routine seq
 void
 f_acc_routine (void)
 {
diff --git a/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
index 08265b65e0b..9d35ec50ed8 100644
--- a/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/Wparentheses-1.c
@@ -4,9 +4,9 @@ 
 int a, b, c;
 void bar (void);
 void baz (void);
-#pragma acc routine
+#pragma acc routine seq
 void bar2 (void);
-#pragma acc routine
+#pragma acc routine seq
 void baz2 (void);
 
 void
diff --git a/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c b/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c
index 16c7b34f66c..b9856e290ec 100644
--- a/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c
+++ b/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size-2.c
@@ -35,3 +35,5 @@  foo2 (int arg)
   __builtin_goacc_parlevel_size (3);
   /* { dg-error "illegal argument 0 to '__builtin_goacc_parlevel_size'" "" { target *-*-* } .-1 } */
 }
+
+/* { dg-warning "expecting one of" "" { target *-*-* } 16 } */
diff --git a/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size.c b/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size.c
index 5cda8189fb8..210f3771758 100644
--- a/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size.c
+++ b/gcc/testsuite/c-c++-common/goacc/builtin-goacc-parlevel-id-size.c
@@ -77,3 +77,5 @@  foo3 (void)
     res += __builtin_goacc_parlevel_size (GOMP_DIM_VECTOR);
   }
 }
+
+/* { dg-warning "expecting one of" "" { target *-*-* } 6 } */
diff --git a/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c b/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
index 93a911120d4..14620952adf 100644
--- a/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
@@ -57,7 +57,7 @@  f_acc_data (void)
   }
 }
 
-#pragma acc routine
+#pragma acc routine seq
 void
 f_acc_routine (void)
 {
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-1.c b/gcc/testsuite/c-c++-common/goacc/routine-1.c
index 23e273c58f4..7518f88f916 100644
--- a/gcc/testsuite/c-c++-common/goacc/routine-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/routine-1.c
@@ -55,3 +55,7 @@  int main ()
 
   return 0;
 }
+
+/* { dg-warning "expecting one of" "" { target *-*-* } 23 } */
+/* { dg-warning "expecting one of" "" { target *-*-* } 29 } */
+/* { dg-warning "expecting one of" "" { target *-*-* } 33 } */
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-1.c b/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-1.c
index d1258750ae0..766ddbc7f43 100644
--- a/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-1.c
@@ -428,20 +428,20 @@  extern void s_7 (void);
 void g_8 (void)
 {
 }
-#pragma acc routine (g_8) /* { dg-error "incompatible .seq. clause when applying .#pragma acc routine. to .\[void \]*g_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (g_8) seq /* { dg-error "incompatible .seq. clause when applying .#pragma acc routine. to .\[void \]*g_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 #pragma acc routine \
   worker
 extern void w_8 (void);
-#pragma acc routine (w_8) /* { dg-error "incompatible .seq. clause when applying .#pragma acc routine. to .\[void \]*w_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (w_8) seq /* { dg-error "incompatible .seq. clause when applying .#pragma acc routine. to .\[void \]*w_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 #pragma acc routine \
   vector
 extern void v_8 (void);
-#pragma acc routine (v_8) /* { dg-error "incompatible .seq. clause when applying .#pragma acc routine. to .\[void \]*v_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (v_8) seq /* { dg-error "incompatible .seq. clause when applying .#pragma acc routine. to .\[void \]*v_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 extern void s_8 (void);
-#pragma acc routine (s_8)
+#pragma acc routine (s_8) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_8) \
   vector /* { dg-error "incompatible .vector. clause when applying .#pragma acc routine. to .\[void \]*s_8\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 #pragma acc routine (s_8) \
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-2.c b/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-2.c
index 36626229299..1f40e13e40e 100644
--- a/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-2.c
+++ b/gcc/testsuite/c-c++-common/goacc/routine-level-of-parallelism-2.c
@@ -3,9 +3,7 @@ 
    ../../gfortran.dg/goacc/routine-level-of-parallelism-2.f.  */
 
 #pragma acc routine gang
-void g_1 (void) /* { dg-warning "region is gang partitioned but does not contain gang partitioned code" } */
-/* { dg-bogus "region is worker partitioned but does not contain worker partitioned code" "worker partitioned" { xfail *-*-* } .-1 } */
-/* { dg-bogus "region is vector partitioned but does not contain vector partitioned code" "worker partitioned" { xfail *-*-* } .-2 } */
+void g_1 (void)
 {
 }
 #pragma acc routine (g_1) gang
@@ -28,46 +26,46 @@  extern void v_1 (void);
 
 #pragma acc routine seq
 extern void s_1_1 (void);
-#pragma acc routine (s_1_1)
+#pragma acc routine (s_1_1) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_1_1) seq
-#pragma acc routine (s_1_1)
+#pragma acc routine (s_1_1) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_1_1) seq
 
-#pragma acc routine
+#pragma acc routine  /* { dg-warning "expecting one of" } */
 extern void s_1_2 (void);
-#pragma acc routine (s_1_2)
+#pragma acc routine (s_1_2) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_1_2) seq
-#pragma acc routine (s_1_2)
+#pragma acc routine (s_1_2) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_1_2) seq
 
 extern void s_2_1 (void);
 #pragma acc routine (s_2_1) seq
-#pragma acc routine (s_2_1)
+#pragma acc routine (s_2_1) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_2_1) seq
-#pragma acc routine (s_2_1)
+#pragma acc routine (s_2_1) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_2_1) seq
 
 extern void s_2_2 (void);
-#pragma acc routine (s_2_2)
-#pragma acc routine (s_2_2)
+#pragma acc routine (s_2_2) /* { dg-warning "expecting one of" } */
+#pragma acc routine (s_2_2) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_2_2) seq
-#pragma acc routine (s_2_2)
+#pragma acc routine (s_2_2) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_2_2) seq
 
 #pragma acc routine seq
 void s_3_1 (void)
 {
 }
-#pragma acc routine (s_3_1)
+#pragma acc routine (s_3_1) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_3_1) seq
-#pragma acc routine (s_3_1)
+#pragma acc routine (s_3_1) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_3_1) seq
 
-#pragma acc routine
+#pragma acc routine seq
 void s_3_2 (void)
 {
 }
-#pragma acc routine (s_3_2)
+#pragma acc routine (s_3_2) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_3_2) seq
-#pragma acc routine (s_3_2)
+#pragma acc routine (s_3_2) /* { dg-warning "expecting one of" } */
 #pragma acc routine (s_3_2) seq
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-nohost-1.c b/gcc/testsuite/c-c++-common/goacc/routine-nohost-1.c
index 17d6b0387e3..800bcf69c1f 100644
--- a/gcc/testsuite/c-c++-common/goacc/routine-nohost-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/routine-nohost-1.c
@@ -3,46 +3,46 @@ 
 
 /* { dg-additional-options "-fdump-tree-oaccdevlow" } */
 
-#pragma acc routine nohost
+#pragma acc routine nohost seq
 int THREE(void)
 {
   return 3;
 }
 
-#pragma acc routine (THREE) nohost
+#pragma acc routine (THREE) nohost seq
 
-#pragma acc routine nohost
+#pragma acc routine nohost seq
 extern int THREE(void);
 
 
-#pragma acc routine nohost
+#pragma acc routine nohost seq
 extern void NOTHING(void);
 
-#pragma acc routine (NOTHING) nohost
+#pragma acc routine (NOTHING) nohost seq
 
 void NOTHING(void)
 {
 }
 
-#pragma acc routine nohost
+#pragma acc routine nohost seq
 extern void NOTHING(void);
 
-#pragma acc routine (NOTHING) nohost
+#pragma acc routine (NOTHING) nohost seq
 
 
 extern float ADD(float, float);
 
-#pragma acc routine (ADD) nohost
+#pragma acc routine (ADD) nohost seq
 
 float ADD(float x, float y)
 {
   return x + y;
 }
 
-#pragma acc routine nohost
+#pragma acc routine nohost seq
 extern float ADD(float, float);
 
-#pragma acc routine (ADD) nohost
+#pragma acc routine (ADD) nohost seq
 
 
 /* { dg-final { scan-tree-dump-times "Discarding function" 3 "oaccdevlow" } } */
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-nohost-2.c b/gcc/testsuite/c-c++-common/goacc/routine-nohost-2.c
index 7402bfc1b41..f172c38458e 100644
--- a/gcc/testsuite/c-c++-common/goacc/routine-nohost-2.c
+++ b/gcc/testsuite/c-c++-common/goacc/routine-nohost-2.c
@@ -1,41 +1,41 @@ 
 /* Test invalid usage of the nohost clause for OpenACC routine directive.
    Exercising different variants for declaring routines.  */
 
-#pragma acc routine
+#pragma acc routine seq
 int THREE_1(void)
 {
   return 3;
 }
 
 #pragma acc routine (THREE_1) \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 #pragma acc routine \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 extern int THREE_1(void);
 
 
-#pragma acc routine
+#pragma acc routine seq
 extern void NOTHING_1(void);
 
 #pragma acc routine (NOTHING_1) \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 void NOTHING_1(void)
 {
 }
 
 #pragma acc routine \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 extern void NOTHING_1(void);
 
 #pragma acc routine (NOTHING_1) \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_1\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 
 extern float ADD_1(float, float);
 
-#pragma acc routine (ADD_1)
+#pragma acc routine (ADD_1) seq
 
 float ADD_1(float x, float y)
 {
@@ -43,55 +43,55 @@  float ADD_1(float x, float y)
 }
 
 #pragma acc routine \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_1\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_1\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
 extern float ADD_1(float, float);
 
 #pragma acc routine (ADD_1) \
-  nohost /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_1\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
+  nohost seq /* { dg-error "incompatible .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_1\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
 
 
 /* The same again, but with/without nohost reversed.  */
 
 #pragma acc routine \
-  nohost
+  nohost seq
 int THREE_2(void)
 {
   return 3;
 }
 
-#pragma acc routine (THREE_2) /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (THREE_2) seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
-#pragma acc routine /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[int \]*THREE_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 extern int THREE_2(void);
 
 
 #pragma acc routine \
-  nohost
+  nohost seq
 extern void NOTHING_2(void);
 
-#pragma acc routine (NOTHING_2) /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (NOTHING_2) seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 void NOTHING_2(void)
 {
 }
 
-#pragma acc routine /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 extern void NOTHING_2(void);
 
-#pragma acc routine (NOTHING_2) /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (NOTHING_2) seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[void \]*NOTHING_2\[\\(\\)\]*., which has already been marked as an accelerator routine" } */
 
 
 extern float ADD_2(float, float);
 
 #pragma acc routine (ADD_2) \
-  nohost
+  nohost seq
 
 float ADD_2(float x, float y)
 {
   return x + y;
 }
 
-#pragma acc routine /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_2\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_2\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
 extern float ADD_2(float, float);
 
-#pragma acc routine (ADD_2) /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_2\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
+#pragma acc routine (ADD_2) seq /* { dg-error "missing .nohost. clause when applying .#pragma acc routine. to .\[float \]*ADD_2\[\\(float, \\)\]*., which has already been marked as an accelerator routine" } */
diff --git a/gcc/testsuite/g++.dg/goacc/routine-1.C b/gcc/testsuite/g++.dg/goacc/routine-1.C
index a73a73d5fc1..92573245c54 100644
--- a/gcc/testsuite/g++.dg/goacc/routine-1.C
+++ b/gcc/testsuite/g++.dg/goacc/routine-1.C
@@ -4,10 +4,10 @@  namespace N
 {
   extern void foo1();
   extern void foo2();
-#pragma acc routine (foo1)
-#pragma acc routine
+#pragma acc routine (foo1) seq
+#pragma acc routine seq
   void foo3()
   {
   }
 }
-#pragma acc routine (N::foo2)
+#pragma acc routine (N::foo2) seq
diff --git a/gcc/testsuite/g++.dg/goacc/routine-2.C b/gcc/testsuite/g++.dg/goacc/routine-2.C
index c82493321cb..436170b940a 100644
--- a/gcc/testsuite/g++.dg/goacc/routine-2.C
+++ b/gcc/testsuite/g++.dg/goacc/routine-2.C
@@ -2,28 +2,28 @@ 
 
 template <typename T>
 extern T one_d();
-#pragma acc routine (one_d) nohost /* { dg-error "names a set of overloads" } */
+#pragma acc routine (one_d) nohost seq /* { dg-error "names a set of overloads" } */
 
 
 int incr (int);
 float incr (float);
 
-#pragma acc routine (incr) /* { dg-error "names a set of overloads" } */
+#pragma acc routine (incr) seq /* { dg-error "names a set of overloads" } */
 
 
 int sum (int, int);
 
 namespace foo {
-#pragma acc routine (sum)
+#pragma acc routine (sum) seq
   int sub (int, int);
 }
 
-#pragma acc routine (foo::sub)
+#pragma acc routine (foo::sub) seq
 
 /* It's strange to apply a routine directive to subset of overloaded
    functions, but that is permissible in OpenACC 2.x.  */
 
 int decr (int a);
 
-#pragma acc routine
+#pragma acc routine seq
 float decr (float a);
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72741-2.f b/gcc/testsuite/gfortran.dg/goacc/pr72741-2.f
index 58651440d20..0f0f7dff2e1 100644
--- a/gcc/testsuite/gfortran.dg/goacc/pr72741-2.f
+++ b/gcc/testsuite/gfortran.dg/goacc/pr72741-2.f
@@ -1,5 +1,5 @@ 
       SUBROUTINE v_1
-!$ACC ROUTINE
+!$ACC ROUTINE SEQ
 !$ACC ROUTINE ! { dg-error "ACC ROUTINE already applied" }
 !$ACC ROUTINE GANG ! { dg-error "ACC ROUTINE already applied" }
 !$ACC ROUTINE SEQ ! { dg-error "ACC ROUTINE already applied" }
@@ -13,7 +13,7 @@ 
 !$ACC ROUTINE (g_1) GANG
 !$ACC ROUTINE (g_1) VECTOR ! { dg-error "ACC ROUTINE already applied" }
 !$ACC ROUTINE (g_1) SEQ ! { dg-error "ACC ROUTINE already applied" }
-!$ACC ROUTINE (g_1) ! { dg-error "ACC ROUTINE already applied" }
+!$ACC ROUTINE (g_1) WORKER! { dg-error "ACC ROUTINE already applied" }
 !$ACC ROUTINE (g_1) ! { dg-error "ACC ROUTINE already applied" }
 
       CALL v_1
diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-9.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-9.f90
index 590e5946d2f..40274710e0e 100644
--- a/gcc/testsuite/gfortran.dg/goacc/routine-9.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/routine-9.f90
@@ -7,9 +7,9 @@  contains
   subroutine subr5 (x)
     implicit none
     integer extfunc
-    !$acc routine (subr5)
-    !$acc routine (extfunc)
-    !$acc routine (m1int) ! { dg-error "invalid function name" }
+    !$acc routine (subr5) seq
+    !$acc routine (extfunc) seq
+    !$acc routine (m1int) seq ! { dg-error "invalid function name" }
     integer, intent(inout) :: x
     if (x < 1) then
        x = 1
@@ -29,13 +29,13 @@  program main
   end interface
   integer, parameter :: n = 10
   integer :: a(n), i
-  !$acc routine (subr1) ! { dg-error "invalid function name" }
+  !$acc routine (subr1) seq ! { dg-error "invalid function name" }
   external :: subr2
-  !$acc routine (subr2)
+  !$acc routine (subr2) seq
 
   external :: R1, R2
-  !$acc routine (R1)
-  !$acc routine (R2)
+  !$acc routine (R1) seq
+  !$acc routine (R2) seq
 
   !$acc parallel
   !$acc loop
@@ -47,7 +47,7 @@  program main
 end program main
 
 subroutine subr1 (x)
-  !$acc routine
+  !$acc routine seq
   integer, intent(inout) :: x
   if (x < 1) then
      x = 1
@@ -66,7 +66,7 @@  subroutine subr2 (x)
 end subroutine subr2
 
 subroutine subr3 (x)
-  !$acc routine (subr3)
+  !$acc routine (subr3) seq
   integer, intent(inout) :: x
   if (x < 1) then
      x = 1
@@ -76,7 +76,7 @@  subroutine subr3 (x)
 end subroutine subr3
 
 subroutine subr4 (x)
-  !$acc routine (subr4)
+  !$acc routine (subr4) seq
   integer, intent(inout) :: x
   if (x < 1) then
      x = 1
@@ -86,7 +86,7 @@  subroutine subr4 (x)
 end subroutine subr4
 
 subroutine subr10 (x)
-  !$acc routine (subr10) device ! { dg-error "Unclassifiable OpenACC directive" }
+  !$acc routine (subr10) seq device ! { dg-error "Unclassifiable OpenACC directive" }
   integer, intent(inout) :: x
   if (x < 1) then
      x = 1
diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-without-clauses.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-without-clauses.f90
new file mode 100644
index 00000000000..6d3b13fb9e7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/routine-without-clauses.f90
@@ -0,0 +1,34 @@ 
+! Test the OpenACC routine directive when it has no gang, worker
+! vector, or seq partitioning clauses.
+
+subroutine s1
+  !$acc routine ! { dg-warning "Expected one of" }
+end subroutine s1
+
+integer function f1 ()
+  !$acc routine ! { dg-warning "Expected one of" }
+end function f1
+
+module m
+contains
+  subroutine s2
+    !$acc routine ! { dg-warning "Expected one of" }
+  end subroutine s2
+
+  integer function f2 ()
+    !$acc routine ! { dg-warning "Expected one of" }
+  end function f2
+end module m
+
+program t
+  implicit none
+  interface
+     subroutine s3
+       !$acc routine ! { dg-warning "Expected one of" }
+     end subroutine s3
+
+     integer function f3 ()
+       !$acc routine ! { dg-warning "Expected one of" }
+     end function f3
+  end interface
+end program t
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-2.c
index d212458dada..a242ac2a93e 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-2.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-2.c
@@ -5,7 +5,7 @@ 
 float c[N];
 #pragma acc declare device_resident (c)
 
-#pragma acc routine
+#pragma acc routine seq
 float
 subr2 (float a)
 {
@@ -23,7 +23,7 @@  subr2 (float a)
 float b[N];
 #pragma acc declare copyin (b)
 
-#pragma acc routine
+#pragma acc routine seq
 float
 subr1 (float a)
 {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-3.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-3.c
index c3a21876312..1b72bda06f6 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-3.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-3.c
@@ -6,7 +6,7 @@ 
 float *b;
 #pragma acc declare deviceptr (b)
 
-#pragma acc routine
+#pragma acc routine seq
 float *
 subr2 (void)
 {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c
index ca48e801314..02c3c8ea8d2 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c
@@ -4,7 +4,7 @@ 
 float b;
 #pragma acc declare create (b)
 
-#pragma acc routine
+#pragma acc routine seq
 int
 func (int a)
 {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
index 21d2139af27..c0933935c00 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/host_data-1.c
@@ -8,7 +8,7 @@ 
 #include <cuda_runtime_api.h>
 #include <cublas_v2.h>
 
-#pragma acc routine
+#pragma acc routine seq
 void
 saxpy (int n, float a, float *x, float *y)
 {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
index dd8107c1acc..87c47256605 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-dim-default.c
@@ -6,7 +6,7 @@ 
 #include <stdio.h>
 #include <gomp-constants.h>
 
-#pragma acc routine
+#pragma acc routine /* { dg-warning "expecting one of" } */
 static int __attribute__ ((noinline)) coord ()
 {
   int res = 0;
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/mode-transitions.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/mode-transitions.c
index 4474c127992..b97b777d967 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/mode-transitions.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/mode-transitions.c
@@ -1101,7 +1101,7 @@  void t27()
 
 /* Check if worker-single variables get broadcastd to vectors.  */
 
-#pragma acc routine
+#pragma acc routine seq
 float t28_routine ()
 {
   return 2.71;
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h
index 5691b7e845f..1934a2b28a8 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h
@@ -2,7 +2,7 @@ 
 #define VARS
 int a[1500];
 float b[10][15][10];
-#pragma acc routine
+#pragma acc routine seq
 __attribute__((noreturn)) void
 noreturn (void)
 {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c
index 0f70e264240..e45e9307222 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-1.c
@@ -8,7 +8,7 @@ 
 
 #include <stdlib.h>
 
-#pragma acc routine
+#pragma acc routine seq
 TEMPLATE
 RETURN_1 fact(TYPE n) RETURN_2
 {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-3.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-3.c
index 2cdd6bf459c..07b95515051 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-3.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/routine-3.c
@@ -6,7 +6,7 @@ 
 
 #include <stdlib.h>
 
-#pragma acc routine nohost
+#pragma acc routine nohost seq
 int
 foo (int n)
 {
-- 
2.17.1