public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [gomp4.1] Disallow modifiers on linear clause except in declare simd
Date: Tue, 13 Oct 2015 07:15:00 -0000	[thread overview]
Message-ID: <20151013071524.GB478@tucnak.redhat.com> (raw)

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

                 reply	other threads:[~2015-10-13  7:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151013071524.GB478@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).