Commit 14b1747c by Aditya Kumar Committed by Sebastian Pop

add more coalescing to simplify constraints

	* graphite-dependences.c (constrain_domain): Add call to isl_*_coalesce.
	(add_pdr_constraints): Same.
	(scop_get_reads): Same.
	(scop_get_must_writes): Same.
	(scop_get_may_writes): Same.
	(scop_get_original_schedule): Same.
	(extend_schedule): Same.
	(apply_schedule_on_deps): Same.
	(carries_deps): Same.
	(compute_deps): Same.
	(scop_get_dependences): Same.
	* graphite-isl-ast-to-gimple.c
	(translate_isl_ast_to_gimple::generate_isl_schedule): Same.
	* graphite-optimize-isl.c (get_schedule_for_band): Same.
	(get_schedule_for_band_list): Same.
	(get_schedule_map): Same.
	(apply_schedule_map_to_scop): Same.
	* graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same.
	(build_loop_iteration_domains): Same.
	(add_condition_to_pbb): Same.
	(add_param_constraints): Same.
	(pdr_add_memory_accesses): Same.
	(pdr_add_data_dimensions): Same.

Co-Authored-By: Sebastian Pop <s.pop@samsung.com>

From-SVN: r232650
parent 42d4fbb0
2016-01-21 Aditya Kumar <aditya.k7@samsung.com>
Sebastian Pop <s.pop@samsung.com>
* graphite-dependences.c (constrain_domain): Add call to isl_*_coalesce.
(add_pdr_constraints): Same.
(scop_get_reads): Same.
(scop_get_must_writes): Same.
(scop_get_may_writes): Same.
(scop_get_original_schedule): Same.
(extend_schedule): Same.
(apply_schedule_on_deps): Same.
(carries_deps): Same.
(compute_deps): Same.
(scop_get_dependences): Same.
* graphite-isl-ast-to-gimple.c
(translate_isl_ast_to_gimple::generate_isl_schedule): Same.
* graphite-optimize-isl.c (get_schedule_for_band): Same.
(get_schedule_for_band_list): Same.
(get_schedule_map): Same.
(apply_schedule_map_to_scop): Same.
* graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Same.
(build_loop_iteration_domains): Same.
(add_condition_to_pbb): Same.
(add_param_constraints): Same.
(pdr_add_memory_accesses): Same.
(pdr_add_data_dimensions): Same.
2016-01-20 Sandra Loosemore <sandra@codesourcery.com> 2016-01-20 Sandra Loosemore <sandra@codesourcery.com>
* doc/invoke.texi (Instrumentation Options): Clarify -mmpx linking * doc/invoke.texi (Instrumentation Options): Clarify -mmpx linking
......
...@@ -49,7 +49,7 @@ constrain_domain (isl_map *map, isl_set *s) ...@@ -49,7 +49,7 @@ constrain_domain (isl_map *map, isl_set *s)
s = isl_set_set_tuple_id (s, id); s = isl_set_set_tuple_id (s, id);
isl_space_free (d); 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. */ /* 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) ...@@ -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_map *x = isl_map_intersect_range (isl_map_copy (pdr->accesses),
isl_set_copy (pdr->subscript_sizes)); isl_set_copy (pdr->subscript_sizes));
x = constrain_domain (x, isl_set_copy (pbb->domain)); x = isl_map_coalesce (x);
return x; return constrain_domain (x, isl_set_copy (pbb->domain));
} }
/* Returns all the memory reads in SCOP. */ /* Returns all the memory reads in SCOP. */
...@@ -93,7 +93,7 @@ scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs) ...@@ -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. */ /* Returns all the memory must writes in SCOP. */
...@@ -126,7 +126,7 @@ scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs) ...@@ -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. */ /* Returns all the memory may writes in SCOP. */
...@@ -159,7 +159,7 @@ scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs) ...@@ -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. */ /* Returns all the original schedules in SCOP. */
...@@ -179,7 +179,7 @@ scop_get_original_schedule (scop_p scop, vec<poly_bb_p> pbbs) ...@@ -179,7 +179,7 @@ scop_get_original_schedule (scop_p scop, vec<poly_bb_p> pbbs)
isl_set_copy (pbb->domain))); 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 /* 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) ...@@ -242,7 +242,7 @@ extend_schedule (__isl_take isl_union_map *x)
str.umap = isl_union_map_empty (isl_union_map_get_space (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_foreach_map (x, extend_schedule_1, (void *) &str);
isl_union_map_free (x); 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 /* Applies SCHEDULE to the in and out dimensions of the dependences
...@@ -252,22 +252,17 @@ static isl_map * ...@@ -252,22 +252,17 @@ static isl_map *
apply_schedule_on_deps (__isl_keep isl_union_map *schedule, apply_schedule_on_deps (__isl_keep isl_union_map *schedule,
__isl_keep isl_union_map *deps) __isl_keep isl_union_map *deps)
{ {
isl_map *x; isl_union_map *trans = extend_schedule (isl_union_map_copy (schedule));
isl_union_map *ux, *trans; isl_union_map *ux = isl_union_map_copy (deps);
trans = isl_union_map_copy (schedule);
trans = extend_schedule (trans);
ux = isl_union_map_copy (deps);
ux = isl_union_map_apply_domain (ux, isl_union_map_copy (trans)); ux = isl_union_map_apply_domain (ux, isl_union_map_copy (trans));
ux = isl_union_map_apply_range (ux, trans); ux = isl_union_map_apply_range (ux, trans);
if (isl_union_map_is_empty (ux)) ux = isl_union_map_coalesce (ux);
{
if (!isl_union_map_is_empty (ux))
return isl_map_from_union_map (ux);
isl_union_map_free (ux); isl_union_map_free (ux);
return NULL; return NULL;
}
x = isl_map_from_union_map (ux);
return x;
} }
/* Return true when DEPS is non empty and the intersection of LEX with /* 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, ...@@ -280,25 +275,19 @@ carries_deps (__isl_keep isl_union_map *schedule,
__isl_keep isl_union_map *deps, __isl_keep isl_union_map *deps,
int depth) int depth)
{ {
bool res;
int i;
isl_space *space;
isl_map *lex, *x;
isl_constraint *ineq;
if (isl_union_map_is_empty (deps)) if (isl_union_map_is_empty (deps))
return false; return false;
x = apply_schedule_on_deps (schedule, deps); isl_map *x = apply_schedule_on_deps (schedule, deps);
if (x == NULL) if (x == NULL)
return false; 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); lex = isl_map_equate (lex, isl_dim_in, i, isl_dim_out, i);
/* in + 1 <= out */ /* in + 1 <= out */
...@@ -306,8 +295,9 @@ carries_deps (__isl_keep isl_union_map *schedule, ...@@ -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_coefficient_si (ineq, isl_dim_in, depth - 1, -1);
ineq = isl_constraint_set_constant_si (ineq, -1); ineq = isl_constraint_set_constant_si (ineq, -1);
lex = isl_map_add_constraint (lex, ineq); lex = isl_map_add_constraint (lex, ineq);
lex = isl_map_coalesce (lex);
x = isl_map_intersect (x, lex); x = isl_map_intersect (x, lex);
res = !isl_map_is_empty (x); bool res = !isl_map_is_empty (x);
isl_map_free (x); isl_map_free (x);
return res; return res;
...@@ -336,6 +326,8 @@ compute_deps (scop_p scop, vec<poly_bb_p> pbbs, ...@@ -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 *may_writes = scop_get_may_writes (scop, pbbs);
isl_union_map *all_writes = isl_union_map_union isl_union_map *all_writes = isl_union_map_union
(isl_union_map_copy (must_writes), isl_union_map_copy (may_writes)); (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_space *space = isl_union_map_get_space (all_writes);
isl_union_map *empty = isl_union_map_empty (space); isl_union_map *empty = isl_union_map_empty (space);
isl_union_map *original = scop_get_original_schedule (scop, pbbs); isl_union_map *original = scop_get_original_schedule (scop, pbbs);
...@@ -416,6 +408,7 @@ scop_get_dependences (scop_p scop) ...@@ -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_raw);
dependences = isl_union_map_union (dependences, may_war); dependences = isl_union_map_union (dependences, may_war);
dependences = isl_union_map_union (dependences, may_waw); dependences = isl_union_map_union (dependences, may_waw);
dependences = isl_union_map_coalesce (dependences);
if (dump_file) if (dump_file)
{ {
......
...@@ -3160,9 +3160,11 @@ translate_isl_ast_to_gimple::generate_isl_schedule (scop_p scop) ...@@ -3160,9 +3160,11 @@ translate_isl_ast_to_gimple::generate_isl_schedule (scop_p scop)
bb_schedule = isl_map_intersect_domain (bb_schedule, bb_schedule = isl_map_intersect_domain (bb_schedule,
isl_set_copy (pbb->domain)); isl_set_copy (pbb->domain));
bb_schedule = extend_schedule (bb_schedule, nb_schedule_dims); bb_schedule = extend_schedule (bb_schedule, nb_schedule_dims);
bb_schedule = isl_map_coalesce (bb_schedule);
schedule_isl schedule_isl
= isl_union_map_union (schedule_isl, = isl_union_map_union (schedule_isl,
isl_union_map_from_map (bb_schedule)); isl_union_map_from_map (bb_schedule));
schedule_isl = isl_union_map_coalesce (schedule_isl);
} }
return schedule_isl; return schedule_isl;
} }
......
...@@ -241,6 +241,7 @@ get_schedule_for_band (isl_band *band, int *dimensions) ...@@ -241,6 +241,7 @@ get_schedule_for_band (isl_band *band, int *dimensions)
PARAM_VALUE (PARAM_LOOP_BLOCK_TILE_SIZE)); 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_from_map (isl_map_from_basic_map (tile_map));
tile_umap = isl_union_map_align_params (tile_umap, space); tile_umap = isl_union_map_align_params (tile_umap, space);
tile_umap = isl_union_map_coalesce (tile_umap);
*dimensions = 2 * *dimensions; *dimensions = 2 * *dimensions;
return isl_union_map_apply_range (partial_schedule, tile_umap); return isl_union_map_apply_range (partial_schedule, tile_umap);
...@@ -292,14 +293,14 @@ get_schedule_for_band_list (isl_band_list *band_list) ...@@ -292,14 +293,14 @@ get_schedule_for_band_list (isl_band_list *band_list)
isl_space_free (space); isl_space_free (space);
} }
return schedule; return isl_union_map_coalesce (schedule);
} }
static isl_union_map * static isl_union_map *
get_schedule_map (isl_schedule *schedule) get_schedule_map (isl_schedule *schedule)
{ {
isl_band_list *bandList = isl_schedule_get_band_forest (schedule); isl_band_list *band_list = isl_schedule_get_band_forest (schedule);
isl_union_map *schedule_map = get_schedule_for_band_list (bandList); isl_union_map *schedule_map = get_schedule_for_band_list (band_list);
isl_band_list_free (bandList); isl_band_list_free (bandList);
return schedule_map; return schedule_map;
} }
...@@ -327,15 +328,16 @@ apply_schedule_map_to_scop (scop_p scop, isl_union_map *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 *stmt_band
= isl_union_map_intersect_domain (isl_union_map_copy (schedule_map), = isl_union_map_intersect_domain (isl_union_map_copy (schedule_map),
isl_union_set_from_set (domain)); 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_union_map_foreach_map (stmt_band, get_single_map, &stmt_schedule);
isl_map_free (pbb->transformed); isl_map_free (pbb->transformed);
pbb->transformed = stmt_schedule; pbb->transformed = isl_map_coalesce (stmt_schedule);
isl_union_map_free (stmt_band); isl_union_map_free (stmt_band);
} }
} }
static isl_union_set * static isl_union_set *
scop_get_domains (scop_p scop ATTRIBUTE_UNUSED) scop_get_domains (scop_p scop)
{ {
int i; int i;
poly_bb_p pbb; poly_bb_p pbb;
......
...@@ -143,6 +143,10 @@ build_pbb_scattering_polyhedrons (isl_aff *static_sched, ...@@ -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); pbb->transformed = isl_map_copy (pbb->schedule);
} }
...@@ -482,7 +486,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, ...@@ -482,7 +486,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
isl_constraint *c = isl_inequality_alloc isl_constraint *c = isl_inequality_alloc
(isl_local_space_from_space (isl_space_copy (space))); (isl_local_space_from_space (isl_space_copy (space)));
c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, 1); 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 */ /* loop_i <= cst_nb_iters */
if (TREE_CODE (nb_iters) == INTEGER_CST) if (TREE_CODE (nb_iters) == INTEGER_CST)
...@@ -513,7 +517,8 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, ...@@ -513,7 +517,8 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
isl_set_dim (valid, isl_dim_set)); isl_set_dim (valid, isl_dim_set));
if (valid) 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_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), 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, ...@@ -541,7 +546,8 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
isl_set *x = isl_pw_aff_ge_set (approx, aff); isl_set *x = isl_pw_aff_ge_set (approx, aff);
x = isl_set_project_out (x, isl_dim_set, 0, x = isl_set_project_out (x, isl_dim_set, 0,
isl_set_dim (x, isl_dim_set)); 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_constraint *c = isl_inequality_alloc
(isl_local_space_from_space (isl_space_copy (space))); (isl_local_space_from_space (isl_space_copy (space)));
...@@ -557,6 +563,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, ...@@ -557,6 +563,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
else else
gcc_unreachable (); gcc_unreachable ();
inner = isl_set_coalesce (inner);
if (loop->inner if (loop->inner
&& !build_loop_iteration_domains (scop, loop->inner, nb + 1, && !build_loop_iteration_domains (scop, loop->inner, nb + 1,
isl_set_copy (inner), doms)) isl_set_copy (inner), doms))
...@@ -648,7 +655,7 @@ add_condition_to_pbb (poly_bb_p pbb, gcond *stmt, enum tree_code code) ...@@ -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_coalesce (cond);
cond = isl_set_set_tuple_id (cond, isl_set_get_tuple_id (pbb->domain)); 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; return true;
} }
...@@ -749,7 +756,8 @@ add_param_constraints (scop_p scop, graphite_dim_t p) ...@@ -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_constant_val (c, v);
c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, 1); 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) if (ub)
...@@ -768,7 +776,8 @@ add_param_constraints (scop_p scop, graphite_dim_t p) ...@@ -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_constant_val (c, v);
c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, -1); 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) ...@@ -911,7 +920,7 @@ pdr_add_memory_accesses (isl_map *acc, dr_info &dri)
acc = set_index (acc, i + 1, aff); 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 /* 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, ...@@ -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)); isl_set *valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
valid = isl_set_project_out (valid, isl_dim_set, 0, valid = isl_set_project_out (valid, isl_dim_set, 0,
isl_set_dim (valid, isl_dim_set)); 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 *aff
= isl_aff_zero_on_domain (isl_local_space_from_space (space)); = 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, ...@@ -992,7 +1002,7 @@ pdr_add_data_dimensions (isl_set *subscript_sizes, scop_p scop,
subscript_sizes = isl_set_intersect (subscript_sizes, ubs); subscript_sizes = isl_set_intersect (subscript_sizes, ubs);
} }
return subscript_sizes; return isl_set_coalesce (subscript_sizes);
} }
/* Build data accesses for DRI. */ /* Build data accesses for DRI. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment