This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Improve diagnostics for OpenMP doacross loops (PR translation/79999)


Hi!

The following testcase clarifies the diagnostics for OpenMP doaccross
and adds a testcase to cover warnings that weren't covered in the testsuite
previously.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-03-07  Jakub Jelinek  <jakub@redhat.com>

	PR translation/79999
	* gimplify.c (gimplify_omp_ordered): Reword diagnostics to talk about
	depend clause with source (or sink) modifier.
	* omp-expand.c (expand_omp_ordered_sink): Likewise.

	* c-c++-common/gomp/doacross-1.c: Adjust expected diagnostics.
	* c-c++-common/gomp/doacross-3.c: New test.

--- gcc/gimplify.c.jj	2019-03-06 19:45:40.822744176 +0100
+++ gcc/gimplify.c	2019-03-07 17:40:39.958301852 +0100
@@ -12145,8 +12145,8 @@ gimplify_omp_ordered (tree expr, gimple_
 	    if (!fail && i != gimplify_omp_ctxp->loop_iter_var.length () / 2)
 	      {
 		error_at (OMP_CLAUSE_LOCATION (c),
-			  "number of variables in %<depend(sink)%> "
-			  "clause does not match number of "
+			  "number of variables in %<depend%> clause with "
+			  "%<sink%> modifier does not match number of "
 			  "iteration variables");
 		failures++;
 	      }
@@ -12158,8 +12158,8 @@ gimplify_omp_ordered (tree expr, gimple_
 	    if (source_c)
 	      {
 		error_at (OMP_CLAUSE_LOCATION (c),
-			  "more than one %<depend(source)%> clause on an "
-			  "%<ordered%> construct");
+			  "more than one %<depend%> clause with %<source%> "
+			  "modifier on an %<ordered%> construct");
 		failures++;
 	      }
 	    else
@@ -12169,8 +12169,9 @@ gimplify_omp_ordered (tree expr, gimple_
   if (source_c && sink_c)
     {
       error_at (OMP_CLAUSE_LOCATION (source_c),
-		"%<depend(source)%> clause specified together with "
-		"%<depend(sink:)%> clauses on the same construct");
+		"%<depend%> clause with %<source%> modifier specified "
+		"together with %<depend%> clauses with %<sink%> modifier "
+		"on the same construct");
       failures++;
     }
 
--- gcc/omp-expand.c.jj	2019-01-01 12:37:16.673982892 +0100
+++ gcc/omp-expand.c	2019-03-07 17:42:04.906917520 +0100
@@ -2147,8 +2147,8 @@ expand_omp_ordered_sink (gimple_stmt_ite
 	      forward = tree_int_cst_sgn (step) != -1;
 	    }
 	  if (forward ^ OMP_CLAUSE_DEPEND_SINK_NEGATIVE (deps))
-	    warning_at (loc, 0, "%<depend(sink)%> clause waiting for "
-				"lexically later iteration");
+	    warning_at (loc, 0, "%<depend%> clause with %<sink%> modifier "
+				"waiting for lexically later iteration");
 	  break;
 	}
       deps = TREE_CHAIN (deps);
@@ -2284,8 +2284,9 @@ expand_omp_ordered_sink (gimple_stmt_ite
 			       build_int_cst (itype, 0));
 	  if (integer_zerop (t) && !warned_step)
 	    {
-	      warning_at (loc, 0, "%<depend(sink)%> refers to iteration never "
-				  "in the iteration space");
+	      warning_at (loc, 0, "%<depend%> clause with %<sink%> modifier "
+				  "refers to iteration never in the iteration "
+				  "space");
 	      warned_step = true;
 	    }
 	  cond = fold_build2_loc (loc, BIT_AND_EXPR, boolean_type_node,
--- gcc/testsuite/c-c++-common/gomp/doacross-1.c.jj	2015-11-06 22:20:16.181539042 +0100
+++ gcc/testsuite/c-c++-common/gomp/doacross-1.c	2019-03-07 17:49:42.077467424 +0100
@@ -38,11 +38,11 @@ foo (void)
   for (i = 0; i < 64; i++)
     {
       #pragma omp ordered depend (sink: i - 1) depend (sink: i - 2)
-      #pragma omp ordered depend (source) depend (source) /* { dg-error "more than one .depend.source.. clause on an" } */
+      #pragma omp ordered depend (source) depend (source) /* { dg-error "more than one .depend. clause with .source. modifier on an .ordered. construct" } */
     }
   #pragma omp for ordered (1)
   for (i = 0; i < 64; i++)
     {
-      #pragma omp ordered depend (sink: i - 1) depend (source) depend (sink: i - 2) /* { dg-error "clause specified together with" } */
+      #pragma omp ordered depend (sink: i - 1) depend (source) depend (sink: i - 2) /* { dg-error ".depend. clause with .source. modifier specified together with .depend. clauses with .sink. modifier on the same construct" } */
     }
 }
--- gcc/testsuite/c-c++-common/gomp/doacross-3.c.jj	2019-03-07 17:53:06.503136095 +0100
+++ gcc/testsuite/c-c++-common/gomp/doacross-3.c	2019-03-07 18:01:54.992521307 +0100
@@ -0,0 +1,54 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (void)
+{
+  int i, j;
+  #pragma omp for ordered (1)
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered depend (sink: i + 1)	/* { dg-warning "'depend' clause with 'sink' modifier waiting for lexically later iteration" } */
+      #pragma omp ordered depend (source)
+    }
+  #pragma omp for ordered (1)
+  for (i = 63; i >= 0; i--)
+    {
+      #pragma omp ordered depend (sink: i - 1)	/* { dg-warning "'depend' clause with 'sink' modifier waiting for lexically later iteration" } */
+      #pragma omp ordered depend (source)
+    }
+  #pragma omp for ordered (2) collapse (2)
+  for (i = 0; i < 64; i++)
+    for (j = 0; j < 64; j++)
+      {
+	#pragma omp ordered depend (sink: i + 1, j - 2)	/* { dg-warning "'depend' clause with 'sink' modifier waiting for lexically later iteration" } */
+	#pragma omp ordered depend (source)
+      }
+  #pragma omp for ordered (2) collapse (2)
+  for (i = 63; i >= 0; --i)
+    for (j = 0; j < 64; j++)
+      {
+	#pragma omp ordered depend (sink: i - 2, j - 2)	/* { dg-warning "'depend' clause with 'sink' modifier waiting for lexically later iteration" } */
+	#pragma omp ordered depend (source)
+      }
+  #pragma omp for ordered (2) collapse (2)
+  for (i = 0; i < 64; i++)
+    for (j = 0; j < 64; j++)
+      {
+	#pragma omp ordered depend (sink: i - 1, j + 2)
+	#pragma omp ordered depend (source)
+      }
+  #pragma omp for ordered (2) collapse (2)
+  for (i = 63; i >= 0; --i)
+    for (j = 0; j < 64; j++)
+      {
+	#pragma omp ordered depend (sink: i + 2, j + 2)
+	#pragma omp ordered depend (source)
+      }
+  #pragma omp for ordered (1)
+  for (i = 0; i < 64; i += 2)
+    {
+      #pragma omp ordered depend (sink: i - 1)	/* { dg-warning "'depend' clause with 'sink' modifier refers to iteration never in the iteration space" } */
+      #pragma omp ordered depend (source)
+    }
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]