]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
attach schedule tree to the scop
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Dec 2015 23:40:06 +0000 (23:40 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Dec 2015 23:40:06 +0000 (23:40 +0000)
we used to translate the just computed schedule tree into a union_map,
and then in the code generation it would be translated back to a schedule tree
just before generating AST code.

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

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

index 95e96561c2d8e74952a0cbf4f6c007834e5ca495..d0d4d677347dac92e68d2f541398f463d7ccf3f3 100644 (file)
@@ -1,3 +1,15 @@
+2015-12-16  Abderrazek Zaafrani  <a.zaafrani@samsung.com>
+
+       * graphite-isl-ast-to-gimple.c: Include isl/schedule_node.h.
+       (set_separate_option): New.
+       (translate_isl_ast_to_gimple::set_options_for_schedule_tree): New.
+       (translate_isl_ast_to_gimple::scop_to_isl_ast): Use scop->schedule.
+       * graphite-optimize-isl.c (optimize_isl): Set scop->schedule, do not
+       free the computed schedule tree.
+       * graphite-poly.c (new_scop): Initialize scop->schedule.
+       * graphite.h: Include isl/schedule.h.
+       (struct scop): Add field schedule.
+
 2015-12-16  Nathan Sidwell  <nathan@acm.org>
 
        * ipa-visibility.c (can_replace_by_local_alias): Make static,
index b392766a27f4cb4aff5cd45606eb4ef79ce9e98d..0043bf44f34253dc35c256c6a88b44239b1bd2f2 100644 (file)
@@ -61,6 +61,9 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/union_map.h>
 #include <isl/ast_build.h>
 #include <isl/val_gmp.h>
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+#include <isl/schedule_node.h>
+#endif
 
 #include "graphite.h"
 
@@ -125,6 +128,29 @@ void ivs_params_clear (ivs_params &ip)
     }
 }
 
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+
+/* Set the "separate" option for the schedule node.  */
+
+static __isl_give isl_schedule_node *
+set_separate_option (__isl_take isl_schedule_node *node, void *user)
+{
+  if (user)
+    return node;
+
+  if (isl_schedule_node_get_type (node) != isl_schedule_node_band)
+    return node;
+
+  /* Set the "separate" option unless it is set earlier to another option.  */
+  if (isl_schedule_node_band_member_get_ast_loop_type (node, 0)
+      == isl_ast_loop_default)
+    return isl_schedule_node_band_member_set_ast_loop_type
+      (node, 0, isl_ast_loop_separate);
+
+  return node;
+}
+#endif
+
 class translate_isl_ast_to_gimple
 {
  public:
@@ -290,6 +316,14 @@ class translate_isl_ast_to_gimple
 
   __isl_give isl_union_map *generate_isl_schedule (scop_p scop);
 
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+  /* Set the "separate" option for all schedules.  This helps reducing control
+     overhead.  */
+
+  __isl_give isl_schedule *
+    set_options_for_schedule_tree (__isl_take isl_schedule *schedule);
+#endif
+
   /* Set the separate option for all dimensions.
      This helps to reduce control overhead.  */
 
@@ -3163,6 +3197,19 @@ ast_build_before_for (__isl_keep isl_ast_build *build, void *user)
   return id;
 }
 
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+/* Set the separate option for all schedules.  This helps reducing control
+   overhead.  */
+
+__isl_give isl_schedule *
+translate_isl_ast_to_gimple::set_options_for_schedule_tree
+(__isl_take isl_schedule *schedule)
+{
+  return isl_schedule_map_schedule_node_bottom_up
+    (schedule, set_separate_option, NULL);
+}
+#endif
+
 /* Set the separate option for all dimensions.
    This helps to reduce control overhead.  */
 
@@ -3187,6 +3234,7 @@ translate_isl_ast_to_gimple::set_options (__isl_take isl_ast_build *control,
 __isl_give isl_ast_node *
 translate_isl_ast_to_gimple::scop_to_isl_ast (scop_p scop, ivs_params &ip)
 {
+  isl_ast_node *ast_isl = NULL;
   /* Generate loop upper bounds that consist of the current loop iterator, an
      operator (< or <=) and an expression not involving the iterator.  If this
      option is not set, then the current loop iterator may appear several times
@@ -3204,8 +3252,21 @@ translate_isl_ast_to_gimple::scop_to_isl_ast (scop_p scop, ivs_params &ip)
        isl_ast_build_set_before_each_for (context_isl, ast_build_before_for,
                                           dependence);
     }
-  isl_ast_node *ast_isl = isl_ast_build_ast_from_schedule (context_isl,
-                                                          schedule_isl);
+
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+  if (scop->schedule)
+    {
+      scop->schedule = set_options_for_schedule_tree (scop->schedule);
+      ast_isl = isl_ast_build_node_from_schedule (context_isl, scop->schedule);
+      isl_union_map_free(schedule_isl);
+    }
+  else
+    ast_isl = isl_ast_build_ast_from_schedule (context_isl, schedule_isl);
+#else
+  ast_isl = isl_ast_build_ast_from_schedule (context_isl, schedule_isl);
+  isl_schedule_free (scop->schedule);
+#endif
+
   isl_ast_build_free (context_isl);
   return ast_isl;
 }
index f5cb5c45dccb6cc073c7f1cef19a39d1b6cafa30..1d9449b5ca99661c29aa5f335837a1ec51c88cbf 100644 (file)
@@ -420,6 +420,10 @@ optimize_isl (scop_p scop)
       return false;
     }
 
+  /* Attach the schedule to scop so that it can be used in code generation.
+     schedule freeing will occur in code generation.  */
+  scop->schedule = schedule;
+
 #ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
   /* isl 0.15 or later.  */
   isl_union_map *schedule_map = get_schedule_map_st (schedule);
@@ -428,7 +432,6 @@ optimize_isl (scop_p scop)
 #endif
   apply_schedule_map_to_scop (scop, schedule_map);
 
-  isl_schedule_free (schedule);
   isl_union_map_free (schedule_map);
   return true;
 }
index 00d674cd7c9ef4b62eea9a9d2167eac98063822e..1f50ff8c6c718761c82b030523e661b6862e3729 100644 (file)
@@ -295,9 +295,9 @@ scop_p
 new_scop (edge entry, edge exit)
 {
   sese_info_p region = new_sese_info (entry, exit);
-  scop_p s;
-  s = XNEW (struct scop);
+  scop_p s = XNEW (struct scop);
 
+  s->schedule = NULL;
   s->param_context = NULL;
   scop_set_region (s, region);
   s->pbbs.create (3);
index ba91dfa4d251960752e29ffef08e4b9261e5e585..929c399d593955d4e73c0b29dc0ca24b5f26632e 100644 (file)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_GRAPHITE_POLY_H
 
 #include "sese.h"
+#include <isl/schedule.h>
 
 #ifndef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
   /* isl 0.14.  */
@@ -411,6 +412,9 @@ struct scop
   /* The context used internally by ISL.  */
   isl_ctx *isl_context;
 
+  /* SCoP final schedule.  */
+  isl_schedule *schedule;
+
   /* The data dependence relation among the data references in this scop.  */
   isl_union_map *dependence;
 };