diff mbox series

[committed,openacc] Add used parameter to TARGET_GOACC_VALIDATE_DIMS

Message ID 20190112102936.GA11343@delia
State New
Headers show
Series [committed,openacc] Add used parameter to TARGET_GOACC_VALIDATE_DIMS | expand

Commit Message

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

Add a used parameter to TARGET_GOACC_VALIDATE_DIMS, allowing a target to make
decisions in the hook implementation based on whether a dimension is used or
not.

Committed to trunk.

Thanks,
- Tom

[openacc] Add used parameter to TARGET_GOACC_VALIDATE_DIMS

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

	* config/nvptx/nvptx.c (nvptx_goacc_validate_dims_1)
	(nvptx_goacc_validate_dims): Add used parameter.
	* doc/tm.texi: Regenerate.
	* omp-offload.c (oacc_parse_default_dims, oacc_validate_dims): Add
	argument to call to targetm.goacc.validate_dims.
	(default_goacc_validate_dims): Add used
	parameter.
	* target.def (validate_dims): Add used parameter in DEFHOOK.
	* targhooks.h (default_goacc_validate_dims): Add used parameter.

---
 gcc/config/nvptx/nvptx.c | 6 +++---
 gcc/doc/tm.texi          | 2 +-
 gcc/omp-offload.c        | 9 +++++----
 gcc/target.def           | 2 +-
 gcc/targhooks.h          | 2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index b37010ff58e..89f0e560910 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -5549,7 +5549,7 @@  has_vector_partitionable_routine_calls_p (tree fndecl)
    DIMS has changed.  */
 
 static void
-nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level)
+nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level, unsigned used)
 {
   bool oacc_default_dims_p = false;
   bool oacc_min_dims_p = false;
@@ -5711,7 +5711,7 @@  nvptx_goacc_validate_dims_1 (tree decl, int dims[], int fn_level)
    DECL is null, we are validating the default dimensions.  */
 
 static bool
-nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
+nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level, unsigned used)
 {
   int old_dims[GOMP_DIM_MAX];
   unsigned int i;
@@ -5719,7 +5719,7 @@  nvptx_goacc_validate_dims (tree decl, int dims[], int fn_level)
   for (i = 0; i < GOMP_DIM_MAX; ++i)
     old_dims[i] = dims[i];
 
-  nvptx_goacc_validate_dims_1 (decl, dims, fn_level);
+  nvptx_goacc_validate_dims_1 (decl, dims, fn_level, used);
 
   gcc_assert (dims[GOMP_DIM_VECTOR] != 0);
   if (dims[GOMP_DIM_WORKER] > 0 && dims[GOMP_DIM_VECTOR] > 0)
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index ddde4a7287b..355fd5917af 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6071,7 +6071,7 @@  to use it.
 Return number of threads in SIMT thread group on the target.
 @end deftypefn
 
-@deftypefn {Target Hook} bool TARGET_GOACC_VALIDATE_DIMS (tree @var{decl}, int *@var{dims}, int @var{fn_level})
+@deftypefn {Target Hook} bool TARGET_GOACC_VALIDATE_DIMS (tree @var{decl}, int *@var{dims}, int @var{fn_level}, unsigned @var{used})
 This hook should check the launch dimensions provided for an OpenACC
 compute region, or routine.  Defaulted values are represented as -1
 and non-constant values as 0.  The @var{fn_level} is negative for the
diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c
index 9cac5655c63..201c459fa1f 100644
--- a/gcc/omp-offload.c
+++ b/gcc/omp-offload.c
@@ -644,8 +644,8 @@  oacc_parse_default_dims (const char *dims)
     }
 
   /* Allow the backend to validate the dimensions.  */
-  targetm.goacc.validate_dims (NULL_TREE, oacc_default_dims, -1);
-  targetm.goacc.validate_dims (NULL_TREE, oacc_min_dims, -2);
+  targetm.goacc.validate_dims (NULL_TREE, oacc_default_dims, -1, 0);
+  targetm.goacc.validate_dims (NULL_TREE, oacc_min_dims, -2, 0);
 }
 
 /* Validate and update the dimensions for offloaded FN.  ATTRS is the
@@ -673,7 +673,7 @@  oacc_validate_dims (tree fn, tree attrs, int *dims, int level, unsigned used)
       pos = TREE_CHAIN (pos);
     }
 
-  bool changed = targetm.goacc.validate_dims (fn, dims, level);
+  bool changed = targetm.goacc.validate_dims (fn, dims, level, used);
 
   /* Default anything left to 1 or a partitioned default.  */
   for (ix = 0; ix != GOMP_DIM_MAX; ix++)
@@ -1717,7 +1717,8 @@  execute_oacc_device_lower ()
 
 bool
 default_goacc_validate_dims (tree ARG_UNUSED (decl), int *dims,
-			     int ARG_UNUSED (fn_level))
+			     int ARG_UNUSED (fn_level),
+			     unsigned ARG_UNUSED (used))
 {
   bool changed = false;
 
diff --git a/gcc/target.def b/gcc/target.def
index 2aeb1ff8445..32830a1b33c 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -1686,7 +1686,7 @@  are being validated and unspecified defaults should be filled in.\n\
 Diagnostics should be issued as appropriate.  Return\n\
 true, if changes have been made.  You must override this hook to\n\
 provide dimensions larger than 1.",
-bool, (tree decl, int *dims, int fn_level),
+bool, (tree decl, int *dims, int fn_level, unsigned used),
 default_goacc_validate_dims)
 
 DEFHOOK
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index 3b6e404f080..fb133fd3f3f 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -121,7 +121,7 @@  extern void default_finish_cost (void *, unsigned *, unsigned *, unsigned *);
 extern void default_destroy_cost_data (void *);
 
 /* OpenACC hooks.  */
-extern bool default_goacc_validate_dims (tree, int [], int);
+extern bool default_goacc_validate_dims (tree, int [], int, unsigned);
 extern int default_goacc_dim_limit (int);
 extern bool default_goacc_fork_join (gcall *, const int [], bool);
 extern void default_goacc_reduction (gcall *);