Re: [gomp4] dimension API

2015-08-13 Thread Thomas Schwinge
Hi Nathan!

On Wed, 12 Aug 2015 09:30:10 -0400, Nathan Sidwell nat...@acm.org wrote:
 I've committed this patch to gomp4.  [...]
 
 Also  put in the change I mentioned earlier this morning about the default 
 validate dims hook setting the dimensions to 1 on accelerators to.  I'll  
 revert 
 Thomas's patch shortly.

Confirmed, that works, thanks!


Grüße,
 Thomas


pgphIkidFb9cy.pgp
Description: PGP signature


Re: [gomp4] dimension API

2015-08-12 Thread Nathan Sidwell

On 08/12/15 09:30, Nathan Sidwell wrote:

I've committed this patch to gomp4.  It reworks the oacc functiuon attribute
dimension handling.  Rather than pass the TREE_LIST to the various hooks, I
convert it to a regular C array of ints.  That makes life simpler for the
consumers.  They return a 'changed' flag to indicate whether the attrribute
should be rewritten.  That rewriting is done in a way that doesn;t presume the
attribute is unshared (Cesar, your workaround should no longer be necessary).


I've discovered I'd committed a slightly earlier version of what I'd tested. 
Consequently there is some breakage.  I'll be fixing it later today, after a retest.


nathan



[gomp4] dimension API

2015-08-12 Thread Nathan Sidwell
I've committed this patch to gomp4.  It reworks the oacc functiuon attribute 
dimension handling.  Rather than pass the TREE_LIST to the various hooks, I 
convert it to a regular C array of ints.  That makes life simpler for the 
consumers.  They return a 'changed' flag to indicate whether the attrribute 
should be rewritten.  That rewriting is done in a way that doesn;t presume the 
attribute is unshared (Cesar, your workaround should no longer be necessary).


Also  put in the change I mentioned earlier this morning about the default 
validate dims hook setting the dimensions to 1 on accelerators to.  I'll  revert 
Thomas's patch shortly.


nathan
2015-08-12  Nathan Sidwell  nat...@codesourcery.com

	* target.def (validate_dims): Adjust API.
	* targhooks.h (default_goacc_validate_dims): Adjust.
	* omp-low.c (replace_oacc_fn_attrib): New function.
	(set_oacc_fn_attrib): Use it.
	(oacc_xform_dim): Dims is array of ints.
	(execute_oacc_transform): Create int array of dims, adjust uses.
	(default_goacc_validate_dims): Adjust API.  Force to w everywhere.
	* doc/tm.texi: Rebuild.
	* config/nvptx/nvptx.c (nvptx_validate_dims): Adjust API.

Index: gcc/config/nvptx/nvptx.c
===
--- gcc/config/nvptx/nvptx.c	(revision 226808)
+++ gcc/config/nvptx/nvptx.c	(working copy)
@@ -3538,71 +3538,46 @@ nvptx_expand_builtin (tree exp, rtx targ
   return d-expander (exp, target, mode, ignore);
 }
 
-/* Validate compute dimensions, fill in defaults.  */
-
-static tree
-nvptx_validate_dims (tree decl, tree dims)
-{
-  tree adims[GOMP_DIM_MAX];
-  unsigned ix;
-  tree *pos_ptr;
-
-  for (ix = 0, pos_ptr = dims; ix != GOMP_DIM_MAX;
-   ix++, pos_ptr = TREE_CHAIN (*pos_ptr))
-{
-  if (!*pos_ptr)
-	*pos_ptr = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE);
-  
-  adims[ix] = TREE_VALUE (*pos_ptr);
-}
-
-  /* Define vector size for known hardware.  */
+/* Define vector size for known hardware.  */
 #define PTX_VECTOR_LENGTH 32
 #define PTX_WORKER_LENGTH 32
 
+/* Validate compute dimensions, fill in non-unity defaults.  */
+
+static bool
+nvptx_validate_dims (tree decl, int dims[])
+{
+  bool changed = false;
+
   /* If the worker size is not 1, the vector size must be 32.  If
  the vector  size is not 1, it must be 32.  */
-  if ((adims[GOMP_DIM_WORKER]
-TREE_INT_CST_LOW (adims[GOMP_DIM_WORKER]) != 1)
-  || (adims[GOMP_DIM_VECTOR]
-	   TREE_INT_CST_LOW (adims[GOMP_DIM_VECTOR]) != 1))
+  if ((dims[GOMP_DIM_WORKER]  1 || dims[GOMP_DIM_WORKER] == 0)
+  || (dims[GOMP_DIM_VECTOR]  1 || dims[GOMP_DIM_VECTOR] == 0))
 {
-  if (!adims[GOMP_DIM_VECTOR]
-	  || TREE_INT_CST_LOW (adims[GOMP_DIM_VECTOR]) != PTX_VECTOR_LENGTH)
+  if (dims[GOMP_DIM_VECTOR] != PTX_VECTOR_LENGTH)
 	{
-	  tree use = build_int_cst (integer_type_node, PTX_VECTOR_LENGTH);
-	  if (adims[GOMP_DIM_VECTOR])
+	  if (dims[GOMP_DIM_VECTOR] = 0)
 	warning_at (DECL_SOURCE_LOCATION (decl), 0,
-			TREE_INT_CST_LOW (adims[GOMP_DIM_VECTOR])
-			? using vector_length (%E), ignoring %E
-			: using vector_length (%E), ignoring runtime setting,
-			use, adims[GOMP_DIM_VECTOR]);
-	  adims[GOMP_DIM_VECTOR] = use;
+			dims[GOMP_DIM_VECTOR]
+			? using vector_length (%d), ignoring %d
+			: using vector_length (%d), ignoring runtime setting,
+			PTX_VECTOR_LENGTH, dims[GOMP_DIM_VECTOR]);
+	  dims[GOMP_DIM_VECTOR] = PTX_VECTOR_LENGTH;
+	  changed = true;
 	}
 }
 
   /* Check the num workers is not too large.  */
-  if (adims[GOMP_DIM_WORKER]
-   TREE_INT_CST_LOW (adims[GOMP_DIM_WORKER])  PTX_WORKER_LENGTH)
+  if (dims[GOMP_DIM_WORKER]  PTX_WORKER_LENGTH)
 {
-  tree use = build_int_cst (integer_type_node, PTX_WORKER_LENGTH);
   warning_at (DECL_SOURCE_LOCATION (decl), 0,
-		  using num_workers (%E), ignoring %E,
-		  use, adims[GOMP_DIM_WORKER]);
-  adims[GOMP_DIM_WORKER] = use;
+		  using num_workers (%d), ignoring %d,
+		  PTX_WORKER_LENGTH, dims[GOMP_DIM_WORKER]);
+  dims[GOMP_DIM_WORKER] = PTX_WORKER_LENGTH;
+  changed = true;
 }
 
-  /* Set defaults.  */
-  for (ix = 0; ix != GOMP_DIM_MAX; ix++)
-if (!adims[ix])
-  adims[ix] = integer_one_node;
-
-  /* Write results.  */
-  tree pos;
-  for (ix = 0, pos = dims; ix != GOMP_DIM_MAX; ix++, pos = TREE_CHAIN (pos))
-TREE_VALUE (pos) = adims[ix];
-
-  return dims;
+  return changed;
 }
 
 /* Return maximum dimension size, or zero for unbounded.  */
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi	(revision 226808)
+++ gcc/doc/tm.texi	(working copy)
@@ -5740,11 +5740,12 @@ usable.  In that case, the smaller the n
 to use it.
 @end deftypefn
 
-@deftypefn {Target Hook} tree TARGET_GOACC_VALIDATE_DIMS (tree, @var{tree})
+@deftypefn {Target Hook} bool TARGET_GOACC_VALIDATE_DIMS (tree, int @var{[]})
 This hook should check the launch dimensions provided.  It should fill
-in default values and verify non-defaults.  The