summaryrefslogtreecommitdiff
path: root/gcc/graphite-optimize-isl.c
diff options
context:
space:
mode:
authorAbderrazek Zaafrani <a.zaafrani@samsung.com>2015-10-27 15:58:05 +0000
committerSebastian Pop <spop@gcc.gnu.org>2015-10-27 15:58:05 +0000
commit5affe17f859a0857b9d9c7c638f1e4e3939d1172 (patch)
tree704eb392cf7852a349580c7e7df9f4a2c6ea12bd /gcc/graphite-optimize-isl.c
parent55015e590fc5f020107c467ae62166f5ec10a52b (diff)
isl schedule tree
Use isl_schedule_node instead of isl_band_list for isl-0.15. Passes regtest and bootstrap for isl-0.15 and isl-0.12.2 on x86_64-linux. gcc/ChangeLog: * graphite-optimize-isl.c (get_schedule_for_node_st): New callback function to schedule based on isl_schedule_node. (get_schedule_map_st): New schedule optimizer based on isl_schedule_node. (scop_get_domains): New. Return the isl_union_set containing the domains of all the pbbs. (optimize_isl): Call the new function get_schedule_map_st for isl-0.15 gcc/testsuite/ChangeLog: * gcc.dg/graphite/block-0.c: Changed to match pattern. * gcc.dg/graphite/interchange-1.c: Same. * gcc.dg/graphite/interchange-10.c: Same. * gcc.dg/graphite/interchange-11.c: Same. * gcc.dg/graphite/interchange-13.c: Same. * gcc.dg/graphite/interchange-3.c: Same. * gcc.dg/graphite/interchange-4.c: Same. * gcc.dg/graphite/interchange-7.c: Same. * gcc.dg/graphite/interchange-9.c: Same. * gcc.dg/graphite/uns-interchange-9.c: Same. * gfortran.dg/graphite/interchange-3.f90: Same. Co-Authored-By: Aditya Kumar <aditya.k7@samsung.com> From-SVN: r229445
Diffstat (limited to 'gcc/graphite-optimize-isl.c')
-rw-r--r--gcc/graphite-optimize-isl.c98
1 files changed, 89 insertions, 9 deletions
diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c
index 090bc01a107..53355bb57dc 100644
--- a/gcc/graphite-optimize-isl.c
+++ b/gcc/graphite-optimize-isl.c
@@ -34,6 +34,9 @@ along with GCC; see the file COPYING3. If not see
#include <isl/aff.h>
#include <isl/options.h>
#include <isl/ctx.h>
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+#include <isl/schedule_node.h>
+#endif
#include "system.h"
#include "coretypes.h"
@@ -50,20 +53,78 @@ along with GCC; see the file COPYING3. If not see
#include "params.h"
#include "dumpfile.h"
-static isl_union_set *
-scop_get_domains (scop_p scop ATTRIBUTE_UNUSED)
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+
+/* get_schedule_for_node_st - Improve schedule for the schedule node.
+ Only Simple loop tiling is considered. */
+
+static __isl_give isl_schedule_node *
+get_schedule_for_node_st (__isl_take isl_schedule_node *node, void *user)
{
- int i;
- poly_bb_p pbb;
- isl_space *space = isl_set_get_space (scop->param_context);
- isl_union_set *res = isl_union_set_empty (space);
+ if (user)
+ return node;
- FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
- res = isl_union_set_add_set (res, isl_set_copy (pbb->domain));
+ if (isl_schedule_node_get_type (node) != isl_schedule_node_band
+ || isl_schedule_node_n_children (node) != 1)
+ return node;
+
+ isl_space *space = isl_schedule_node_band_get_space (node);
+ unsigned dims = isl_space_dim (space, isl_dim_set);
+ isl_schedule_node *child = isl_schedule_node_get_child (node, 0);
+ isl_schedule_node_type type = isl_schedule_node_get_type (child);
+ isl_space_free (space);
+ isl_schedule_node_free (child);
+
+ if (type != isl_schedule_node_leaf)
+ return node;
+
+ if (dims <= 1 || !isl_schedule_node_band_get_permutable (node))
+ {
+ if (dump_file && dump_flags)
+ fprintf (dump_file, "not tiled\n");
+ return node;
+ }
+
+ /* Tile loops. */
+ space = isl_schedule_node_band_get_space (node);
+ isl_multi_val *sizes = isl_multi_val_zero (space);
+ long tile_size = PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE);
+ isl_ctx *ctx = isl_schedule_node_get_ctx (node);
+
+ for (unsigned i = 0; i < dims; i++)
+ {
+ sizes = isl_multi_val_set_val (sizes, i,
+ isl_val_int_from_si (ctx, tile_size));
+ if (dump_file && dump_flags)
+ fprintf (dump_file, "tiled by %ld\n", tile_size);
+ }
+
+ node = isl_schedule_node_band_tile (node, sizes);
+ node = isl_schedule_node_child (node, 0);
- return res;
+ return node;
}
+/* get_schedule_map_st - Improve the schedule by performing other loop
+ optimizations. _st ending is for schedule tree version of this
+ function (see get_schedule_map below for the band forest version).
+
+ Do a depth-first post-order traversal of the nodes in a schedule
+ tree and apply get_schedule_for_node_st on them to improve the schedule.
+ */
+
+static __isl_give isl_union_map *
+get_schedule_map_st (__isl_keep isl_schedule *schedule)
+{
+
+ schedule = isl_schedule_map_schedule_node_bottom_up (schedule,
+ get_schedule_for_node_st,
+ NULL);
+ isl_union_map *schedule_map = isl_schedule_get_map (schedule);
+ return schedule_map;
+}
+#else
+
/* get_tile_map - Create a map that describes a n-dimensonal tiling.
get_tile_map creates a map from a n-dimensional scattering space into an
@@ -255,6 +316,7 @@ get_schedule_map (isl_schedule *schedule)
isl_band_list_free (bandList);
return schedule_map;
}
+#endif
static isl_stat
get_single_map (__isl_take isl_map *map, void *user)
@@ -285,6 +347,20 @@ apply_schedule_map_to_scop (scop_p scop, isl_union_map *schedule_map)
}
}
+static isl_union_set *
+scop_get_domains (scop_p scop ATTRIBUTE_UNUSED)
+{
+ int i;
+ poly_bb_p pbb;
+ isl_space *space = isl_set_get_space (scop->param_context);
+ isl_union_set *res = isl_union_set_empty (space);
+
+ FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
+ res = isl_union_set_add_set (res, isl_set_copy (pbb->domain));
+
+ return res;
+}
+
static const int CONSTANT_BOUND = 20;
/* Compute the schedule for SCOP based on its parameters, domain and set of
@@ -360,7 +436,11 @@ optimize_isl (scop_p scop)
return false;
#endif
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+ isl_union_map *schedule_map = get_schedule_map_st (schedule);
+#else
isl_union_map *schedule_map = get_schedule_map (schedule);
+#endif
apply_schedule_map_to_scop (scop, schedule_map);
isl_schedule_free (schedule);