graphite-dependences.c (pddr_original_scattering): New.
authorSebastian Pop <sebastian.pop@amd.com>
Fri, 28 Aug 2009 20:31:28 +0000 (20:31 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 28 Aug 2009 20:31:28 +0000 (20:31 +0000)
2009-08-28  Sebastian Pop  <sebastian.pop@amd.com>

* graphite-dependences.c (pddr_original_scattering): New.
(graphite_legal_transform_dr): Call pddr_original_scattering.
(dot_deps_1): New.
(dot_deps): New.
* graphite-dependences.h (dot_deps): Declared.
* graphite-poly.c (new_poly_dr): Initialize PDR_ID.
(print_pdr): Print PDR_ID.
* graphite-poly.h (struct poly_dr): Add field id.
(PDR_ID): New.
(pbb_index): New.
* graphite-scop-detection.c (dot_all_scops_1): Cleanup comment.

From-SVN: r151183

gcc/ChangeLog
gcc/ChangeLog.graphite
gcc/graphite-dependences.c
gcc/graphite-dependences.h
gcc/graphite-poly.c
gcc/graphite-poly.h
gcc/graphite-scop-detection.c

index 9e717e05ed561c7d2977fbdf781717e1b36c0f59..d7b4369d3c6e60f9d190c80ef8e918adaed3234d 100644 (file)
@@ -1,3 +1,17 @@
+2009-08-28  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * graphite-dependences.c (pddr_original_scattering): New.
+       (graphite_legal_transform_dr): Call pddr_original_scattering.
+       (dot_deps_1): New.
+       (dot_deps): New.
+       * graphite-dependences.h (dot_deps): Declared.
+       * graphite-poly.c (new_poly_dr): Initialize PDR_ID.
+       (print_pdr): Print PDR_ID.
+       * graphite-poly.h (struct poly_dr): Add field id.
+       (PDR_ID): New.
+       (pbb_index): New.
+       * graphite-scop-detection.c (dot_all_scops_1): Cleanup comment.
+
 2009-08-28  Sebastian Pop  <sebastian.pop@amd.com>
 
        * graphite-dependences.c (graphite_carried_dependence_level_k): Do
index a2620d35e68f66b4d95ff4faf888120693d88346..495e9d50485478a2cdc53bd0adb2cff5e5cc6bba 100644 (file)
@@ -1,3 +1,17 @@
+2009-08-25  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * graphite-dependences.c (pddr_original_scattering): New.
+       (graphite_legal_transform_dr): Call pddr_original_scattering.
+       (dot_deps_1): New.
+       (dot_deps): New.
+       * graphite-dependences.h (dot_deps): Declared.
+       * graphite-poly.c (new_poly_dr): Initialize PDR_ID.
+       (print_pdr): Print PDR_ID.
+       * graphite-poly.h (struct poly_dr): Add field id.
+       (PDR_ID): New.
+       (pbb_index): New.
+       * graphite-scop-detection.c (dot_all_scops_1): Cleanup comment.
+
 2009-08-22  Sebastian Pop  <sebastian.pop@amd.com>
 
        * graphite-dependences.c (graphite_carried_dependence_level_k): Do
index 585e072f69cc266023fcf53e29294e844b56762c..b68ccee7a9690e88279788dc4e0fcc0ee9362448 100644 (file)
@@ -494,6 +494,30 @@ dependence_polyhedron (poly_bb_p pbb1, poly_bb_p pbb2,
   return res;
 }
 
+/* Returns the PDDR corresponding to the original schedule, or NULL if
+   the dependence relation is empty.  */
+
+static poly_ddr_p
+pddr_original_scattering (poly_bb_p pbb1, poly_bb_p pbb2,
+                         poly_dr_p pdr1, poly_dr_p pdr2)
+{
+  poly_ddr_p pddr;
+  ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
+  ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
+  ppl_Polyhedron_t so1 = PBB_ORIGINAL_SCATTERING (pbb1);
+  ppl_Polyhedron_t so2 = PBB_ORIGINAL_SCATTERING (pbb2);
+
+  if (PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2))
+    return NULL;
+
+  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
+                               true, true);
+  if (pddr_is_empty (pddr))
+    return NULL;
+
+  return pddr;
+}
+
 /* Returns true when the PBB_TRANSFORMED_SCATTERING functions of PBB1
    and PBB2 respect the data dependences of PBB_ORIGINAL_SCATTERING
    functions.  */
@@ -509,20 +533,11 @@ graphite_legal_transform_dr (poly_bb_p pbb1, poly_bb_p pbb2,
   ppl_dimension_type pdim;
   bool is_empty_p;
   poly_ddr_p pddr;
-
   ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1);
   ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2);
-  ppl_Polyhedron_t so1 = PBB_ORIGINAL_SCATTERING (pbb1);
-  ppl_Polyhedron_t so2 = PBB_ORIGINAL_SCATTERING (pbb2);
-  graphite_dim_t sdim1 = PDR_NB_SUBSCRIPTS (pdr1) + 1;
-  graphite_dim_t sdim2 = PDR_NB_SUBSCRIPTS (pdr2) + 1;
 
-  if (sdim1 != sdim2)
-    return true;
-
-  pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
-                               true, true);
-  if (pddr_is_empty (pddr))
+  pddr = pddr_original_scattering (pbb1, pbb2, pdr1, pdr2);
+  if (!pddr)
     return true;
 
   po = PDDR_DDP (pddr);
@@ -679,8 +694,6 @@ graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
   ppl_Polyhedron_t so2 = PBB_TRANSFORMED_SCATTERING (pbb2);
   ppl_Pointset_Powerset_C_Polyhedron_t po;
   ppl_Pointset_Powerset_C_Polyhedron_t eqpp;
-  graphite_dim_t sdim1 = PDR_NB_SUBSCRIPTS (pdr1) + 1;
-  graphite_dim_t sdim2 = PDR_NB_SUBSCRIPTS (pdr2) + 1;
   graphite_dim_t tdim1 = pbb_nb_scattering_transform (pbb1);
   graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1);
   ppl_dimension_type dim;
@@ -691,7 +704,7 @@ graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2,
       || !poly_drs_may_alias_p (pdr1, pdr2))
     return false;
 
-  if (sdim1 != sdim2)
+  if (PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2))
     return true;
 
   pddr = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2,
@@ -733,4 +746,50 @@ dependency_between_pbbs_p (poly_bb_p pbb1, poly_bb_p pbb2, int level)
   return false;
 }
 
+/* Pretty print to FILE all the data dependences of SCoP in DOT
+   format.  */
+
+static void
+dot_deps_1 (FILE *file, scop_p scop)
+{
+  int i, j, k, l;
+  poly_bb_p pbb1, pbb2;
+  poly_dr_p pdr1, pdr2;
+
+  fputs ("digraph all {\n", file);
+
+  for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb1); i++)
+    for (j = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), j, pbb2); j++)
+      for (k = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb1), k, pdr1); k++)
+       for (l = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb2), l, pdr2); l++)
+         if (pddr_original_scattering (pbb1, pbb2, pdr1, pdr2))
+           fprintf (file, "S%d_D%d -> S%d_D%d\n",
+                    pbb_index (pbb1), PDR_ID (pdr1),
+                    pbb_index (pbb2), PDR_ID (pdr2));
+
+  fputs ("}\n\n", file);
+}
+
+/* Display all the data dependences in SCoP using dotty.  */
+
+void
+dot_deps (scop_p scop)
+{
+  /* When debugging, enable the following code.  This cannot be used
+     in production compilers because it calls "system".  */
+#if 1
+  int x;
+  FILE *stream = fopen ("/tmp/scopdeps.dot", "w");
+  gcc_assert (stream);
+
+  dot_deps_1 (stream, scop);
+  fclose (stream);
+
+  x = system ("dotty /tmp/scopdeps.dot");
+#else
+  dot_deps_1 (stderr, scop);
+#endif
+}
+
+
 #endif
index 267d80ba9dd554aecdde5b8eaac16801e6986885..a668d1c1565916e6ba2f70d438ad33702cfd8ed5 100644 (file)
@@ -50,5 +50,6 @@ typedef struct poly_ddr
 extern int eq_poly_ddr_p (const void *, const void *);
 extern hashval_t hash_poly_ddr_p (const void *);
 extern void free_poly_ddr (void *);
+extern void dot_deps (scop_p);
 
 #endif
index 3bc50d48e7b6891e2f5d014e1d4ecaea3fe2b912..835d6a87104b16ac380d060bd59c918ec11c2654 100644 (file)
@@ -273,7 +273,9 @@ new_poly_dr (poly_bb_p pbb,
             enum POLY_DR_TYPE type, void *cdr, int nb_subscripts)
 {
   poly_dr_p pdr = XNEW (struct poly_dr);
+  static int id = 0;
 
+  PDR_ID (pdr) = id++;
   PDR_PBB (pdr) = pbb;
   PDR_ACCESSES (pdr) = accesses;
   PDR_TYPE (pdr) = type;
@@ -361,7 +363,7 @@ print_pdr_access_layout (FILE *file, poly_dr_p pdr)
 void
 print_pdr (FILE *file, poly_dr_p pdr)
 {
-  fprintf (file, "pdr (");
+  fprintf (file, "pdr_%d (", PDR_ID (pdr));
 
   switch (PDR_TYPE (pdr))
     {
index 793c36225ed7ec2c900692c99276fe0fbebec8c2..a42e2429e0efdf1565426cfba5ae1665485afefd 100644 (file)
@@ -53,6 +53,9 @@ enum POLY_DR_TYPE
 
 struct poly_dr
 {
+  /* An identifier for this PDR.  */
+  int id;
+
   /* A pointer to compiler's data reference description.  */
   void *compiler_dr;
 
@@ -130,9 +133,10 @@ struct poly_dr
   ppl_Pointset_Powerset_C_Polyhedron_t accesses;
 
   /* The number of subscripts.  */
-  graphite_dim_t nb_subscripts; 
+  graphite_dim_t nb_subscripts;
 };
 
+#define PDR_ID(PDR) (PDR->id)
 #define PDR_CDR(PDR) (PDR->compiler_dr)
 #define PDR_PBB(PDR) (PDR->pbb)
 #define PDR_TYPE(PDR) (PDR->type)
@@ -304,9 +308,18 @@ extern bool scop_do_interchange (scop_p);
 extern bool scop_do_strip_mine (scop_p);
 extern void pbb_number_of_iterations (poly_bb_p, graphite_dim_t, Value);
 
+/* The index of the PBB.  */
+
+static inline int
+pbb_index (poly_bb_p pbb)
+{
+  return GBB_BB (PBB_BLACK_BOX (pbb))->index;
+}
+
 /* The scop that contains the PDR.  */
 
-static inline scop_p pdr_scop (poly_dr_p pdr)
+static inline scop_p
+pdr_scop (poly_dr_p pdr)
 {
   return PBB_SCOP (PDR_PBB (pdr));
 }
index 60cb95ba7243edd4a9597473024443cc2742d349..9fdf6b373e53a787f1204a73062558e7bf064d3b 100644 (file)
@@ -1445,12 +1445,15 @@ build_scops (VEC (scop_p, heap) **scops)
             VEC_length (scop_p, *scops));
 }
 
-/* Pretty print all SCoPs in DOT format and mark them with different colors.
-   If there are not enough colors, paint later SCoPs gray.
+/* Pretty print to FILE all the SCoPs in DOT format and mark them with
+   different colors.  If there are not enough colors, paint the
+   remaining SCoPs in gray.
+
    Special nodes:
-   - "*" after the node number: entry of a SCoP,
-   - "#" after the node number: exit of a SCoP,
-   - "()" entry or exit not part of SCoP.  */
+   - "*" after the node number denotes the entry of a SCoP,
+   - "#" after the node number denotes the exit of a SCoP,
+   - "()" around the node number denotes the entry or the
+     exit nodes of the SCOP.  These are not part of SCoP.  */
 
 static void
 dot_all_scops_1 (FILE *file, VEC (scop_p, heap) *scops)