[committed,nvptx] Allow default vl to be overridden in nvptx_goacc_validate_dims_1

Message ID 20190112103906.GA11521@delia
State New
Headers show
Series
  • [committed,nvptx] Allow default vl to be overridden in nvptx_goacc_validate_dims_1
Related show

Commit Message

Tom de Vries Jan. 12, 2019, 10:39 a.m.
Hi,

In nvptx_goacc_validate_dims_1, allow oacc_default_dims[DIM_VECTOR] to be
overridden, by assigning it to a new variable default_vector_length at the
start, and using it at the end.

Committed to trunk.

Thanks,
- Tom

[nvptx] Allow default vl to be overridden in nvptx_goacc_validate_dims_1

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

	* config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1): Add an use new
	variable default_vector_length.

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

Patch

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index a4c79532a1d..95d72d0a4e0 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -5556,6 +5556,7 @@  nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level, unsigned used)
   bool offload_region_p = false;
   bool routine_p = false;
   bool routine_seq_p = false;
+  int default_vector_length = -1;
 
   if (decl == NULL_TREE)
     {
@@ -5654,6 +5655,12 @@  nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level, unsigned used)
       gcc_assert (dims[GOMP_DIM_GANG] >= -1);
     }
 
+  if (offload_region_p)
+    default_vector_length = oacc_get_default_dim (GOMP_DIM_VECTOR);
+  else
+    /* oacc_default_dims_p.  */
+    default_vector_length = PTX_DEFAULT_VECTOR_LENGTH;
+
   int old_dims[GOMP_DIM_MAX];
   unsigned int i;
   for (i = 0; i < GOMP_DIM_MAX; ++i)
@@ -5673,12 +5680,12 @@  nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level, unsigned used)
   if (dims[GOMP_DIM_VECTOR] == 0)
     {
       vector_reason = G_("using vector_length (%d), ignoring runtime setting");
-      dims[GOMP_DIM_VECTOR] = PTX_DEFAULT_VECTOR_LENGTH;
+      dims[GOMP_DIM_VECTOR] = default_vector_length;
     }
 
   if (dims[GOMP_DIM_VECTOR] > 0
       && !nvptx_welformed_vector_length_p (dims[GOMP_DIM_VECTOR]))
-    dims[GOMP_DIM_VECTOR] = PTX_DEFAULT_VECTOR_LENGTH;
+    dims[GOMP_DIM_VECTOR] = default_vector_length;
 
   nvptx_apply_dim_limits (dims);
 
@@ -5696,7 +5703,7 @@  nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level, unsigned used)
 
   if (oacc_default_dims_p)
     {
-      dims[GOMP_DIM_VECTOR] = PTX_DEFAULT_VECTOR_LENGTH;
+      dims[GOMP_DIM_VECTOR] = default_vector_length;
       if (dims[GOMP_DIM_WORKER] < 0)
 	dims[GOMP_DIM_WORKER] = PTX_DEFAULT_RUNTIME_DIM;
       if (dims[GOMP_DIM_GANG] < 0)
@@ -5715,7 +5722,9 @@  nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level, unsigned used)
 	    /* Function oacc_validate_dims will apply the minimal dimension.  */
 	    continue;
 
-	  dims[i] = oacc_get_default_dim (i);
+	  dims[i] = (i == GOMP_DIM_VECTOR
+		     ? default_vector_length
+		     : oacc_get_default_dim (i));
 	}
 
       nvptx_apply_dim_limits (dims);