Patchwork [15/20] strip-mine with isl

login
register
mail settings
Submitter Sebastian Pop
Date Aug. 15, 2011, 7:12 a.m.
Message ID <1313392379-1525-15-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/110001/
State New
Headers show

Comments

Sebastian Pop - Aug. 15, 2011, 7:12 a.m.
---
 gcc/graphite-blocking.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
Sven Verdoolaege - Aug. 15, 2011, 7:39 a.m.
On Mon, Aug 15, 2011 at 02:12:54AM -0500, Sebastian Pop wrote:
> @@ -160,6 +182,14 @@ pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
>      ppl_delete_Linear_Expression (expr);
>      ppl_Polyhedron_add_constraint (res, new_cstr);
>      ppl_delete_Constraint (new_cstr);
> +
> +    {
> +      isl_dim *d = isl_map_get_dim (pbb->transformed);
> +      isl_constraint *c = isl_equality_alloc (d);
> +
> +      c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
> +      pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
> +    }
>    }
>  }

I'm not sure what the point is of introducing an extra dimension
fixed to zero, but it can be accomplished more easily using isl_map_fix_si.
Also, it may clarify the code if you first construct the transformation
and then apply it, like you do in the interchange.

skimo

Patch

diff --git a/gcc/graphite-blocking.c b/gcc/graphite-blocking.c
index 429b405..0741f82 100644
--- a/gcc/graphite-blocking.c
+++ b/gcc/graphite-blocking.c
@@ -27,6 +27,7 @@  along with GCC; see the file COPYING3.  If not see
 #include <isl/set.h>
 #include <isl/map.h>
 #include <isl/union_map.h>
+#include <isl/constraint.h>
 #include <cloog/cloog.h>
 #include <cloog/isl/domain.h>
 #endif
@@ -112,9 +113,11 @@  pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
 
   psct_add_scattering_dimension (pbb, strip);
   psct_add_scattering_dimension (pbb, strip + 1);
-
   ppl_Polyhedron_space_dimension (res, &dim);
 
+  pbb->transformed = isl_map_insert_dims (pbb->transformed, isl_dim_out,
+					  strip, 2);
+
   /* Lower bound of the striped loop.  */
   {
     ppl_Constraint_t new_cstr;
@@ -128,6 +131,15 @@  pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
     ppl_delete_Linear_Expression (expr);
     ppl_Polyhedron_add_constraint (res, new_cstr);
     ppl_delete_Constraint (new_cstr);
+
+    {
+      isl_dim *d = isl_map_get_dim (pbb->transformed);
+      isl_constraint *c = isl_inequality_alloc (d);
+
+      c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, -stride);
+      c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, 1);
+      pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
+    }
   }
 
   /* Upper bound of the striped loop.  */
@@ -144,6 +156,16 @@  pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
     ppl_delete_Linear_Expression (expr);
     ppl_Polyhedron_add_constraint (res, new_cstr);
     ppl_delete_Constraint (new_cstr);
+
+    {
+      isl_dim *d = isl_map_get_dim (pbb->transformed);
+      isl_constraint *c = isl_inequality_alloc (d);
+
+      c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip, stride);
+      c = isl_constraint_set_coefficient_si (c, isl_dim_out, iter, -1);
+      c = isl_constraint_set_constant_si (c, stride - 1);
+      pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
+    }
   }
 
   /* Static scheduling for ITER level.
@@ -160,6 +182,14 @@  pbb_strip_mine_time_depth (poly_bb_p pbb, int time_depth, int stride)
     ppl_delete_Linear_Expression (expr);
     ppl_Polyhedron_add_constraint (res, new_cstr);
     ppl_delete_Constraint (new_cstr);
+
+    {
+      isl_dim *d = isl_map_get_dim (pbb->transformed);
+      isl_constraint *c = isl_equality_alloc (d);
+
+      c = isl_constraint_set_coefficient_si (c, isl_dim_out, strip + 1, 1);
+      pbb->transformed = isl_map_add_constraint (pbb->transformed, c);
+    }
   }
 }