public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4.1] Disallow modifiers on linear clause except in declare simd
@ 2015-10-13  7:15 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2015-10-13  7:15 UTC (permalink / raw)
  To: gcc-patches

Hi!

Modifiers are only meaningful in declare simd construct, therefore
latest OpenMP 4.5 disallows them on simd/for constructs.

2015-10-13  Jakub Jelinek  <jakub@redhat.com>

c/
	* c-typeck.c (c_finish_omp_clauses): Disallow modifiers on simd/for
	constructs.
cp/
	* semantics.c (finish_omp_clauses): Disallow modifiers on simd/for
	constructs.
testsuite/
	* c-c++-common/gomp/linear-1.c: New test.
	* g++.dg/gomp/linear-1.C: New test.

--- gcc/c/c-typeck.c.jj	2015-10-09 11:17:17.000000000 +0200
+++ gcc/c/c-typeck.c	2015-10-09 19:05:48.433813759 +0200
@@ -12470,6 +12470,14 @@ c_finish_omp_clauses (tree clauses, bool
 	  if (!declare_simd)
 	    need_implicitly_determined = true;
 	  t = OMP_CLAUSE_DECL (c);
+	  if (!declare_simd
+	      && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT)
+	    {
+	      error_at (OMP_CLAUSE_LOCATION (c),
+			"modifier should not be specified in %<linear%> "
+			"clause on %<simd%> or %<for%> constructs");
+	      OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
+	    }
 	  if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
 	      && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
 	    {
--- gcc/cp/semantics.c.jj	2015-10-09 11:19:37.000000000 +0200
+++ gcc/cp/semantics.c	2015-10-09 19:07:12.604636561 +0200
@@ -5725,6 +5725,14 @@ finish_omp_clauses (tree clauses, bool a
 	case OMP_CLAUSE_LINEAR:
 	  field_ok = allow_fields;
 	  t = OMP_CLAUSE_DECL (c);
+	  if (!declare_simd
+	      && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT)
+	    {
+	      error_at (OMP_CLAUSE_LOCATION (c),
+			"modifier should not be specified in %<linear%> "
+			"clause on %<simd%> or %<for%> constructs");
+	      OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
+	    }
 	  if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL)
 	      && !type_dependent_expression_p (t))
 	    {
--- gcc/testsuite/c-c++-common/gomp/linear-1.c.jj	2015-10-12 10:59:33.058013750 +0200
+++ gcc/testsuite/c-c++-common/gomp/linear-1.c	2015-10-12 11:25:31.633491633 +0200
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int i;
+
+#pragma omp declare simd linear (val (x) : 1) linear (y : 2)
+int bar (int x, int y, int z);
+
+void
+foo (int x, int y)
+{
+  #pragma omp simd linear (i: 3)
+  for (i = 0; i < 33; i += 3)
+    ;
+  #pragma omp simd linear (val (i): 3)		/* { dg-error "modifier should not be specified in" } */
+  for (i = 0; i < 33; i += 3)
+    ;
+  #pragma omp simd linear (x: y + 1)
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp simd linear (val (x): y + 1)	/* { dg-error "modifier should not be specified in" } */
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for linear (x: y + 1)
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for linear (val (x): y + 1)	/* { dg-error "modifier should not be specified in" } */
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for simd linear (i: 3)
+  for (i = 0; i < 33; i += 3)
+    ;
+  #pragma omp for simd linear (val (i): 3)	/* { dg-error "modifier should not be specified in" } */
+  for (i = 0; i < 33; i += 3)
+    ;
+  #pragma omp for simd linear (x: y + 1)
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for simd linear (val (x): y + 1)	/* { dg-error "modifier should not be specified in" } */
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+}
--- gcc/testsuite/g++.dg/gomp/linear-1.C.jj	2015-10-12 11:37:13.327880757 +0200
+++ gcc/testsuite/g++.dg/gomp/linear-1.C	2015-10-12 11:39:16.052024819 +0200
@@ -0,0 +1,48 @@
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+int i;
+
+#pragma omp declare simd linear (ref (x) : 1) linear (uval (y) : 2)
+int bar (int &x, int &y, int z);
+
+void
+foo (int &x, int &y)
+{
+  #pragma omp simd linear (x: y + 1)
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp simd linear (val (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp simd linear (ref (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp simd linear (uval (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for linear (x: y + 1)
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for linear (val (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for linear (ref (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for linear (uval (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for simd linear (x: y + 1)
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for simd linear (val (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for simd linear (ref (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+  #pragma omp for simd linear (uval (x): y + 1)	// { dg-error "modifier should not be specified in" }
+  for (i = 0; i < 10; i++)
+    x += y + 1;
+}

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-13  7:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-13  7:15 [gomp4.1] Disallow modifiers on linear clause except in declare simd Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).