@@ -303,14 +303,6 @@ 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. */
@@ -3186,19 +3178,6 @@ 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. */
@@ -3223,7 +3202,6 @@ 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
@@ -3231,6 +3209,23 @@ translate_isl_ast_to_gimple::scop_to_isl_ast (scop_p scop, ivs_params &ip)
isl_options_set_ast_build_atomic_upper_bound (scop->isl_context, true);
add_parameters_to_ivs_params (scop, ip);
+
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+ /* isl 0.15 and isl scheduler has a new schedule. */
+ if (scop->schedule)
+ {
+ /* Set the separate option to reduce control flow overhead. */
+ isl_schedule *schedule = isl_schedule_map_schedule_node_bottom_up
+ (scop->schedule, set_separate_option, NULL);
+ isl_ast_build *context_isl = generate_isl_context (scop);
+ isl_ast_node *ast_isl = isl_ast_build_node_from_schedule
+ (context_isl, schedule);
+ isl_ast_build_free (context_isl);
+ return ast_isl;
+ }
+#endif
+
+ /* isl 0.14, graphite-identity, or parallelize. */
isl_union_map *schedule_isl = generate_isl_schedule (scop);
isl_ast_build *context_isl = generate_isl_context (scop);
context_isl = set_options (context_isl, schedule_isl);
@@ -3241,21 +3236,8 @@ 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);
}
-
-#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_node *ast_isl = isl_ast_build_ast_from_schedule
+ (context_isl, schedule_isl);
isl_ast_build_free (context_isl);
return ast_isl;
}
@@ -39,303 +39,15 @@ along with GCC; see the file COPYING3. If not see
#include "dumpfile.h"
#include "graphite.h"
-#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
-/* isl 0.15 or later. */
-
-/* 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)
-{
- if (user)
- return node;
-
- 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 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)
+#ifndef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+/* isl 0.14 */
+bool
+optimize_isl (scop_p scop ATTRIBUTE_UNUSED)
{
-
- 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;
+ return false;
}
#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
- 2*n-dimensional scattering space. The map describes a rectangular tiling.
-
- Example:
- SCHEDULE_DIMENSIONS = 2, PARAMETER_DIMENSIONS = 1, TILE_SIZE = 32
-
- tile_map := [p0] -> {[s0, s1] -> [t0, t1, s0, s1]:
- t0 % 32 = 0 and t0 <= s0 < t0 + 32 and
- t1 % 32 = 0 and t1 <= s1 < t1 + 32}
-
- Before tiling:
-
- for (i = 0; i < N; i++)
- for (j = 0; j < M; j++)
- S(i,j)
-
- After tiling:
-
- for (t_i = 0; t_i < N; i+=32)
- for (t_j = 0; t_j < M; j+=32)
- for (i = t_i; i < min(t_i + 32, N); i++) | Unknown that N % 32 = 0
- for (j = t_j; j < t_j + 32; j++) | Known that M % 32 = 0
- S(i,j)
- */
-
-static isl_basic_map *
-get_tile_map (isl_ctx *ctx, int schedule_dimensions, int tile_size)
-{
- /* We construct
-
- tile_map := [p0] -> {[s0, s1] -> [t0, t1, p0, p1, a0, a1]:
- s0 = a0 * 32 and s0 = p0 and t0 <= p0 < t0 + 32 and
- s1 = a1 * 32 and s1 = p1 and t1 <= p1 < t1 + 32}
-
- and project out the auxilary dimensions a0 and a1. */
- isl_space *space
- = isl_space_alloc (ctx, 0, schedule_dimensions, schedule_dimensions * 3);
- isl_basic_map *tile_map = isl_basic_map_universe (isl_space_copy (space));
-
- isl_local_space *local_space = isl_local_space_from_space (space);
-
- for (int x = 0; x < schedule_dimensions; x++)
- {
- int sX = x;
- int tX = x;
- int pX = schedule_dimensions + x;
- int aX = 2 * schedule_dimensions + x;
-
- isl_constraint *c;
-
- /* sX = aX * tile_size; */
- c = isl_equality_alloc (isl_local_space_copy (local_space));
- isl_constraint_set_coefficient_si (c, isl_dim_out, sX, 1);
- isl_constraint_set_coefficient_si (c, isl_dim_out, aX, -tile_size);
- tile_map = isl_basic_map_add_constraint (tile_map, c);
-
- /* pX = sX; */
- c = isl_equality_alloc (isl_local_space_copy (local_space));
- isl_constraint_set_coefficient_si (c, isl_dim_out, pX, 1);
- isl_constraint_set_coefficient_si (c, isl_dim_in, sX, -1);
- tile_map = isl_basic_map_add_constraint (tile_map, c);
-
- /* tX <= pX */
- c = isl_inequality_alloc (isl_local_space_copy (local_space));
- isl_constraint_set_coefficient_si (c, isl_dim_out, pX, 1);
- isl_constraint_set_coefficient_si (c, isl_dim_out, tX, -1);
- tile_map = isl_basic_map_add_constraint (tile_map, c);
-
- /* pX <= tX + (tile_size - 1) */
- c = isl_inequality_alloc (isl_local_space_copy (local_space));
- isl_constraint_set_coefficient_si (c, isl_dim_out, tX, 1);
- isl_constraint_set_coefficient_si (c, isl_dim_out, pX, -1);
- isl_constraint_set_constant_si (c, tile_size - 1);
- tile_map = isl_basic_map_add_constraint (tile_map, c);
- }
-
- /* Project out auxiliary dimensions.
-
- The auxiliary dimensions are transformed into existentially quantified
- ones.
- This reduces the number of visible scattering dimensions and allows isl
- to produces better code. */
- tile_map =
- isl_basic_map_project_out (tile_map, isl_dim_out,
- 2 * schedule_dimensions, schedule_dimensions);
- isl_local_space_free (local_space);
- return tile_map;
-}
-
-/* get_schedule_for_band - Get the schedule for this BAND.
-
- Polly applies transformations like tiling on top of the isl calculated
- value.
- This can influence the number of scheduling dimension. The number of
- schedule dimensions is returned in DIMENSIONS. */
-
-static isl_union_map *
-get_schedule_for_band (isl_band *band, int *dimensions)
-{
- isl_union_map *partial_schedule;
- isl_ctx *ctx;
- isl_space *space;
- isl_basic_map *tile_map;
- isl_union_map *tile_umap;
-
- partial_schedule = isl_band_get_partial_schedule (band);
- *dimensions = isl_band_n_member (band);
-
- /* It does not make any sense to tile a band with just one dimension. */
- if (*dimensions == 1)
- {
- if (dump_file && dump_flags)
- fprintf (dump_file, "not tiled\n");
- return partial_schedule;
- }
-
- if (dump_file && dump_flags)
- fprintf (dump_file, "tiled by %d\n",
- PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE));
-
- ctx = isl_union_map_get_ctx (partial_schedule);
- space = isl_union_map_get_space (partial_schedule);
-
- tile_map = get_tile_map (ctx, *dimensions,
- PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE));
- tile_umap = isl_union_map_from_map (isl_map_from_basic_map (tile_map));
- tile_umap = isl_union_map_align_params (tile_umap, space);
- tile_umap = isl_union_map_coalesce (tile_umap);
- *dimensions = 2 * *dimensions;
-
- return isl_union_map_apply_range (partial_schedule, tile_umap);
-}
-
-
-/* get_schedule_for_band_list - Get the scheduling map for a list of bands.
-
- We walk recursively the forest of bands to combine the schedules of the
- individual bands to the overall schedule. In case tiling is requested,
- the individual bands are tiled. */
-
-static isl_union_map *
-get_schedule_for_band_list (isl_band_list *band_list)
-{
- int num_bands, i;
- isl_union_map *schedule;
- isl_ctx *ctx;
-
- ctx = isl_band_list_get_ctx (band_list);
- num_bands = isl_band_list_n_band (band_list);
- schedule = isl_union_map_empty (isl_space_params_alloc (ctx, 0));
-
- for (i = 0; i < num_bands; i++)
- {
- isl_band *band;
- isl_union_map *partial_schedule;
- int schedule_dimensions;
- isl_space *space;
-
- band = isl_band_list_get_band (band_list, i);
- partial_schedule = get_schedule_for_band (band, &schedule_dimensions);
- space = isl_union_map_get_space (partial_schedule);
-
- if (isl_band_has_children (band))
- {
- isl_band_list *children = isl_band_get_children (band);
- isl_union_map *suffixSchedule
- = get_schedule_for_band_list (children);
- partial_schedule
- = isl_union_map_flat_range_product (partial_schedule,
- suffixSchedule);
- isl_band_list_free (children);
- }
-
- schedule = isl_union_map_union (schedule, partial_schedule);
-
- isl_band_free (band);
- isl_space_free (space);
- }
-
- return isl_union_map_coalesce (schedule);
-}
-
-static isl_union_map *
-get_schedule_map (isl_schedule *schedule)
-{
- isl_band_list *band_list = isl_schedule_get_band_forest (schedule);
- isl_union_map *schedule_map = get_schedule_for_band_list (band_list);
- isl_band_list_free (bandList);
- return schedule_map;
-}
-#endif
-
-static isl_stat
-get_single_map (__isl_take isl_map *map, void *user)
-{
- isl_map **single_map = (isl_map **)user;
- *single_map = map;
- return isl_stat_ok;
-}
-
-static void
-apply_schedule_map_to_scop (scop_p scop, isl_union_map *schedule_map)
-{
- int i;
- poly_bb_p pbb;
-
- FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
- {
- isl_set *domain = isl_set_copy (pbb->domain);
- isl_map *stmt_schedule;
-
- isl_union_map *stmt_band
- = isl_union_map_intersect_domain (isl_union_map_copy (schedule_map),
- isl_union_set_from_set (domain));
- stmt_band = isl_union_map_coalesce (stmt_band);
- isl_union_map_foreach_map (stmt_band, get_single_map, &stmt_schedule);
- isl_map_free (pbb->transformed);
- pbb->transformed = isl_map_coalesce (stmt_schedule);
- isl_union_map_free (stmt_band);
- }
-}
-
static isl_union_set *
scop_get_domains (scop_p scop)
{
@@ -375,8 +87,6 @@ optimize_isl (scop_p scop)
isl_options_set_schedule_max_constant_term (scop->isl_context, CONSTANT_BOUND);
isl_options_set_schedule_maximize_band_depth (scop->isl_context, 1);
-#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
- /* isl 0.15 or later. */
isl_options_set_schedule_serialize_sccs (scop->isl_context, 0);
isl_options_set_schedule_maximize_band_depth (scop->isl_context, 1);
isl_options_set_schedule_max_constant_term (scop->isl_context, 20);
@@ -385,10 +95,9 @@ optimize_isl (scop_p scop)
isl_options_set_coalesce_bounded_wrapping (scop->isl_context, 1);
isl_options_set_ast_build_exploit_nested_bounds (scop->isl_context, 1);
isl_options_set_ast_build_atomic_upper_bound (scop->isl_context, 1);
-#else
- isl_options_set_schedule_fuse (scop->isl_context, ISL_SCHEDULE_FUSE_MIN);
-#endif
+ /* FIXME: the use of isl_union_set_compute_schedule is discouraged in isl
+ 0.15. Instead, we need the original schedule tree. */
isl_schedule *schedule
= isl_union_set_compute_schedule (domain, validity, proximity);
isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_ABORT);
@@ -408,17 +117,7 @@ optimize_isl (scop_p scop)
/* 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);
-#else
- isl_union_map *schedule_map = get_schedule_map (schedule);
-#endif
- apply_schedule_map_to_scop (scop, schedule_map);
-
- isl_union_map_free (schedule_map);
return true;
}
-
+#endif /* HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS */
#endif /* HAVE_isl */
@@ -91,21 +91,23 @@ debug_iteration_domains (scop_p scop)
bool
apply_poly_transforms (scop_p scop)
{
- bool transform_done = false;
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+ /* isl 0.15 or later. */
+ if (flag_loop_nest_optimize)
+ return optimize_isl (scop);
+#else
+ /* Loop optimizations are not supported for deprecated isl version 0.14. */
+ if (flag_loop_nest_optimize)
+ return false;
+#endif
+
+ if (!flag_graphite_identity && !flag_loop_parallelize_all)
+ return false;
/* Generate code even if we did not apply any real transformation.
This also allows to check the performance for the identity
transformation: GIMPLE -> GRAPHITE -> GIMPLE. */
- if (flag_graphite_identity)
- transform_done = true;
-
- if (flag_loop_parallelize_all)
- transform_done = true;
-
- if (flag_loop_nest_optimize)
- transform_done |= optimize_isl (scop);
-
- return transform_done;
+ return true;
}
/* Create a new polyhedral data reference and add it to PBB. It is