public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed][nvptx] Postpone warnings in nvptx_goacc_validate_dims_1
@ 2019-01-07  8:54 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2019-01-07  8:54 UTC (permalink / raw)
  To: gcc-patches

Hi,

this patch moves warnings in nvptx_goacc_validate_dims_1 to as late as
possible.  This allows us more flexibility in setting the dimensions.

Committed to trunk.

Thanks,
- Tom

[nvptx] Postpone warnings in nvptx_goacc_validate_dims_1

2019-01-07  Tom de Vries  <tdevries@suse.de>

	* config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): Move warnings to
	as late as possible.

---
 gcc/config/nvptx/nvptx.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 3d680e9d80a..3a4a5a3a159 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -5376,25 +5376,37 @@ nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level)
       gcc_assert (dims[GOMP_DIM_GANG] >= -1);
     }
 
-  if (dims[GOMP_DIM_VECTOR] >= 0
-      && dims[GOMP_DIM_VECTOR] != PTX_WARP_SIZE)
+  int old_dims[GOMP_DIM_MAX];
+  unsigned int i;
+  for (i = 0; i < GOMP_DIM_MAX; ++i)
+    old_dims[i] = dims[i];
+
+  const char *vector_reason = NULL;
+  if (dims[GOMP_DIM_VECTOR] == 0)
     {
-      warning_at (decl ? DECL_SOURCE_LOCATION (decl) : UNKNOWN_LOCATION, 0,
-		  dims[GOMP_DIM_VECTOR]
-		  ? G_("using vector_length (%d), ignoring %d")
-		  : G_("using vector_length (%d), ignoring runtime setting"),
-		  PTX_DEFAULT_VECTOR_LENGTH, dims[GOMP_DIM_VECTOR]);
+      vector_reason = G_("using vector_length (%d), ignoring runtime setting");
       dims[GOMP_DIM_VECTOR] = PTX_DEFAULT_VECTOR_LENGTH;
     }
 
+  if (dims[GOMP_DIM_VECTOR] > 0
+      && dims[GOMP_DIM_VECTOR] != PTX_WARP_SIZE)
+    dims[GOMP_DIM_VECTOR] = PTX_DEFAULT_VECTOR_LENGTH;
+
   /* Check the num workers is not too large.  */
   if (dims[GOMP_DIM_WORKER] > PTX_WORKER_LENGTH)
-    {
-      warning_at (decl ? DECL_SOURCE_LOCATION (decl) : UNKNOWN_LOCATION, 0,
-		  "using num_workers (%d), ignoring %d",
-		  PTX_WORKER_LENGTH, dims[GOMP_DIM_WORKER]);
-      dims[GOMP_DIM_WORKER] = PTX_WORKER_LENGTH;
-    }
+    dims[GOMP_DIM_WORKER] = PTX_WORKER_LENGTH;
+
+  if (dims[GOMP_DIM_VECTOR] != old_dims[GOMP_DIM_VECTOR])
+    warning_at (decl ? DECL_SOURCE_LOCATION (decl) : UNKNOWN_LOCATION, 0,
+		vector_reason != NULL
+		? vector_reason
+		: G_("using vector_length (%d), ignoring %d"),
+		dims[GOMP_DIM_VECTOR], old_dims[GOMP_DIM_VECTOR]);
+
+  if (dims[GOMP_DIM_WORKER] != old_dims[GOMP_DIM_WORKER])
+    warning_at (decl ? DECL_SOURCE_LOCATION (decl) : UNKNOWN_LOCATION, 0,
+		G_("using num_workers (%d), ignoring %d"),
+		dims[GOMP_DIM_WORKER], old_dims[GOMP_DIM_WORKER]);
 
   if (oacc_default_dims_p)
     {

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

only message in thread, other threads:[~2019-01-07  8:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07  8:54 [committed][nvptx] Postpone warnings in nvptx_goacc_validate_dims_1 Tom de Vries

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).