* [PATCH 4/4] [graphite] add missing ast node for isl 0.15
2015-12-18 17:42 [PATCH 1/4] [graphite] add more coalescing to simplify constraints Sebastian Pop
@ 2015-12-18 17:42 ` Sebastian Pop
2015-12-18 17:42 ` [PATCH 2/4] [graphite] remove isl scheduler optimizations for deprecated isl 0.14 Sebastian Pop
2015-12-18 17:42 ` [PATCH 3/4] [graphite] add tiling on schedule trees Sebastian Pop
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Pop @ 2015-12-18 17:42 UTC (permalink / raw)
To: sebpop; +Cc: richard.guenther, gcc-patches, hiraditya, Sebastian Pop
---
gcc/graphite-isl-ast-to-gimple.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 64183c4..7e00b17 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -1245,6 +1245,15 @@ translate_isl_ast_to_gimple::translate_isl_ast (loop_p context_loop,
case isl_ast_node_block:
return translate_isl_ast_node_block (context_loop, node,
next_e, ip);
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+ case isl_ast_node_mark:
+ {
+ isl_ast_node *n = isl_ast_node_mark_get_node (node);
+ edge e = translate_isl_ast (context_loop, n, next_e, ip);
+ isl_ast_node_free (n);
+ return e;
+ }
+#endif
default:
gcc_unreachable ();
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/4] [graphite] add more coalescing to simplify constraints
@ 2015-12-18 17:42 Sebastian Pop
2015-12-18 17:42 ` [PATCH 4/4] [graphite] add missing ast node for isl 0.15 Sebastian Pop
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Pop @ 2015-12-18 17:42 UTC (permalink / raw)
To: sebpop; +Cc: richard.guenther, gcc-patches, hiraditya, Sebastian Pop
---
gcc/graphite-dependences.c | 63 ++++++++++++++++++----------------------
gcc/graphite-isl-ast-to-gimple.c | 2 ++
gcc/graphite-optimize-isl.c | 12 ++++----
gcc/graphite-sese-to-poly.c | 28 ++++++++++++------
4 files changed, 56 insertions(+), 49 deletions(-)
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index 46869d7..ae08059 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -49,7 +49,7 @@ constrain_domain (isl_map *map, isl_set *s)
s = isl_set_set_tuple_id (s, id);
isl_space_free (d);
- return isl_map_intersect_domain (map, s);
+ return isl_map_coalesce (isl_map_intersect_domain (map, s));
}
/* Constrain pdr->accesses with pdr->subscript_sizes and pbb->domain. */
@@ -59,8 +59,8 @@ add_pdr_constraints (poly_dr_p pdr, poly_bb_p pbb)
{
isl_map *x = isl_map_intersect_range (isl_map_copy (pdr->accesses),
isl_set_copy (pdr->subscript_sizes));
- x = constrain_domain (x, isl_set_copy (pbb->domain));
- return x;
+ x = isl_map_coalesce (x);
+ return constrain_domain (x, isl_set_copy (pbb->domain));
}
/* Returns all the memory reads in SCOP. */
@@ -93,7 +93,7 @@ scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs)
}
}
- return res;
+ return isl_union_map_coalesce (res);
}
/* Returns all the memory must writes in SCOP. */
@@ -126,7 +126,7 @@ scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs)
}
}
- return res;
+ return isl_union_map_coalesce (res);
}
/* Returns all the memory may writes in SCOP. */
@@ -159,7 +159,7 @@ scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs)
}
}
- return res;
+ return isl_union_map_coalesce (res);
}
/* Returns all the original schedules in SCOP. */
@@ -179,7 +179,7 @@ scop_get_original_schedule (scop_p scop, vec<poly_bb_p> pbbs)
isl_set_copy (pbb->domain)));
}
- return res;
+ return isl_union_map_coalesce (res);
}
/* Helper function used on each MAP of a isl_union_map. Computes the
@@ -242,7 +242,7 @@ extend_schedule (__isl_take isl_union_map *x)
str.umap = isl_union_map_empty (isl_union_map_get_space (x));
isl_union_map_foreach_map (x, extend_schedule_1, (void *) &str);
isl_union_map_free (x);
- return str.umap;
+ return isl_union_map_coalesce (str.umap);
}
/* Applies SCHEDULE to the in and out dimensions of the dependences
@@ -252,22 +252,17 @@ static isl_map *
apply_schedule_on_deps (__isl_keep isl_union_map *schedule,
__isl_keep isl_union_map *deps)
{
- isl_map *x;
- isl_union_map *ux, *trans;
-
- trans = isl_union_map_copy (schedule);
- trans = extend_schedule (trans);
- ux = isl_union_map_copy (deps);
+ isl_union_map *trans = extend_schedule (isl_union_map_copy (schedule));
+ isl_union_map *ux = isl_union_map_copy (deps);
ux = isl_union_map_apply_domain (ux, isl_union_map_copy (trans));
ux = isl_union_map_apply_range (ux, trans);
- if (isl_union_map_is_empty (ux))
- {
- isl_union_map_free (ux);
- return NULL;
- }
- x = isl_map_from_union_map (ux);
+ ux = isl_union_map_coalesce (ux);
+
+ if (!isl_union_map_is_empty (ux))
+ return isl_map_from_union_map (ux);
- return x;
+ isl_union_map_free (ux);
+ return NULL;
}
/* Return true when DEPS is non empty and the intersection of LEX with
@@ -280,25 +275,19 @@ carries_deps (__isl_keep isl_union_map *schedule,
__isl_keep isl_union_map *deps,
int depth)
{
- bool res;
- int i;
- isl_space *space;
- isl_map *lex, *x;
- isl_constraint *ineq;
-
if (isl_union_map_is_empty (deps))
return false;
- x = apply_schedule_on_deps (schedule, deps);
+ isl_map *x = apply_schedule_on_deps (schedule, deps);
if (x == NULL)
return false;
- space = isl_map_get_space (x);
- space = isl_space_range (space);
- lex = isl_map_lex_le (space);
- space = isl_map_get_space (x);
- ineq = isl_inequality_alloc (isl_local_space_from_space (space));
- for (i = 0; i < depth - 1; i++)
+ isl_space *space = isl_map_get_space (x);
+ isl_map *lex = isl_map_lex_le (isl_space_range (space));
+ isl_constraint *ineq = isl_inequality_alloc
+ (isl_local_space_from_space (isl_map_get_space (x)));
+
+ for (int i = 0; i < depth - 1; i++)
lex = isl_map_equate (lex, isl_dim_in, i, isl_dim_out, i);
/* in + 1 <= out */
@@ -306,8 +295,9 @@ carries_deps (__isl_keep isl_union_map *schedule,
ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_in, depth - 1, -1);
ineq = isl_constraint_set_constant_si (ineq, -1);
lex = isl_map_add_constraint (lex, ineq);
+ lex = isl_map_coalesce (lex);
x = isl_map_intersect (x, lex);
- res = !isl_map_is_empty (x);
+ bool res = !isl_map_is_empty (x);
isl_map_free (x);
return res;
@@ -336,6 +326,8 @@ compute_deps (scop_p scop, vec<poly_bb_p> pbbs,
isl_union_map *may_writes = scop_get_may_writes (scop, pbbs);
isl_union_map *all_writes = isl_union_map_union
(isl_union_map_copy (must_writes), isl_union_map_copy (may_writes));
+ all_writes = isl_union_map_coalesce (all_writes);
+
isl_space *space = isl_union_map_get_space (all_writes);
isl_union_map *empty = isl_union_map_empty (space);
isl_union_map *original = scop_get_original_schedule (scop, pbbs);
@@ -416,6 +408,7 @@ scop_get_dependences (scop_p scop)
dependences = isl_union_map_union (dependences, may_raw);
dependences = isl_union_map_union (dependences, may_war);
dependences = isl_union_map_union (dependences, may_waw);
+ dependences = isl_union_map_coalesce (dependences);
if (dump_file)
{
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 795232a..aaca9e9 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -3160,9 +3160,11 @@ translate_isl_ast_to_gimple::generate_isl_schedule (scop_p scop)
bb_schedule = isl_map_intersect_domain (bb_schedule,
isl_set_copy (pbb->domain));
bb_schedule = extend_schedule (bb_schedule, nb_schedule_dims);
+ bb_schedule = isl_map_coalesce (bb_schedule);
schedule_isl
= isl_union_map_union (schedule_isl,
isl_union_map_from_map (bb_schedule));
+ schedule_isl = isl_union_map_coalesce (schedule_isl);
}
return schedule_isl;
}
diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c
index 9626e96..15dd5b0 100644
--- a/gcc/graphite-optimize-isl.c
+++ b/gcc/graphite-optimize-isl.c
@@ -241,6 +241,7 @@ get_schedule_for_band (isl_band *band, int *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);
@@ -292,14 +293,14 @@ get_schedule_for_band_list (isl_band_list *band_list)
isl_space_free (space);
}
- return schedule;
+ return isl_union_map_coalesce (schedule);
}
static isl_union_map *
get_schedule_map (isl_schedule *schedule)
{
- isl_band_list *bandList = isl_schedule_get_band_forest (schedule);
- isl_union_map *schedule_map = get_schedule_for_band_list (bandList);
+ 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;
}
@@ -327,15 +328,16 @@ apply_schedule_map_to_scop (scop_p scop, isl_union_map *schedule_map)
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 = stmt_schedule;
+ pbb->transformed = isl_map_coalesce (stmt_schedule);
isl_union_map_free (stmt_band);
}
}
static isl_union_set *
-scop_get_domains (scop_p scop ATTRIBUTE_UNUSED)
+scop_get_domains (scop_p scop)
{
int i;
poly_bb_p pbb;
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 7992c28..6421e4e 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -143,6 +143,10 @@ build_pbb_scattering_polyhedrons (isl_aff *static_sched,
}
}
+ /* Simplify the original schedule. */
+ pbb->schedule = isl_map_coalesce (pbb->schedule);
+
+ /* At the beginning, set the transformed schedule to the original. */
pbb->transformed = isl_map_copy (pbb->schedule);
}
@@ -482,7 +486,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
isl_constraint *c = isl_inequality_alloc
(isl_local_space_from_space (isl_space_copy (space)));
c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, 1);
- inner = isl_set_add_constraint (inner, c);
+ inner = isl_set_coalesce (isl_set_add_constraint (inner, c));
/* loop_i <= cst_nb_iters */
if (TREE_CODE (nb_iters) == INTEGER_CST)
@@ -513,7 +517,8 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
isl_set_dim (valid, isl_dim_set));
if (valid)
- scop->param_context = isl_set_intersect (scop->param_context, valid);
+ scop->param_context = isl_set_coalesce
+ (isl_set_intersect (scop->param_context, valid));
isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space));
isl_aff *al = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls),
@@ -541,7 +546,8 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
isl_set *x = isl_pw_aff_ge_set (approx, aff);
x = isl_set_project_out (x, isl_dim_set, 0,
isl_set_dim (x, isl_dim_set));
- scop->param_context = isl_set_intersect (scop->param_context, x);
+ scop->param_context = isl_set_coalesce
+ (isl_set_intersect (scop->param_context, x));
isl_constraint *c = isl_inequality_alloc
(isl_local_space_from_space (isl_space_copy (space)));
@@ -557,6 +563,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
else
gcc_unreachable ();
+ inner = isl_set_coalesce (inner);
if (loop->inner
&& !build_loop_iteration_domains (scop, loop->inner, nb + 1,
isl_set_copy (inner), doms))
@@ -648,7 +655,7 @@ add_condition_to_pbb (poly_bb_p pbb, gcond *stmt, enum tree_code code)
cond = isl_set_coalesce (cond);
cond = isl_set_set_tuple_id (cond, isl_set_get_tuple_id (pbb->domain));
- pbb->domain = isl_set_intersect (pbb->domain, cond);
+ pbb->domain = isl_set_coalesce (isl_set_intersect (pbb->domain, cond));
return true;
}
@@ -749,7 +756,8 @@ add_param_constraints (scop_p scop, graphite_dim_t p)
c = isl_constraint_set_constant_val (c, v);
c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, 1);
- scop->param_context = isl_set_add_constraint (scop->param_context, c);
+ scop->param_context = isl_set_coalesce
+ (isl_set_add_constraint (scop->param_context, c));
}
if (ub)
@@ -768,7 +776,8 @@ add_param_constraints (scop_p scop, graphite_dim_t p)
c = isl_constraint_set_constant_val (c, v);
c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, -1);
- scop->param_context = isl_set_add_constraint (scop->param_context, c);
+ scop->param_context = isl_set_coalesce
+ (isl_set_add_constraint (scop->param_context, c));
}
}
@@ -911,7 +920,7 @@ pdr_add_memory_accesses (isl_map *acc, dr_info &dri)
acc = set_index (acc, i + 1, aff);
}
- return acc;
+ return isl_map_coalesce (acc);
}
/* Return true when the LOW and HIGH bounds of an array reference REF are valid
@@ -972,7 +981,8 @@ pdr_add_data_dimensions (isl_set *subscript_sizes, scop_p scop,
isl_set *valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
valid = isl_set_project_out (valid, isl_dim_set, 0,
isl_set_dim (valid, isl_dim_set));
- scop->param_context = isl_set_intersect (scop->param_context, valid);
+ scop->param_context = isl_set_coalesce
+ (isl_set_intersect (scop->param_context, valid));
isl_aff *aff
= isl_aff_zero_on_domain (isl_local_space_from_space (space));
@@ -992,7 +1002,7 @@ pdr_add_data_dimensions (isl_set *subscript_sizes, scop_p scop,
subscript_sizes = isl_set_intersect (subscript_sizes, ubs);
}
- return subscript_sizes;
+ return isl_set_coalesce (subscript_sizes);
}
/* Build data accesses for DRI. */
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/4] [graphite] add tiling on schedule trees
2015-12-18 17:42 [PATCH 1/4] [graphite] add more coalescing to simplify constraints Sebastian Pop
2015-12-18 17:42 ` [PATCH 4/4] [graphite] add missing ast node for isl 0.15 Sebastian Pop
2015-12-18 17:42 ` [PATCH 2/4] [graphite] remove isl scheduler optimizations for deprecated isl 0.14 Sebastian Pop
@ 2015-12-18 17:42 ` Sebastian Pop
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Pop @ 2015-12-18 17:42 UTC (permalink / raw)
To: sebpop; +Cc: richard.guenther, gcc-patches, hiraditya, Sebastian Pop
---
gcc/graphite-optimize-isl.c | 96 ++++++++++++++++++++++++++++++++++++++++-----
gcc/graphite-poly.c | 19 +++++++++
gcc/graphite.h | 2 +
gcc/params.def | 2 +-
4 files changed, 108 insertions(+), 11 deletions(-)
diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c
index 7c3bfcf..9d185c6 100644
--- a/gcc/graphite-optimize-isl.c
+++ b/gcc/graphite-optimize-isl.c
@@ -48,6 +48,71 @@ optimize_isl (scop_p scop ATTRIBUTE_UNUSED)
}
#else
+static isl_schedule_node *
+tile_node (__isl_take isl_schedule_node *node)
+{
+ isl_ctx *ctx = isl_schedule_node_get_ctx (node);
+ isl_space *space = isl_schedule_node_band_get_space (node);
+ unsigned dims = isl_space_dim (space, isl_dim_set);
+ isl_multi_val *sizes = isl_multi_val_zero (space);
+
+ for (unsigned i = 0; i < dims; i++)
+ {
+ isl_val *tile_size = isl_val_int_from_si
+ (ctx, PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE));
+ sizes = isl_multi_val_set_val (sizes, i, tile_size);
+ }
+
+ isl_id *id1 = isl_id_alloc (ctx, "tile", NULL);
+ node = isl_schedule_node_insert_mark
+ (node, id1);
+ node = isl_schedule_node_child (node, 0);
+ node = isl_schedule_node_band_tile (node, sizes);
+ node = isl_schedule_node_child (node, 0);
+ isl_id *id2 = isl_id_alloc (ctx, "point", NULL);
+ node = isl_schedule_node_insert_mark
+ (node, id2);
+
+ return isl_schedule_node_child (node, 0);
+}
+
+static bool is_tileable_node (__isl_keep isl_schedule_node *node)
+{
+ if (isl_schedule_node_get_type (node) != isl_schedule_node_band)
+ return false;
+
+ if (isl_schedule_node_n_children (node) != 1)
+ return false;
+
+ if (!isl_schedule_node_band_get_permutable (node))
+ return false;
+
+ isl_space *space = isl_schedule_node_band_get_space (node);
+ unsigned dims = isl_space_dim (space, isl_dim_set);
+ isl_space_free (space);
+
+ if (dims <= 1)
+ return false;
+
+ isl_schedule_node *child = isl_schedule_node_get_child (node, 0);
+ enum isl_schedule_node_type type = isl_schedule_node_get_type (child);
+ isl_schedule_node_free (child);
+
+ if (type != isl_schedule_node_leaf)
+ return false;
+
+ return true;
+}
+
+static isl_schedule_node *
+optimize_node (__isl_take isl_schedule_node *node, void *user ATTRIBUTE_UNUSED)
+{
+ if (is_tileable_node (node))
+ return tile_node (node);
+
+ return node;
+}
+
static isl_union_set *
scop_get_domains (scop_p scop)
{
@@ -62,8 +127,6 @@ scop_get_domains (scop_p scop)
return res;
}
-static const int CONSTANT_BOUND = 20;
-
/* Compute the schedule for SCOP based on its parameters, domain and set of
constraints. Then apply the schedule to SCOP. */
@@ -85,15 +148,13 @@ optimize_isl (scop_p scop)
isl_union_map *validity = isl_union_map_copy (scop->dependence);
isl_union_map *proximity = isl_union_map_copy (validity);
- isl_options_set_schedule_max_constant_term (scop->isl_context, CONSTANT_BOUND);
- isl_options_set_schedule_maximize_band_depth (scop->isl_context, 1);
- isl_options_set_schedule_serialize_sccs (scop->isl_context, 0);
+ isl_options_set_schedule_serialize_sccs (scop->isl_context, 1);
isl_options_set_schedule_maximize_band_depth (scop->isl_context, 1);
isl_options_set_schedule_max_constant_term (scop->isl_context, 20);
isl_options_set_schedule_max_coefficient (scop->isl_context, 20);
isl_options_set_tile_scale_tile_loops (scop->isl_context, 0);
- 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_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);
/* FIXME: the use of isl_union_set_compute_schedule is discouraged in isl
@@ -114,9 +175,24 @@ 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;
+ if (dump_file)
+ {
+ fprintf (dump_file, "schedule before tiling:\n");
+ print_isl_schedule (dump_file, schedule);
+ }
+
+ isl_schedule_node *root = isl_schedule_get_root (schedule);
+ root = isl_schedule_node_map_descendant_bottom_up (root, optimize_node, NULL);
+ scop->schedule = isl_schedule_node_get_schedule (root);
+
+ if (dump_file)
+ {
+ fprintf (dump_file, "schedule after tiling:\n");
+ print_isl_schedule (dump_file, scop->schedule);
+ }
+
+ isl_schedule_free (schedule);
+ isl_schedule_node_free (root);
return true;
}
#endif /* HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS */
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index ff451b8..73356f2 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -541,6 +541,7 @@ void
print_isl_set (FILE *f, isl_set *set)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+ p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
p = isl_printer_print_set (p, set);
p = isl_printer_print_str (p, "\n");
isl_printer_free (p);
@@ -556,6 +557,7 @@ void
print_isl_map (FILE *f, isl_map *map)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+ p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
p = isl_printer_print_map (p, map);
p = isl_printer_print_str (p, "\n");
isl_printer_free (p);
@@ -571,6 +573,7 @@ void
print_isl_union_map (FILE *f, isl_union_map *map)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+ p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
p = isl_printer_print_union_map (p, map);
p = isl_printer_print_str (p, "\n");
isl_printer_free (p);
@@ -613,6 +616,22 @@ debug_isl_constraint (isl_constraint *c)
print_isl_constraint (stderr, c);
}
+void
+print_isl_schedule (FILE *f, isl_schedule *s)
+{
+ isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
+ p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
+ p = isl_printer_print_schedule (p, s);
+ p = isl_printer_print_str (p, "\n");
+ isl_printer_free (p);
+}
+
+DEBUG_FUNCTION void
+debug_isl_schedule (isl_schedule *s)
+{
+ print_isl_schedule (stderr, s);
+}
+
/* Returns the number of iterations RES of the loop around PBB at
time(scattering) dimension TIME_DEPTH. */
diff --git a/gcc/graphite.h b/gcc/graphite.h
index 83f8191..2e07a89 100644
--- a/gcc/graphite.h
+++ b/gcc/graphite.h
@@ -317,6 +317,8 @@ extern void print_isl_map (FILE *, isl_map *);
extern void print_isl_union_map (FILE *, isl_union_map *);
extern void print_isl_aff (FILE *, isl_aff *);
extern void print_isl_constraint (FILE *, isl_constraint *);
+extern void print_isl_schedule (FILE *, isl_schedule *);
+extern void debug_isl_schedule (isl_schedule *);
extern void debug_isl_set (isl_set *);
extern void debug_isl_map (isl_map *);
extern void debug_isl_union_map (isl_union_map *);
diff --git a/gcc/params.def b/gcc/params.def
index 9b82164..98081b9 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -833,7 +833,7 @@ DEFPARAM (PARAM_SWITCH_CONVERSION_BRANCH_RATIO,
DEFPARAM (PARAM_LOOP_BLOCK_TILE_SIZE,
"loop-block-tile-size",
"size of tiles for loop blocking.",
- 51, 0, 0)
+ 32, 0, 0)
/* Maximal number of parameters that we allow in a SCoP. */
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] [graphite] remove isl scheduler optimizations for deprecated isl 0.14
2015-12-18 17:42 [PATCH 1/4] [graphite] add more coalescing to simplify constraints Sebastian Pop
2015-12-18 17:42 ` [PATCH 4/4] [graphite] add missing ast node for isl 0.15 Sebastian Pop
@ 2015-12-18 17:42 ` Sebastian Pop
2015-12-18 17:42 ` [PATCH 3/4] [graphite] add tiling on schedule trees Sebastian Pop
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Pop @ 2015-12-18 17:42 UTC (permalink / raw)
To: sebpop; +Cc: richard.guenther, gcc-patches, hiraditya, Sebastian Pop
---
gcc/graphite-isl-ast-to-gimple.c | 56 +++----
gcc/graphite-optimize-isl.c | 317 +--------------------------------------
gcc/graphite-poly.c | 24 +--
3 files changed, 40 insertions(+), 357 deletions(-)
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index aaca9e9..64183c4 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -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;
}
diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c
index 15dd5b0..7c3bfcf 100644
--- a/gcc/graphite-optimize-isl.c
+++ b/gcc/graphite-optimize-isl.c
@@ -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 */
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index d188341..ff451b8 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -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
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-18 17:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 17:42 [PATCH 1/4] [graphite] add more coalescing to simplify constraints Sebastian Pop
2015-12-18 17:42 ` [PATCH 4/4] [graphite] add missing ast node for isl 0.15 Sebastian Pop
2015-12-18 17:42 ` [PATCH 2/4] [graphite] remove isl scheduler optimizations for deprecated isl 0.14 Sebastian Pop
2015-12-18 17:42 ` [PATCH 3/4] [graphite] add tiling on schedule trees Sebastian Pop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).