On 05/19/2011 06:52 PM, Sebastian Pop wrote:
I could loop at the internal name
of the variable, and check if it starts with graphite_IV.

I think this is a *very* bad idea, and unfortunately the graphite-opencl
code uses this strcmp technique to detect reductions, and that's why
the graphite-opencl code is broken right now.

Sebastian

Hello
There are two places in graphite-opencl where we use strcmp technique.
The first one is the detection of privatizable variables (opencl_private_var_name_p) and it can be eliminated by marking all zero dimensional arrays as private (see patch below).

The other occurrence of this technique is the detection of loop iterators in CLAST data structures. In this case we assume that every loop iterator called scat_<NUM> where NUM represents the depth of corresponding loop in current loop nest. Is it possible to use it here, or we should use another approach for detecting and comparing loop iterators for CLAST loops?

--
Alexey Kravets
kayr...@ispras.ru
	* graphite-opencl.c: Use zero_dim_array_p instead of
	graphite_artificial_array_p.

diff --git a/gcc/graphite-opencl.c b/gcc/graphite-opencl.c
index ea894ee..53704d2 100644
--- a/gcc/graphite-opencl.c
+++ b/gcc/graphite-opencl.c
@@ -330,42 +330,6 @@ zero_dim_array_p (tree var)
   return TREE_INT_CST_LOW (up_bound) == 0;
 }
 
-/* Check whether NAME is the name of the artificial array, which can be
-   privatized.  */
-
-static bool
-opencl_private_var_name_p (const char *name)
-{
-  static const char *general_reduction = "General_Reduction";
-  static const char *close_phi = "Close_Phi";
-  static const char *cross_bb = "Cross_BB_scalar_dependence";
-  static const char *commutative = "Commutative_Associative_Reduction";
-
-  if (!name)
-    return false;
-
-  return
-    ((strstr (name, general_reduction) == name)
-     || (strstr (name, close_phi) == name)
-     || (strstr (name, commutative) == name)
-     || (strstr (name, cross_bb) == name));
-}
-
-/* Check whether VAR is an artificial array, which can be privatized.  */
-
-static bool
-graphite_artificial_array_p (tree var)
-{
-  tree name;
-
-  if (TREE_CODE (var) != VAR_DECL
-      || !zero_dim_array_p (var)
-      || !(name = DECL_NAME (var)))
-    return false;
-
-  return opencl_private_var_name_p (IDENTIFIER_POINTER (name));
-}
-
 /* Get depth of type TYPE scalar (base) part.  */
 
 static int
@@ -393,7 +357,7 @@ opencl_data_create (tree var, tree size)
   opencl_data tmp = XNEW (struct opencl_data_def);
   tree type = TREE_TYPE (var);
 
-  tmp->can_be_private = graphite_artificial_array_p (var);
+  tmp->can_be_private = zero_dim_array_p (var);
   tmp->exact_object = var;
 
   tmp->supported = TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == SSA_NAME;

Reply via email to