OSDN Git Service

Restore original scattering when the transform is not legal.
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Aug 2009 14:23:01 +0000 (14:23 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Aug 2009 14:23:01 +0000 (14:23 +0000)
2009-08-05  Sebastian Pop  <sebastian.pop@amd.com>

* graphite-blocking.c (scop_do_strip_mine): Call store_scattering.
Early return without analyzing the data dependences if no
transform has been done.  Call restore_scattering if the transform
is not legal.
(graphite-interchange.c): Same.
* graphite-poly.c (print_scattering_function): Test for PBB_TRANSFORMED.
(graphite_read_transforms): Initialize PBB_TRANSFORMED.
(apply_poly_transforms): Do not gcc_assert that
the transform is legal.
(new_poly_bb): Initialize PBB_TRANSFORMED, PBB_SAVED, and PBB_ORIGINAL.
Do not initialize PBB_NB_SCATTERING_TRANSFORM, PBB_NB_LOCAL_VARIABLES,
PBB_TRANSFORMED_SCATTERING, and PBB_ORIGINAL_SCATTERING.
(free_poly_dr): Free PBB_TRANSFORMED, PBB_SAVED, and PBB_ORIGINAL.
* graphite-poly.h (struct poly_scattering): New.
(struct poly_bb): Add original, transformed, and saved fields.
Remove transformed_scattering, original_scattering, nb_local_variables,
and nb_scattering_transform fields.
(PBB_ORIGINAL, PBB_TRANSFORMED, PBB_SAVED): New.
(poly_scattering_new): New.
(poly_scattering_free): New.
(poly_scattering_copy): New.
(store_scattering_pbb): New.
(store_scattering): New.
(restore_scattering_pbb): New.
(restore_scattering): New.
* graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons):
Initialize PBB_TRANSFORMED and PBB_ORIGINAL.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150686 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ChangeLog.graphite
gcc/graphite-blocking.c
gcc/graphite-interchange.c
gcc/graphite-poly.c
gcc/graphite-poly.h
gcc/graphite-sese-to-poly.c

index e679ad3..60a0cc8 100644 (file)
@@ -1,5 +1,35 @@
 2009-08-12  Sebastian Pop  <sebastian.pop@amd.com>
 
+       * graphite-blocking.c (scop_do_strip_mine): Call store_scattering.
+       Early return without analyzing the data dependences if no
+       transform has been done.  Call restore_scattering if the transform
+       is not legal.
+       (graphite-interchange.c): Same.
+       * graphite-poly.c (print_scattering_function): Test for PBB_TRANSFORMED.
+       (graphite_read_transforms): Initialize PBB_TRANSFORMED.
+       (apply_poly_transforms): Do not gcc_assert that
+       the transform is legal.
+       (new_poly_bb): Initialize PBB_TRANSFORMED, PBB_SAVED, and PBB_ORIGINAL.
+       Do not initialize PBB_NB_SCATTERING_TRANSFORM, PBB_NB_LOCAL_VARIABLES,
+       PBB_TRANSFORMED_SCATTERING, and PBB_ORIGINAL_SCATTERING.
+       (free_poly_dr): Free PBB_TRANSFORMED, PBB_SAVED, and PBB_ORIGINAL.
+       * graphite-poly.h (struct poly_scattering): New.
+       (struct poly_bb): Add original, transformed, and saved fields.
+       Remove transformed_scattering, original_scattering, nb_local_variables,
+       and nb_scattering_transform fields.
+       (PBB_ORIGINAL, PBB_TRANSFORMED, PBB_SAVED): New.
+       (poly_scattering_new): New.
+       (poly_scattering_free): New.
+       (poly_scattering_copy): New.
+       (store_scattering_pbb): New.
+       (store_scattering): New.
+       (restore_scattering_pbb): New.
+       (restore_scattering): New.
+       * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons):
+       Initialize PBB_TRANSFORMED and PBB_ORIGINAL.
+
+2009-08-12  Sebastian Pop  <sebastian.pop@amd.com>
+
        * graphite-poly.c (print_pbb): Add parentheses in the pretty print.
        (print_scop): Same.
 
index 19027ea..38b22e9 100644 (file)
@@ -1,5 +1,35 @@
 2009-08-05  Sebastian Pop  <sebastian.pop@amd.com>
 
+       * graphite-blocking.c (scop_do_strip_mine): Call store_scattering.
+       Early return without analyzing the data dependences if no
+       transform has been done.  Call restore_scattering if the transform
+       is not legal.
+       (graphite-interchange.c): Same.
+       * graphite-poly.c (print_scattering_function): Test for PBB_TRANSFORMED.
+       (graphite_read_transforms): Initialize PBB_TRANSFORMED.
+       (apply_poly_transforms): Do not gcc_assert that
+       the transform is legal.
+       (new_poly_bb): Initialize PBB_TRANSFORMED, PBB_SAVED, and PBB_ORIGINAL.
+       Do not initialize PBB_NB_SCATTERING_TRANSFORM, PBB_NB_LOCAL_VARIABLES,
+       PBB_TRANSFORMED_SCATTERING, and PBB_ORIGINAL_SCATTERING.
+       (free_poly_dr): Free PBB_TRANSFORMED, PBB_SAVED, and PBB_ORIGINAL.
+       * graphite-poly.h (struct poly_scattering): New.
+       (struct poly_bb): Add original, transformed, and saved fields.
+       Remove transformed_scattering, original_scattering, nb_local_variables,
+       and nb_scattering_transform fields.
+       (PBB_ORIGINAL, PBB_TRANSFORMED, PBB_SAVED): New.
+       (poly_scattering_new): New.
+       (poly_scattering_free): New.
+       (poly_scattering_copy): New.
+       (store_scattering_pbb): New.
+       (store_scattering): New.
+       (restore_scattering_pbb): New.
+       (restore_scattering): New.
+       * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons):
+       Initialize PBB_TRANSFORMED and PBB_ORIGINAL.
+       
+2009-08-05  Sebastian Pop  <sebastian.pop@amd.com>
+
        * graphite-poly.c (print_pbb): Add parentheses in the pretty print.
        (print_scop): Same.
 
index 4961c7f..45f3bc6 100644 (file)
@@ -201,10 +201,21 @@ scop_do_strip_mine (scop_p scop)
   int i;
   bool transform_done = false;
 
+  store_scattering (scop);
+
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
     transform_done |= pbb_do_strip_mine (pbb);
 
-  return transform_done;
+  if (!transform_done)
+    return false;
+
+  if (!graphite_legal_transform (scop))
+    {
+      restore_scattering (scop);
+      return false;
+    }
+
+  return true;
 }
 
 #endif
index 4639afe..785be70 100644 (file)
@@ -388,9 +388,20 @@ scop_do_interchange (scop_p scop)
   poly_bb_p pbb;
   bool transform_done = false;
 
+  store_scattering (scop);
+
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
     transform_done |= pbb_do_interchange (pbb, scop);
 
+  if (!transform_done)
+    return false;
+
+  if (!graphite_legal_transform (scop))
+    {
+      restore_scattering (scop);
+      return false;
+    }
+
   return transform_done;
 }
 
index 6d24cbd..d06da75 100644 (file)
@@ -142,7 +142,7 @@ print_scattering_function (FILE *file, poly_bb_p pbb)
 {
   graphite_dim_t i;
 
-  if (!PBB_TRANSFORMED_SCATTERING (pbb))
+  if (!PBB_TRANSFORMED (pbb))
     return;
 
   fprintf (file, "scattering bb_%d (\n", GBB_BB (PBB_BLACK_BOX (pbb))->index);
@@ -255,16 +255,10 @@ apply_poly_transforms (scop_p scop)
     gcc_unreachable (); /* Not yet supported.  */
 
   if (flag_loop_strip_mine)
-    {
-      transform_done |= scop_do_strip_mine (scop);
-      gcc_assert (graphite_legal_transform (scop));
-    }
+    transform_done |= scop_do_strip_mine (scop);
 
   if (flag_loop_interchange)
-    {
-      transform_done |= scop_do_interchange (scop);
-      gcc_assert (graphite_legal_transform (scop));
-    }
+    transform_done |= scop_do_interchange (scop);
 
   return transform_done;
 }
@@ -309,11 +303,10 @@ new_poly_bb (scop_p scop, void *black_box)
   PBB_DOMAIN (pbb) = NULL;
   PBB_SCOP (pbb) = scop;
   pbb_set_black_box (pbb, black_box);
-  PBB_TRANSFORMED_SCATTERING (pbb) = NULL;
-  PBB_ORIGINAL_SCATTERING (pbb) = NULL;
+  PBB_TRANSFORMED (pbb) = NULL;
+  PBB_SAVED (pbb) = NULL;
+  PBB_ORIGINAL (pbb) = NULL;
   PBB_DRS (pbb) = VEC_alloc (poly_dr_p, heap, 3);
-  PBB_NB_SCATTERING_TRANSFORM (pbb) = 0;
-  PBB_NB_LOCAL_VARIABLES (pbb) = 0;
   VEC_safe_push (poly_bb_p, heap, SCOP_BBS (scop), pbb);
 }
 
@@ -327,11 +320,14 @@ free_poly_bb (poly_bb_p pbb)
 
   ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb));
 
-  if (PBB_TRANSFORMED_SCATTERING (pbb))
-    ppl_delete_Polyhedron (PBB_TRANSFORMED_SCATTERING (pbb));
+  if (PBB_TRANSFORMED (pbb))
+    poly_scattering_free (PBB_TRANSFORMED (pbb));
+
+  if (PBB_SAVED (pbb))
+    poly_scattering_free (PBB_SAVED (pbb));
 
-  if (PBB_ORIGINAL_SCATTERING (pbb))
-    ppl_delete_Polyhedron (PBB_ORIGINAL_SCATTERING (pbb));
+  if (PBB_ORIGINAL (pbb))
+    poly_scattering_free (PBB_ORIGINAL (pbb));
 
   if (PBB_DRS (pbb))
     for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++)
index 83d5fca..28fca70 100644 (file)
@@ -227,6 +227,20 @@ pdr_parameter_dim (poly_dr_p pdr, graphite_dim_t param)
   return pbb_dim_iter_domain (pbb) + param;
 }
 
+typedef struct poly_scattering *poly_scattering_p;
+
+struct poly_scattering
+{
+  /* The scattering function containing the transformations.  */
+  ppl_Polyhedron_t scattering;
+
+  /* The number of local variables.  */
+  int nb_local_variables;
+
+  /* The number of scattering dimensions.  */
+  int nb_scattering;
+};
+
 /* POLY_BB represents a blackbox in the polyhedral model.  */
 
 struct poly_bb
@@ -260,28 +274,27 @@ struct poly_bb
   /* The data references we access.  */
   VEC (poly_dr_p, heap) *drs;
 
-  /* The scattering function containing the transformations.  */
-  ppl_Polyhedron_t transformed_scattering;
-
+  /* The original scattering.  */
+  poly_scattering_p original;
 
-  /* The original scattering function.  */
-  ppl_Polyhedron_t original_scattering;
-
-  /* The number of local variables.  */
-  int nb_local_variables;
+  /* The transformed scattering.  */
+  poly_scattering_p transformed;
 
-  /* The number of scattering dimensions in the TRANSFORMED scattering.  */
-  int nb_scattering_transform;
+  /* A copy of the transformed scattering.  */
+  poly_scattering_p saved;
 };
 
 #define PBB_BLACK_BOX(PBB) ((gimple_bb_p) PBB->black_box)
 #define PBB_SCOP(PBB) (PBB->scop)
 #define PBB_DOMAIN(PBB) (PBB->domain)
 #define PBB_DRS(PBB) (PBB->drs)
-#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB->transformed_scattering)
-#define PBB_ORIGINAL_SCATTERING(PBB) (PBB->original_scattering)
-#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->nb_local_variables)
-#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->nb_scattering_transform)
+#define PBB_ORIGINAL(PBB) (PBB->original)
+#define PBB_ORIGINAL_SCATTERING(PBB) (PBB->original->scattering)
+#define PBB_TRANSFORMED(PBB) (PBB->transformed)
+#define PBB_TRANSFORMED_SCATTERING(PBB) (PBB->transformed->scattering)
+#define PBB_SAVED(PBB) (PBB->saved)
+#define PBB_NB_LOCAL_VARIABLES(PBB) (PBB->transformed->nb_local_variables)
+#define PBB_NB_SCATTERING_TRANSFORM(PBB) (PBB->transformed->nb_scattering)
 
 extern void new_poly_bb (scop_p, void *);
 extern void free_poly_bb (poly_bb_p);
@@ -578,4 +591,87 @@ scop_set_nb_params (scop_p scop, graphite_dim_t nb_params)
   scop->nb_params = nb_params;
 }
 
+/* Allocates a new empty poly_scattering structure.  */
+
+static inline poly_scattering_p
+poly_scattering_new (void)
+{
+  poly_scattering_p res = XNEW (struct poly_scattering);
+
+  res->scattering = NULL;
+  res->nb_local_variables = 0;
+  res->nb_scattering = 0;
+  return res;
+}
+
+/* Free a poly_scattering structure.  */
+
+static inline void
+poly_scattering_free (poly_scattering_p s)
+{
+  ppl_delete_Polyhedron (s->scattering);
+  free (s);
+}
+
+/* Copies S and return a new scattering.  */
+
+static inline poly_scattering_p
+poly_scattering_copy (poly_scattering_p s)
+{
+  poly_scattering_p res = poly_scattering_new ();
+
+  ppl_new_C_Polyhedron_from_C_Polyhedron (&(res->scattering), s->scattering);
+  res->nb_local_variables = s->nb_local_variables;
+  res->nb_scattering = s->nb_scattering;
+  return res;
+}
+
+/* Saves the transformed scattering of PBB.  */
+
+static inline void
+store_scattering_pbb (poly_bb_p pbb)
+{
+  gcc_assert (PBB_TRANSFORMED (pbb));
+
+  if (PBB_SAVED (pbb))
+    poly_scattering_free (PBB_SAVED (pbb));
+
+  PBB_SAVED (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb));
+}
+
+/* Saves the scattering for all the pbbs in the SCOP.  */
+
+static inline void
+store_scattering (scop_p scop)
+{
+  int i;
+  poly_bb_p pbb;
+
+  for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
+    store_scattering_pbb (pbb);
+}
+
+/* Restores the scattering of PBB.  */
+
+static inline void
+restore_scattering_pbb (poly_bb_p pbb)
+{
+  gcc_assert (PBB_SAVED (pbb));
+
+  poly_scattering_free (PBB_TRANSFORMED (pbb));
+  PBB_TRANSFORMED (pbb) = poly_scattering_copy (PBB_SAVED (pbb));
+}
+
+/* Restores the scattering for all the pbbs in the SCOP.  */
+
+static inline void
+restore_scattering (scop_p scop)
+{
+  int i;
+  poly_bb_p pbb;
+
+  for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
+    restore_scattering_pbb (pbb);
+}
+
 #endif
index 4ed7ffc..6204ec8 100644 (file)
@@ -498,6 +498,7 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
 
   value_init (v);
   ppl_new_Coefficient (&c);
+  PBB_TRANSFORMED (pbb) = poly_scattering_new ();
   ppl_new_C_Polyhedron_from_space_dimension
     (&PBB_TRANSFORMED_SCATTERING (pbb), dim, 0);
 
@@ -543,8 +544,7 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
   value_clear (v);
   ppl_delete_Coefficient (c);
 
-  ppl_new_C_Polyhedron_from_C_Polyhedron (&PBB_ORIGINAL_SCATTERING (pbb),
-                                         PBB_TRANSFORMED_SCATTERING (pbb));
+  PBB_ORIGINAL (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb));
 }
 
 /* Build for BB the static schedule.