Commit adba512d by Aditya Kumar Committed by Sebastian Pop

new scop schedule for isl-0.15

Keep unchanged the implementation for isl-0.14.

	* graphite-poly.c (apply_poly_transforms): Simplify.
	(print_isl_set): Use more readable format: ISL_YAML_STYLE_BLOCK.
	(print_isl_map): Same.
	(print_isl_union_map): Same.
	(print_isl_schedule): New.
	(debug_isl_schedule): New.
	* graphite-dependences.c (scop_get_reads): Do not call
	isl_union_map_add_map that is undocumented isl functionality.
	(scop_get_must_writes): Same.
	(scop_get_may_writes): Same.
	(scop_get_original_schedule): Remove.
	(scop_get_dependences): Do not call isl_union_map_compute_flow that
	is deprecated in isl 0.15.  Instead, use isl_union_access_* interface.
	(compute_deps): Remove.
	* graphite-isl-ast-to-gimple.c (print_schedule_ast): New.
	(debug_schedule_ast): New.
	(translate_isl_ast_to_gimple::scop_to_isl_ast): Call set_separate_option.
	(graphite_regenerate_ast_isl): Add dump.
	(translate_isl_ast_to_gimple::scop_to_isl_ast): Generate code
	from scop->transformed_schedule.
	(graphite_regenerate_ast_isl): Add more dump.
	* graphite-optimize-isl.c (optimize_isl): Set
	scop->transformed_schedule.  Check whether schedules are equal.
	(apply_poly_transforms): Move here.
	* graphite-poly.c (apply_poly_transforms): ... from here.
	(free_poly_bb): Static.
	(free_scop): Static.
	(pbb_number_of_iterations_at_time): Remove.
	(print_isl_ast): New.
	(debug_isl_ast): New.
	(debug_scop_pbb): New.
	* graphite-scop-detection.c (print_edge): Move.
	(print_sese): Move.
	* graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Remove.
	(build_scop_scattering): Remove.
	(create_pw_aff_from_tree): Assert instead of bailing out.
	(add_condition_to_pbb): Remove unused code, do not fail.
	(add_conditions_to_domain): Same.
	(add_conditions_to_constraints): Remove.
	(build_scop_context): New.
	(add_iter_domain_dimension): New.
	(build_iteration_domains): Initialize pbb->iterators.
	Call add_conditions_to_domain.
	(nested_in): New.
	(loop_at): New.
	(index_outermost_in_loop): New.
	(index_pbb_in_loop): New.
	(outermost_pbb_in): New.
	(add_in_sequence): New.
	(add_outer_projection): New.
	(outer_projection_mupa): New.
	(add_loop_schedule): New.
	(build_schedule_pbb): New.
	(build_schedule_loop): New.
	(embed_in_surrounding_loops): New.
	(build_schedule_loop_nest): New.
	(build_original_schedule): New.
	(build_poly_scop): Call build_original_schedule.
	* graphite.h: Declare print_isl_schedule and debug_isl_schedule.
	(free_poly_dr): Remove.
	(struct poly_bb): Add iterators.  Remove schedule, transformed, saved.
	(free_poly_bb): Remove.
	(debug_loop_vec): Remove.
	(print_isl_ast): Declare.
	(debug_isl_ast): Declare.
	(scop_do_interchange): Remove.
	(scop_do_strip_mine): Remove.
	(scop_do_block): Remove.
	(flatten_all_loops): Remove.
	(optimize_isl): Remove.
	(pbb_number_of_iterations_at_time): Remove.
	(debug_scop_pbb): Declare.
	(print_schedule_ast): Declare.
	(debug_schedule_ast): Declare.
	(struct scop): Remove schedule.  Add original_schedule,
	transformed_schedule.
	(free_gimple_poly_bb): Remove.
	(print_generated_program): Remove.
	(debug_generated_program): Remove.
	(unify_scattering_dimensions): Remove.
	* sese.c (print_edge): ... here.
	(print_sese): ... here.
	(debug_edge): ... here.
	(debug_sese): ... here.
	* sese.h (print_edge): Declare.
	(print_sese): Declare.
	(dump_edge): Declare.
	(dump_sese): Declare.

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

From-SVN: r232812
parent 1e050c90
2016-01-25 Aditya Kumar <aditya.k7@samsung.com>
Sebastian Pop <s.pop@samsung.com>
* graphite-poly.c (apply_poly_transforms): Simplify.
(print_isl_set): Use more readable format: ISL_YAML_STYLE_BLOCK.
(print_isl_map): Same.
(print_isl_union_map): Same.
(print_isl_schedule): New.
(debug_isl_schedule): New.
* graphite-dependences.c (scop_get_reads): Do not call
isl_union_map_add_map that is undocumented isl functionality.
(scop_get_must_writes): Same.
(scop_get_may_writes): Same.
(scop_get_original_schedule): Remove.
(scop_get_dependences): Do not call isl_union_map_compute_flow that
is deprecated in isl 0.15. Instead, use isl_union_access_* interface.
(compute_deps): Remove.
* graphite-isl-ast-to-gimple.c (print_schedule_ast): New.
(debug_schedule_ast): New.
(translate_isl_ast_to_gimple::scop_to_isl_ast): Call set_separate_option.
(graphite_regenerate_ast_isl): Add dump.
(translate_isl_ast_to_gimple::scop_to_isl_ast): Generate code
from scop->transformed_schedule.
(graphite_regenerate_ast_isl): Add more dump.
* graphite-optimize-isl.c (optimize_isl): Set
scop->transformed_schedule. Check whether schedules are equal.
(apply_poly_transforms): Move here.
* graphite-poly.c (apply_poly_transforms): ... from here.
(free_poly_bb): Static.
(free_scop): Static.
(pbb_number_of_iterations_at_time): Remove.
(print_isl_ast): New.
(debug_isl_ast): New.
(debug_scop_pbb): New.
* graphite-scop-detection.c (print_edge): Move.
(print_sese): Move.
* graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Remove.
(build_scop_scattering): Remove.
(create_pw_aff_from_tree): Assert instead of bailing out.
(add_condition_to_pbb): Remove unused code, do not fail.
(add_conditions_to_domain): Same.
(add_conditions_to_constraints): Remove.
(build_scop_context): New.
(add_iter_domain_dimension): New.
(build_iteration_domains): Initialize pbb->iterators.
Call add_conditions_to_domain.
(nested_in): New.
(loop_at): New.
(index_outermost_in_loop): New.
(index_pbb_in_loop): New.
(outermost_pbb_in): New.
(add_in_sequence): New.
(add_outer_projection): New.
(outer_projection_mupa): New.
(add_loop_schedule): New.
(build_schedule_pbb): New.
(build_schedule_loop): New.
(embed_in_surrounding_loops): New.
(build_schedule_loop_nest): New.
(build_original_schedule): New.
(build_poly_scop): Call build_original_schedule.
* graphite.h: Declare print_isl_schedule and debug_isl_schedule.
(free_poly_dr): Remove.
(struct poly_bb): Add iterators. Remove schedule, transformed, saved.
(free_poly_bb): Remove.
(debug_loop_vec): Remove.
(print_isl_ast): Declare.
(debug_isl_ast): Declare.
(scop_do_interchange): Remove.
(scop_do_strip_mine): Remove.
(scop_do_block): Remove.
(flatten_all_loops): Remove.
(optimize_isl): Remove.
(pbb_number_of_iterations_at_time): Remove.
(debug_scop_pbb): Declare.
(print_schedule_ast): Declare.
(debug_schedule_ast): Declare.
(struct scop): Remove schedule. Add original_schedule,
transformed_schedule.
(free_gimple_poly_bb): Remove.
(print_generated_program): Remove.
(debug_generated_program): Remove.
(unify_scattering_dimensions): Remove.
* sese.c (print_edge): ... here.
(print_sese): ... here.
(debug_edge): ... here.
(debug_sese): ... here.
* sese.h (print_edge): Declare.
(print_sese): Declare.
(dump_edge): Declare.
(dump_sese): Declare.
2016-01-25 Aditya Kumar <aditya.k7@samsung.com>
Sebastian Pop <s.pop@samsung.com>
* Makefile.in: Set ISLVER in site.exp.
2016-01-25 Jakub Jelinek <jakub@redhat.com>
......
......@@ -66,7 +66,7 @@ add_pdr_constraints (poly_dr_p pdr, poly_bb_p pbb)
/* Returns all the memory reads in SCOP. */
static isl_union_map *
scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs)
scop_get_reads (scop_p scop)
{
int i, j;
poly_bb_p pbb;
......@@ -74,7 +74,7 @@ scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs)
isl_space *space = isl_set_get_space (scop->param_context);
isl_union_map *res = isl_union_map_empty (space);
FOR_EACH_VEC_ELT (pbbs, i, pbb)
FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
{
FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr)
if (pdr_read_p (pdr))
......@@ -84,7 +84,9 @@ scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs)
fprintf (dump_file, "Adding read to depedence graph: ");
print_pdr (dump_file, pdr);
}
res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
isl_union_map *um
= isl_union_map_from_map (add_pdr_constraints (pdr, pbb));
res = isl_union_map_union (res, um);
if (dump_file)
{
fprintf (dump_file, "Reads depedence graph: ");
......@@ -99,7 +101,7 @@ scop_get_reads (scop_p scop, vec<poly_bb_p> pbbs)
/* Returns all the memory must writes in SCOP. */
static isl_union_map *
scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs)
scop_get_must_writes (scop_p scop)
{
int i, j;
poly_bb_p pbb;
......@@ -107,7 +109,7 @@ scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs)
isl_space *space = isl_set_get_space (scop->param_context);
isl_union_map *res = isl_union_map_empty (space);
FOR_EACH_VEC_ELT (pbbs, i, pbb)
FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
{
FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr)
if (pdr_write_p (pdr))
......@@ -117,7 +119,9 @@ scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs)
fprintf (dump_file, "Adding must write to depedence graph: ");
print_pdr (dump_file, pdr);
}
res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
isl_union_map *um
= isl_union_map_from_map (add_pdr_constraints (pdr, pbb));
res = isl_union_map_union (res, um);
if (dump_file)
{
fprintf (dump_file, "Must writes depedence graph: ");
......@@ -132,7 +136,7 @@ scop_get_must_writes (scop_p scop, vec<poly_bb_p> pbbs)
/* Returns all the memory may writes in SCOP. */
static isl_union_map *
scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs)
scop_get_may_writes (scop_p scop)
{
int i, j;
poly_bb_p pbb;
......@@ -140,7 +144,7 @@ scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs)
isl_space *space = isl_set_get_space (scop->param_context);
isl_union_map *res = isl_union_map_empty (space);
FOR_EACH_VEC_ELT (pbbs, i, pbb)
FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
{
FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr)
if (pdr_may_write_p (pdr))
......@@ -150,7 +154,9 @@ scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs)
fprintf (dump_file, "Adding may write to depedence graph: ");
print_pdr (dump_file, pdr);
}
res = isl_union_map_add_map (res, add_pdr_constraints (pdr, pbb));
isl_union_map *um
= isl_union_map_from_map (add_pdr_constraints (pdr, pbb));
res = isl_union_map_union (res, um);
if (dump_file)
{
fprintf (dump_file, "May writes depedence graph: ");
......@@ -162,6 +168,7 @@ scop_get_may_writes (scop_p scop, vec<poly_bb_p> pbbs)
return isl_union_map_coalesce (res);
}
#ifndef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
/* Returns all the original schedules in SCOP. */
static isl_union_map *
......@@ -181,6 +188,7 @@ scop_get_original_schedule (scop_p scop, vec<poly_bb_p> pbbs)
return isl_union_map_coalesce (res);
}
#endif
/* Helper function used on each MAP of a isl_union_map. Computes the
maximal output dimension. */
......@@ -303,6 +311,95 @@ carries_deps (__isl_keep isl_union_map *schedule,
return res;
}
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
/* Compute the dependence relations for the SCOP:
RAW are read after write dependences,
WAR are write after read dependences,
WAW are write after write dependences. */
void
scop_get_dependences (scop_p scop)
{
if (scop->dependence)
return;
isl_union_map *reads = scop_get_reads (scop);
isl_union_map *must_writes = scop_get_must_writes (scop);
isl_union_map *may_writes = scop_get_may_writes (scop);
if (dump_file)
{
fprintf (dump_file, "\n--- Documentation for datarefs dump: ---\n");
fprintf (dump_file, "Statements on the iteration domain are mapped to"
" array references.\n");
fprintf (dump_file, " To read the following data references:\n\n");
fprintf (dump_file, " S_5[i0] -> [106] : i0 >= 0 and i0 <= 3\n");
fprintf (dump_file, " S_8[i0] -> [1, i0] : i0 >= 0 and i0 <= 3\n\n");
fprintf (dump_file, " S_5[i0] is the dynamic instance of statement"
" bb_5 in a loop that accesses all iterations 0 <= i0 <= 3.\n");
fprintf (dump_file, " [1, i0] is a 'memref' with alias set 1"
" and first subscript access i0.\n");
fprintf (dump_file, " [106] is a 'scalar reference' which is the sum of"
" SSA_NAME_VERSION 6"
" and --param graphite-max-arrays-per-scop=100\n");
fprintf (dump_file, "-----------------------\n\n");
fprintf (dump_file, "data references (\n");
fprintf (dump_file, " reads: ");
print_isl_union_map (dump_file, reads);
fprintf (dump_file, " must_writes: ");
print_isl_union_map (dump_file, must_writes);
fprintf (dump_file, " may_writes: ");
print_isl_union_map (dump_file, may_writes);
fprintf (dump_file, ")\n");
}
gcc_assert (scop->original_schedule);
isl_union_access_info *ai;
ai = isl_union_access_info_from_sink (isl_union_map_copy (reads));
ai = isl_union_access_info_set_must_source (ai, isl_union_map_copy (must_writes));
ai = isl_union_access_info_set_may_source (ai, may_writes);
ai = isl_union_access_info_set_schedule
(ai, isl_schedule_copy (scop->original_schedule));
isl_union_flow *flow = isl_union_access_info_compute_flow (ai);
isl_union_map *raw = isl_union_flow_get_must_dependence (flow);
isl_union_flow_free (flow);
ai = isl_union_access_info_from_sink (isl_union_map_copy (must_writes));
ai = isl_union_access_info_set_must_source (ai, must_writes);
ai = isl_union_access_info_set_may_source (ai, reads);
ai = isl_union_access_info_set_schedule
(ai, isl_schedule_copy (scop->original_schedule));
flow = isl_union_access_info_compute_flow (ai);
isl_union_map *waw = isl_union_flow_get_must_dependence (flow);
isl_union_map *war = isl_union_flow_get_may_dependence (flow);
war = isl_union_map_subtract (war, isl_union_map_copy (waw));
isl_union_flow_free (flow);
raw = isl_union_map_coalesce (raw);
waw = isl_union_map_coalesce (waw);
war = isl_union_map_coalesce (war);
isl_union_map *dependences = raw;
dependences = isl_union_map_union (dependences, war);
dependences = isl_union_map_union (dependences, waw);
dependences = isl_union_map_coalesce (dependences);
if (dump_file)
{
fprintf (dump_file, "data dependences (\n");
print_isl_union_map (dump_file, dependences);
fprintf (dump_file, ")\n");
}
scop->dependence = dependences;
}
#else
/* Compute the original data dependences in SCOP for all the reads and
writes in PBBS. */
......@@ -321,9 +418,9 @@ compute_deps (scop_p scop, vec<poly_bb_p> pbbs,
isl_union_map **must_waw_no_source,
isl_union_map **may_waw_no_source)
{
isl_union_map *reads = scop_get_reads (scop, pbbs);
isl_union_map *must_writes = scop_get_must_writes (scop, pbbs);
isl_union_map *may_writes = scop_get_may_writes (scop, pbbs);
isl_union_map *reads = scop_get_reads (scop);
isl_union_map *must_writes = scop_get_must_writes (scop);
isl_union_map *may_writes = scop_get_may_writes (scop);
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);
......@@ -428,4 +525,6 @@ scop_get_dependences (scop_p scop)
return dependences;
}
#endif /* HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS */
#endif /* HAVE_isl */
......@@ -92,24 +92,120 @@ get_schedule_for_node_st (__isl_take isl_schedule_node *node, void *user)
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).
static isl_union_set *
scop_get_domains (scop_p scop)
{
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);
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.
*/
FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
res = isl_union_set_add_set (res, isl_set_copy (pbb->domain));
return res;
}
/* Compute the schedule for SCOP based on its parameters, domain and set of
constraints. Then apply the schedule to SCOP. */
static __isl_give isl_union_map *
get_schedule_map_st (__isl_keep isl_schedule *schedule)
static bool
optimize_isl (scop_p scop)
{
int old_max_operations = isl_ctx_get_max_operations (scop->isl_context);
int max_operations = PARAM_VALUE (PARAM_MAX_ISL_OPERATIONS);
if (max_operations)
isl_ctx_set_max_operations (scop->isl_context, max_operations);
isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_CONTINUE);
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;
isl_union_set *domain = scop_get_domains (scop);
/* Simplify the dependences on the domain. */
scop_get_dependences (scop);
isl_union_map *dependences
= isl_union_map_gist_domain (isl_union_map_copy (scop->dependence),
isl_union_set_copy (domain));
isl_union_map *validity
= isl_union_map_gist_range (dependences, isl_union_set_copy (domain));
/* FIXME: proximity should not be validity. */
isl_union_map *proximity = isl_union_map_copy (validity);
isl_schedule_constraints *sc = isl_schedule_constraints_on_domain (domain);
sc = isl_schedule_constraints_set_proximity (sc, proximity);
sc = isl_schedule_constraints_set_validity (sc, isl_union_map_copy (validity));
sc = isl_schedule_constraints_set_coincidence (sc, validity);
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);
isl_options_set_schedule_max_coefficient (scop->isl_context, 20);
isl_options_set_tile_scale_tile_loops (scop->isl_context, 0);
/* 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
in the upper bound. See the isl manual for more details. */
isl_options_set_ast_build_atomic_upper_bound (scop->isl_context, 1);
scop->transformed_schedule = isl_schedule_constraints_compute_schedule (sc);
scop->transformed_schedule =
isl_schedule_map_schedule_node_bottom_up (scop->transformed_schedule,
get_schedule_for_node_st, NULL);
isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_ABORT);
isl_ctx_reset_operations (scop->isl_context);
isl_ctx_set_max_operations (scop->isl_context, old_max_operations);
if (!scop->transformed_schedule
|| isl_ctx_last_error (scop->isl_context) == isl_error_quota)
{
if (dump_file && dump_flags)
fprintf (dump_file, "isl timed out --param max-isl-operations=%d\n",
max_operations);
return false;
}
gcc_assert (scop->original_schedule);
isl_union_map *original = isl_schedule_get_map (scop->original_schedule);
isl_union_map *transformed = isl_schedule_get_map (scop->transformed_schedule);
bool same_schedule = isl_union_map_is_equal (original, transformed);
isl_union_map_free (original);
isl_union_map_free (transformed);
if (same_schedule)
{
if (dump_file)
{
fprintf (dump_file, "[scheduler] isl optimized schedule is "
"identical to the original schedule.\n");
print_schedule_ast (dump_file, scop->original_schedule, scop);
}
isl_schedule_free (scop->transformed_schedule);
scop->transformed_schedule = isl_schedule_copy (scop->original_schedule);
return false;
}
return true;
}
/* Apply graphite transformations to all the basic blocks of SCOP. */
bool
apply_poly_transforms (scop_p scop)
{
if (flag_loop_nest_optimize)
return optimize_isl (scop);
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. */
gcc_assert (scop->original_schedule);
scop->transformed_schedule = isl_schedule_copy (scop->original_schedule);
return true;
}
#else
/* get_tile_map - Create a map that describes a n-dimensonal tiling.
......@@ -304,7 +400,6 @@ get_schedule_map (isl_schedule *schedule)
isl_band_list_free (band_list);
return schedule_map;
}
#endif
static isl_stat
get_single_map (__isl_take isl_map *map, void *user)
......@@ -350,12 +445,10 @@ 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. */
bool
static bool
optimize_isl (scop_p scop)
{
int old_max_operations = isl_ctx_get_max_operations (scop->isl_context);
......@@ -373,24 +466,10 @@ 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);
#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);
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_ast_build_atomic_upper_bound (scop->isl_context, 1);
#else
isl_options_set_schedule_fuse (scop->isl_context, ISL_SCHEDULE_FUSE_MIN);
#endif
isl_schedule *schedule
= isl_union_set_compute_schedule (domain, validity, proximity);
isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_ABORT);
isl_ctx_reset_operations (scop->isl_context);
......@@ -405,20 +484,38 @@ 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);
#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);
if (dump_file)
{
fprintf (dump_file, "isl end schedule:\n");
print_isl_schedule (dump_file, scop->schedule);
}
return true;
}
/* Apply graphite transformations to all the basic blocks of SCOP. */
bool
apply_poly_transforms (scop_p scop)
{
if (flag_loop_nest_optimize)
return optimize_isl (scop);
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. */
return true;
}
#endif /* HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS */
#endif /* HAVE_isl */
......@@ -86,28 +86,6 @@ debug_iteration_domains (scop_p scop)
print_iteration_domains (stderr, scop);
}
/* Apply graphite transformations to all the basic blocks of SCOP. */
bool
apply_poly_transforms (scop_p scop)
{
bool transform_done = 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;
}
/* Create a new polyhedral data reference and add it to PBB. It is
defined by its ACCESSES, its TYPE, and the number of subscripts
NB_SUBSCRIPTS. */
......@@ -142,7 +120,7 @@ new_poly_dr (poly_bb_p pbb, gimple *stmt, enum poly_dr_type type,
/* Free polyhedral data reference PDR. */
void
static void
free_poly_dr (poly_dr_p pdr)
{
isl_map_free (pdr->accesses);
......@@ -158,9 +136,13 @@ new_poly_bb (scop_p scop, gimple_poly_bb_p black_box)
poly_bb_p pbb = XNEW (struct poly_bb);
pbb->domain = NULL;
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
pbb->iterators = NULL;
#else
pbb->schedule = NULL;
pbb->transformed = NULL;
pbb->saved = NULL;
#endif
PBB_SCOP (pbb) = scop;
pbb_set_black_box (pbb, black_box);
PBB_DRS (pbb).create (3);
......@@ -171,16 +153,25 @@ new_poly_bb (scop_p scop, gimple_poly_bb_p black_box)
/* Free polyhedral black box. */
void
static void
free_poly_bb (poly_bb_p pbb)
{
int i;
poly_dr_p pdr;
isl_set_free (pbb->domain);
pbb->domain = NULL;
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
isl_set_free (pbb->iterators);
pbb->iterators = NULL;
#else
isl_map_free (pbb->schedule);
pbb->schedule = NULL;
isl_map_free (pbb->transformed);
pbb->transformed = NULL;
isl_map_free (pbb->saved);
pbb->saved = NULL;
#endif
if (PBB_DRS (pbb).exists ())
FOR_EACH_VEC_ELT (PBB_DRS (pbb), i, pdr)
......@@ -251,7 +242,7 @@ new_gimple_poly_bb (basic_block bb, vec<data_reference_p> drs,
/* Frees GBB. */
void
static void
free_gimple_poly_bb (gimple_poly_bb_p gbb)
{
free_data_refs (GBB_DATA_REFS (gbb));
......@@ -282,7 +273,12 @@ new_scop (edge entry, edge exit)
sese_info_p region = new_sese_info (entry, exit);
scop_p s = XNEW (struct scop);
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
s->original_schedule = NULL;
s->transformed_schedule = NULL;
#else
s->schedule = NULL;
#endif
s->param_context = NULL;
scop_set_region (s, region);
s->pbbs.create (3);
......@@ -309,8 +305,17 @@ free_scop (scop_p scop)
scop->drs.release ();
isl_set_free (scop->param_context);
scop->param_context = NULL;
isl_union_map_free (scop->dependence);
scop->dependence = NULL;
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
isl_schedule_free (scop->original_schedule);
scop->original_schedule = NULL;
isl_schedule_free (scop->transformed_schedule);
scop->transformed_schedule = NULL;
#else
#endif
XDELETE (scop);
}
......@@ -535,53 +540,61 @@ debug_scop_params (scop_p scop)
extern isl_ctx *the_isl_ctx;
void
print_isl_set (FILE *f, isl_set *set)
print_isl_set (FILE *f, __isl_keep isl_set *set)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
#endif
p = isl_printer_print_set (p, set);
p = isl_printer_print_str (p, "\n");
isl_printer_free (p);
}
DEBUG_FUNCTION void
debug_isl_set (isl_set *set)
debug_isl_set (__isl_keep isl_set *set)
{
print_isl_set (stderr, set);
}
void
print_isl_map (FILE *f, isl_map *map)
print_isl_map (FILE *f, __isl_keep isl_map *map)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
#endif
p = isl_printer_print_map (p, map);
p = isl_printer_print_str (p, "\n");
isl_printer_free (p);
}
DEBUG_FUNCTION void
debug_isl_map (isl_map *map)
debug_isl_map (__isl_keep isl_map *map)
{
print_isl_map (stderr, map);
}
void
print_isl_union_map (FILE *f, isl_union_map *map)
print_isl_union_map (FILE *f, __isl_keep isl_union_map *map)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
#endif
p = isl_printer_print_union_map (p, map);
p = isl_printer_print_str (p, "\n");
isl_printer_free (p);
}
DEBUG_FUNCTION void
debug_isl_union_map (isl_union_map *map)
debug_isl_union_map (__isl_keep isl_union_map *map)
{
print_isl_union_map (stderr, map);
}
void
print_isl_aff (FILE *f, isl_aff *aff)
print_isl_aff (FILE *f, __isl_keep isl_aff *aff)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
p = isl_printer_print_aff (p, aff);
......@@ -590,13 +603,13 @@ print_isl_aff (FILE *f, isl_aff *aff)
}
DEBUG_FUNCTION void
debug_isl_aff (isl_aff *aff)
debug_isl_aff (__isl_keep isl_aff *aff)
{
print_isl_aff (stderr, aff);
}
void
print_isl_constraint (FILE *f, isl_constraint *c)
print_isl_constraint (FILE *f, __isl_keep isl_constraint *c)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
p = isl_printer_print_constraint (p, c);
......@@ -605,46 +618,49 @@ print_isl_constraint (FILE *f, isl_constraint *c)
}
DEBUG_FUNCTION void
debug_isl_constraint (isl_constraint *c)
debug_isl_constraint (__isl_keep isl_constraint *c)
{
print_isl_constraint (stderr, c);
}
/* Returns the number of iterations RES of the loop around PBB at
time(scattering) dimension TIME_DEPTH. */
void
print_isl_schedule (FILE *f, __isl_keep isl_schedule *s)
{
isl_printer *p = isl_printer_to_file (the_isl_ctx, f);
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
p = isl_printer_set_yaml_style (p, ISL_YAML_STYLE_BLOCK);
#endif
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_keep isl_schedule *s)
{
print_isl_schedule (stderr, s);
}
void
pbb_number_of_iterations_at_time (poly_bb_p pbb,
graphite_dim_t time_depth,
mpz_t res)
{
isl_set *transdomain;
isl_space *dc;
isl_aff *aff;
isl_val *isllb, *islub;
/* Map the iteration domain through the current scatter, and work
on the resulting set. */
transdomain = isl_set_apply (isl_set_copy (pbb->domain),
isl_map_copy (pbb->transformed));
/* Select the time_depth' dimension via an affine expression. */
dc = isl_set_get_space (transdomain);
aff = isl_aff_zero_on_domain (isl_local_space_from_space (dc));
aff = isl_aff_set_coefficient_si (aff, isl_dim_in, time_depth, 1);
/* And find the min/max for that function. */
/* XXX isl check results? */
isllb = isl_set_min_val (transdomain, aff);
islub = isl_set_max_val (transdomain, aff);
islub = isl_val_sub (islub, isllb);
islub = isl_val_add_ui (islub, 1);
isl_val_get_num_gmp (islub, res);
isl_val_free (islub);
isl_aff_free (aff);
isl_set_free (transdomain);
print_isl_ast (FILE *file, __isl_keep isl_ast_node *n)
{
isl_printer *prn = isl_printer_to_file (the_isl_ctx, file);
prn = isl_printer_set_output_format (prn, ISL_FORMAT_C);
prn = isl_printer_print_ast_node (prn, n);
prn = isl_printer_print_str (prn, "\n");
isl_printer_free (prn);
}
DEBUG_FUNCTION void
debug_isl_ast (isl_ast_node *n)
{
print_isl_ast (stderr, n);
}
DEBUG_FUNCTION void
debug_scop_pbb (scop_p scop, int i)
{
debug_pbb (scop->pbbs[i]);
}
#endif /* HAVE_isl */
......
......@@ -533,21 +533,6 @@ public:
static edge get_nearest_pdom_with_single_exit (basic_block dom);
/* Pretty printers. */
static void print_edge (FILE *file, const_edge e)
{
fprintf (file, "edge (bb_%d, bb_%d)", e->src->index, e->dest->index);
}
static void print_sese (FILE *file, sese_l s)
{
fprintf (file, "(entry_"); print_edge (file, s.entry);
fprintf (file, ", exit_"); print_edge (file, s.exit);
fprintf (file, ")\n");
}
/* Merge scops at same loop depth and returns the new sese.
Returns a new SESE when merge was successful, INVALID_SESE otherwise. */
......
......@@ -209,7 +209,6 @@ struct poly_dr
void new_poly_dr (poly_bb_p, gimple *, enum poly_dr_type,
isl_map *, isl_set *);
void free_poly_dr (poly_dr_p);
void debug_pdr (poly_dr_p);
void print_pdr (FILE *, poly_dr_p);
......@@ -268,10 +267,9 @@ struct poly_bb
The number of variables in the DOMAIN may change and is not
related to the number of loops in the original code. */
isl_set *domain;
/* The data references we access. */
vec<poly_dr_p> drs;
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
isl_set *iterators;
#else
/* The original scattering. */
isl_map *schedule;
......@@ -280,6 +278,10 @@ struct poly_bb
/* A copy of the transformed scattering. */
isl_map *saved;
#endif
/* The data references we access. */
vec<poly_dr_p> drs;
/* The last basic block generated for this pbb. */
basic_block new_bb;
......@@ -290,8 +292,6 @@ struct poly_bb
#define PBB_DRS(PBB) (PBB->drs)
extern poly_bb_p new_poly_bb (scop_p, gimple_poly_bb_p);
extern void free_poly_bb (poly_bb_p);
extern void debug_loop_vec (poly_bb_p);
extern void print_pbb_domain (FILE *, poly_bb_p);
extern void print_pbb (FILE *, poly_bb_p);
extern void print_scop_context (FILE *, scop_p);
......@@ -313,18 +313,19 @@ 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 print_isl_ast (FILE *, isl_ast_node *);
extern void debug_isl_ast (isl_ast_node *);
extern void debug_isl_set (isl_set *);
extern void debug_isl_map (isl_map *);
extern void debug_isl_union_map (isl_union_map *);
extern void debug_isl_aff (isl_aff *);
extern void debug_isl_constraint (isl_constraint *);
extern int scop_do_interchange (scop_p);
extern int scop_do_strip_mine (scop_p, int);
extern bool scop_do_block (scop_p);
extern bool flatten_all_loops (scop_p);
extern bool optimize_isl (scop_p);
extern void pbb_number_of_iterations_at_time (poly_bb_p, graphite_dim_t, mpz_t);
extern void debug_gmp_value (mpz_t);
extern void debug_scop_pbb (scop_p scop, int i);
extern void print_schedule_ast (FILE *, __isl_keep isl_schedule *, scop_p);
extern void debug_schedule_ast (__isl_keep isl_schedule *, scop_p);
/* The basic block of the PBB. */
......@@ -424,8 +425,16 @@ struct scop
/* The context used internally by isl. */
isl_ctx *isl_context;
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
/* SCoP original schedule. */
isl_schedule *original_schedule;
/* SCoP transformed schedule. */
isl_schedule *transformed_schedule;
#else
/* SCoP final schedule. */
isl_schedule *schedule;
#endif
/* The data dependence relation among the data references in this scop. */
isl_union_map *dependence;
......@@ -435,10 +444,6 @@ extern scop_p new_scop (edge, edge);
extern void free_scop (scop_p);
extern gimple_poly_bb_p new_gimple_poly_bb (basic_block, vec<data_reference_p>,
vec<scalar_use>, vec<tree>);
extern void free_gimple_poly_bb (gimple_poly_bb_p);
extern void print_generated_program (FILE *, scop_p);
extern void debug_generated_program (scop_p);
extern int unify_scattering_dimensions (scop_p);
extern bool apply_poly_transforms (scop_p);
/* Set the region of SCOP to REGION. */
......@@ -465,8 +470,11 @@ scop_set_nb_params (scop_p scop, graphite_dim_t nb_params)
scop->nb_params = nb_params;
}
isl_union_map *
scop_get_dependences (scop_p scop);
#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
extern void scop_get_dependences (scop_p scop);
#else
extern isl_union_map *scop_get_dependences (scop_p scop);
#endif
bool
carries_deps (__isl_keep isl_union_map *schedule,
......@@ -475,9 +483,9 @@ carries_deps (__isl_keep isl_union_map *schedule,
extern bool build_poly_scop (scop_p);
extern bool graphite_regenerate_ast_isl (scop_p);
extern void build_scops (vec<scop_p> *);
extern void dot_all_sese (FILE *, vec<sese_l> &);
extern void dot_sese (sese_l &);
extern void dot_cfg ();
#endif
......@@ -585,3 +585,37 @@ scalar_evolution_in_region (const sese_l &region, loop_p loop, tree t)
return instantiate_scev (before, loop, t);
}
/* Pretty print edge E to FILE. */
void
print_edge (FILE *file, const_edge e)
{
fprintf (file, "edge (bb_%d, bb_%d)", e->src->index, e->dest->index);
}
/* Pretty print sese S to FILE. */
void
print_sese (FILE *file, const sese_l &s)
{
fprintf (file, "(entry_"); print_edge (file, s.entry);
fprintf (file, ", exit_"); print_edge (file, s.exit);
fprintf (file, ")\n");
}
/* Pretty print edge E to STDERR. */
DEBUG_FUNCTION void
debug_edge (const_edge e)
{
print_edge (stderr, e);
}
/* Pretty print sese S to STDERR. */
DEBUG_FUNCTION void
debug_sese (const sese_l &s)
{
print_sese (stderr, s);
}
......@@ -43,6 +43,11 @@ struct sese_l
edge exit;
};
void print_edge (FILE *file, const_edge e);
void print_sese (FILE *file, const sese_l &s);
void dump_edge (const_edge e);
void dump_sese (const sese_l &);
/* Get the entry of an sese S. */
static inline basic_block
......@@ -207,7 +212,7 @@ loop_in_sese_p (struct loop *loop, const sese_l &region)
loop_2 is completely contained -> depth 1 */
static inline unsigned int
sese_loop_depth (sese_l &region, loop_p loop)
sese_loop_depth (const sese_l &region, loop_p loop)
{
unsigned int depth = 0;
......
......@@ -34,4 +34,4 @@ if (n >= k + 1 && k >= 0) {
*/
/* { dg-final { scan-tree-dump-times "if \\\(P_9 >= P_10 \\\+ 1 && P_10 >= 0\\\) \\\{" 1 "graphite" } } */
/* { dg-final { scan-tree-dump "if \\\(P_9 >= P_10 \\\+ 1 && P_10 >= 0\\\) \\\{" "graphite" } } */
......@@ -24,4 +24,4 @@ Program FOO
end Program FOO
! { dg-final { scan-tree-dump-times "unsuccessful, reverting back to the original code." "1" "graphite" } }
! { dg-final { scan-tree-dump-times "codegen error: reverting back to the original code." "1" "graphite" } }
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