add original schedule to scop
authorAbderrazek Zaafrani <a.zaafrani@samsung.com>
Sat, 7 Nov 2015 01:32:27 +0000 (01:32 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Sat, 7 Nov 2015 01:32:27 +0000 (01:32 +0000)
    * graphite-optimize-isl.c (optimize_isl): Call isl_union_map_is_equal.
    * graphite-poly.c (new_scop): Initialize original_schedule.
    (free_scop): Free original_schedule.
    * graphite-poly.h (struct scop): Add field original_schedule.
    * graphite-sese-to-poly.c (build_scop_original_schedule): New.
    (build_poly_scop): Call build_scop_original_schedule.

From-SVN: r229910

gcc/ChangeLog
gcc/graphite-optimize-isl.c
gcc/graphite-poly.c
gcc/graphite-poly.h
gcc/graphite-sese-to-poly.c

index bac7eb8..90fbe5f 100644 (file)
@@ -1,5 +1,14 @@
 2015-11-06  Abderrazek Zaafrani  <a.zaafrani@samsung.com>
 
+       * graphite-optimize-isl.c (optimize_isl): Call isl_union_map_is_equal.
+       * graphite-poly.c (new_scop): Initialize original_schedule.
+       (free_scop): Free original_schedule.
+       * graphite-poly.h (struct scop): Add field original_schedule.
+       * graphite-sese-to-poly.c (build_scop_original_schedule): New.
+       (build_poly_scop): Call build_scop_original_schedule.
+
+2015-11-06  Abderrazek Zaafrani  <a.zaafrani@samsung.com>
+
        * graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Remove.
        (build_pbb_minimal_scattering_polyhedrons): New.
        (build_scop_scattering): Remove.
index 0d85975..c09264b 100644 (file)
@@ -441,11 +441,23 @@ optimize_isl (scop_p scop)
 #else
   isl_union_map *schedule_map = get_schedule_map (schedule);
 #endif
-  apply_schedule_map_to_scop (scop, schedule_map);
 
-  isl_schedule_free (schedule);
-  isl_union_map_free (schedule_map);
-  return true;
+  if (isl_union_map_is_equal (scop->original_schedule, schedule_map))
+    {
+      if (dump_file && dump_flags)
+       fprintf (dump_file, "\nISL schedule same as original schedule\n");
+
+      isl_schedule_free (schedule);
+      isl_union_map_free (schedule_map);
+      return false;
+    }
+  else
+    {
+      apply_schedule_map_to_scop (scop, schedule_map);
+      isl_schedule_free (schedule);
+      isl_union_map_free (schedule_map);
+      return true;
+    }
 }
 
 #endif /* HAVE_isl */
index 2aa40c0..36c3061 100644 (file)
@@ -305,6 +305,7 @@ new_scop (edge entry, edge exit)
   scop->must_waw_no_source = NULL;
   scop->may_waw_no_source = NULL;
   scop_set_region (scop, region);
+  scop->original_schedule = NULL;
   scop->pbbs.create (3);
   scop->poly_scop_p = false;
   scop->drs.create (3);
@@ -341,6 +342,7 @@ free_scop (scop_p scop)
   isl_union_map_free (scop->may_waw);
   isl_union_map_free (scop->must_waw_no_source);
   isl_union_map_free (scop->may_waw_no_source);
+  isl_union_map_free (scop->original_schedule);
   XDELETE (scop);
 }
 
index 5298f85..b35431a 100644 (file)
@@ -436,6 +436,9 @@ struct scop
     *must_war, *may_war, *must_war_no_source, *may_war_no_source,
     *must_waw, *may_waw, *must_waw_no_source, *may_waw_no_source;
 
+  /* Original schedule of the SCoP.  */
+  isl_union_map *original_schedule;
+
   /* True when the scop has been converted to its polyhedral
      representation.  */
   bool poly_scop_p;
index 394a281..ba45199 100644 (file)
@@ -426,6 +426,55 @@ build_scop_minimal_scattering (scop_p scop)
   isl_aff_free (static_sched);
 }
 
+/* Build the original schedule showing the orginal order of execution
+   of statement instances.
+
+   The following example shows the original schedule:
+
+   for (i: ...)
+     {
+       for (j: ...)
+         {
+           A
+         }
+       B
+     }
+   C
+   for (i: ...)
+     {
+       D
+     }
+
+   Static schedules for A to D expressed in a union map:
+
+   { S_A[i0, i1] -> [i0, i1]; S_B[i0] -> [i0]; S_C[] -> []; S_9[i0] -> [i0] }
+
+*/
+
+static void
+build_scop_original_schedule (scop_p scop)
+{
+  isl_space *space = isl_set_get_space (scop->param_context);
+  isl_union_map *res = isl_union_map_empty (space);
+
+  int i;
+  poly_bb_p pbb;
+  FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
+    {
+      int nb_dimensions = isl_set_dim (pbb->domain, isl_dim_set);
+      isl_space *dc = isl_set_get_space (pbb->domain);
+      isl_space *dm = isl_space_add_dims (isl_space_from_domain (dc),
+                                         isl_dim_out, nb_dimensions);
+      isl_map *mp = isl_map_universe (dm);
+      for (int i = 0; i < nb_dimensions; i++)
+       mp = isl_map_equate (mp, isl_dim_in, i, isl_dim_out, i);
+
+      res = isl_union_map_add_map (res, mp);
+    }
+  scop->original_schedule = res;
+}
+
+
 static isl_pw_aff *extract_affine (scop_p, tree, __isl_take isl_space *space);
 
 /* Extract an affine expression from the chain of recurrence E.  */
@@ -1799,6 +1848,7 @@ build_poly_scop (scop_p scop)
 
   build_scop_drs (scop);
   build_scop_minimal_scattering (scop);
+  build_scop_original_schedule (scop);
 
   /* This SCoP has been translated to the polyhedral
      representation.  */