Commit 6b3ebcdd by Sebastian Pop

fix PR53852: stop ISL after a given number of operations

2015-09-02  Sebastian Pop  <s.pop@samsung.com>

            * config.in: Regenerate.
            * configure: Regenerate.
            * configure.ac (HAVE_ISL_CTX_MAX_OPERATIONS): Detect.
            * graphite-optimize-isl.c (optimize_isl): Stop computation when
            PARAM_MAX_ISL_OPERATIONS is reached.
            * params.def (PARAM_MAX_ISL_OPERATIONS): Add.

            * graphite-dependences.c (extend_schedule): Remove gcc_asserts on
            result equal to isl_stat_ok as the status now can be isl_error_quota.
            (subtract_commutative_associative_deps): Same.
            (compute_deps): Same.

testsuite/
            * gcc.dg/graphite/uns-interchange-12.c: Adjust pattern to pass with
            both isl-0.12 and isl-0.15.
            * gcc.dg/graphite/uns-interchange-14.c: Same.
            * gcc.dg/graphite/uns-interchange-15.c: Same.
            * gcc.dg/graphite/uns-interchange-mvt.c: Same.

From-SVN: r227572
parent b81c3156
2015-09-09 Sebastian Pop <s.pop@samsung.com>
PR tree-optimization/53852
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (HAVE_ISL_CTX_MAX_OPERATIONS): Detect.
* graphite-optimize-isl.c (optimize_isl): Stop computation when
PARAM_MAX_ISL_OPERATIONS is reached.
* params.def (PARAM_MAX_ISL_OPERATIONS): Add.
* graphite-dependences.c (extend_schedule): Remove gcc_asserts on
result equal to isl_stat_ok as the status now can be isl_error_quota.
(subtract_commutative_associative_deps): Same.
(compute_deps): Same.
2015-09-08 Aditya Kumar <hiraditya@msn.com> 2015-09-08 Aditya Kumar <hiraditya@msn.com>
Sebastian Pop <s.pop@samsung.com> Sebastian Pop <s.pop@samsung.com>
......
...@@ -1332,6 +1332,12 @@ ...@@ -1332,6 +1332,12 @@
#endif #endif
/* Define if isl_ctx_get_max_operations exists. */
#ifndef USED_FOR_TARGET
#undef HAVE_ISL_CTX_MAX_OPERATIONS
#endif
/* Define if isl_options_set_schedule_serialize_sccs exists. */ /* Define if isl_options_set_schedule_serialize_sccs exists. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS #undef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
......
...@@ -28625,6 +28625,29 @@ rm -f core conftest.err conftest.$ac_objext \ ...@@ -28625,6 +28625,29 @@ rm -f core conftest.err conftest.$ac_objext \
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_has_isl_options_set_schedule_serialize_sccs" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_has_isl_options_set_schedule_serialize_sccs" >&5
$as_echo "$ac_has_isl_options_set_schedule_serialize_sccs" >&6; } $as_echo "$ac_has_isl_options_set_schedule_serialize_sccs" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Checking for isl_ctx_get_max_operations" >&5
$as_echo_n "checking Checking for isl_ctx_get_max_operations... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <isl/ctx.h>
int
main ()
{
isl_ctx_get_max_operations (isl_ctx_alloc ());
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
ac_has_isl_ctx_get_max_operations=yes
else
ac_has_isl_ctx_get_max_operations=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_has_isl_ctx_get_max_operations" >&5
$as_echo "$ac_has_isl_ctx_get_max_operations" >&6; }
LIBS="$saved_LIBS" LIBS="$saved_LIBS"
CXXFLAGS="$saved_CXXFLAGS" CXXFLAGS="$saved_CXXFLAGS"
...@@ -28639,6 +28662,11 @@ $as_echo "#define HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE 1" >>confdefs.h ...@@ -28639,6 +28662,11 @@ $as_echo "#define HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE 1" >>confdefs.h
$as_echo "#define HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS 1" >>confdefs.h $as_echo "#define HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS 1" >>confdefs.h
fi fi
if test x"$ac_has_isl_ctx_get_max_operations" = x"yes"; then
$as_echo "#define HAVE_ISL_CTX_MAX_OPERATIONS 1" >>confdefs.h
fi
fi fi
# Check for plugin support # Check for plugin support
......
...@@ -5790,6 +5790,13 @@ if test "x${ISLLIBS}" != "x" ; then ...@@ -5790,6 +5790,13 @@ if test "x${ISLLIBS}" != "x" ; then
[ac_has_isl_options_set_schedule_serialize_sccs=no]) [ac_has_isl_options_set_schedule_serialize_sccs=no])
AC_MSG_RESULT($ac_has_isl_options_set_schedule_serialize_sccs) AC_MSG_RESULT($ac_has_isl_options_set_schedule_serialize_sccs)
AC_MSG_CHECKING([Checking for isl_ctx_get_max_operations])
AC_TRY_LINK([#include <isl/ctx.h>],
[isl_ctx_get_max_operations (isl_ctx_alloc ());],
[ac_has_isl_ctx_get_max_operations=yes],
[ac_has_isl_ctx_get_max_operations=no])
AC_MSG_RESULT($ac_has_isl_ctx_get_max_operations)
LIBS="$saved_LIBS" LIBS="$saved_LIBS"
CXXFLAGS="$saved_CXXFLAGS" CXXFLAGS="$saved_CXXFLAGS"
...@@ -5802,6 +5809,10 @@ if test "x${ISLLIBS}" != "x" ; then ...@@ -5802,6 +5809,10 @@ if test "x${ISLLIBS}" != "x" ; then
AC_DEFINE(HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS, 1, AC_DEFINE(HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS, 1,
[Define if isl_options_set_schedule_serialize_sccs exists.]) [Define if isl_options_set_schedule_serialize_sccs exists.])
fi fi
if test x"$ac_has_isl_ctx_get_max_operations" = x"yes"; then
AC_DEFINE(HAVE_ISL_CTX_MAX_OPERATIONS, 1,
[Define if isl_ctx_get_max_operations exists.])
fi
fi fi
GCC_ENABLE_PLUGINS GCC_ENABLE_PLUGINS
......
...@@ -256,17 +256,12 @@ __isl_give isl_union_map * ...@@ -256,17 +256,12 @@ __isl_give isl_union_map *
extend_schedule (__isl_take isl_union_map *x) extend_schedule (__isl_take isl_union_map *x)
{ {
int max = 0; int max = 0;
isl_stat res;
struct extend_schedule_str str; struct extend_schedule_str str;
res = isl_union_map_foreach_map (x, max_number_of_out_dimensions, (void *) &max); isl_union_map_foreach_map (x, max_number_of_out_dimensions, (void *) &max);
gcc_assert (res == isl_stat_ok);
str.max = max; str.max = max;
str.umap = isl_union_map_empty (isl_union_map_get_space (x)); str.umap = isl_union_map_empty (isl_union_map_get_space (x));
res = isl_union_map_foreach_map (x, extend_schedule_1, (void *) &str); isl_union_map_foreach_map (x, extend_schedule_1, (void *) &str);
gcc_assert (res == isl_stat_ok);
isl_union_map_free (x); isl_union_map_free (x);
return str.umap; return str.umap;
} }
...@@ -395,7 +390,6 @@ subtract_commutative_associative_deps (scop_p scop, ...@@ -395,7 +390,6 @@ subtract_commutative_associative_deps (scop_p scop,
FOR_EACH_VEC_ELT (pbbs, i, pbb) FOR_EACH_VEC_ELT (pbbs, i, pbb)
if (PBB_IS_REDUCTION (pbb)) if (PBB_IS_REDUCTION (pbb))
{ {
int res;
isl_union_map *r = isl_union_map_empty (isl_space_copy (space)); isl_union_map *r = isl_union_map_empty (isl_space_copy (space));
isl_union_map *must_w = isl_union_map_empty (isl_space_copy (space)); isl_union_map *must_w = isl_union_map_empty (isl_space_copy (space));
isl_union_map *may_w = isl_union_map_empty (isl_space_copy (space)); isl_union_map *may_w = isl_union_map_empty (isl_space_copy (space));
...@@ -432,27 +426,24 @@ subtract_commutative_associative_deps (scop_p scop, ...@@ -432,27 +426,24 @@ subtract_commutative_associative_deps (scop_p scop,
(isl_union_map_copy (must_w), isl_union_map_copy (may_w)); (isl_union_map_copy (must_w), isl_union_map_copy (may_w));
empty = isl_union_map_empty (isl_union_map_get_space (all_w)); empty = isl_union_map_empty (isl_union_map_get_space (all_w));
res = isl_union_map_compute_flow (isl_union_map_copy (r), isl_union_map_compute_flow (isl_union_map_copy (r),
isl_union_map_copy (must_w), isl_union_map_copy (must_w),
isl_union_map_copy (may_w), isl_union_map_copy (may_w),
isl_union_map_copy (original), isl_union_map_copy (original),
&x_must_raw, &x_may_raw, &x_must_raw, &x_may_raw,
&x_must_raw_no_source, &x_must_raw_no_source,
&x_may_raw_no_source); &x_may_raw_no_source);
gcc_assert (res == 0); isl_union_map_compute_flow (isl_union_map_copy (all_w),
res = isl_union_map_compute_flow (isl_union_map_copy (all_w),
r, empty, r, empty,
isl_union_map_copy (original), isl_union_map_copy (original),
&x_must_war, &x_may_war, &x_must_war, &x_may_war,
&x_must_war_no_source, &x_must_war_no_source,
&x_may_war_no_source); &x_may_war_no_source);
gcc_assert (res == 0); isl_union_map_compute_flow (all_w, must_w, may_w,
res = isl_union_map_compute_flow (all_w, must_w, may_w,
isl_union_map_copy (original), isl_union_map_copy (original),
&x_must_waw, &x_may_waw, &x_must_waw, &x_may_waw,
&x_must_waw_no_source, &x_must_waw_no_source,
&x_may_waw_no_source); &x_may_waw_no_source);
gcc_assert (res == 0);
if (must_raw) if (must_raw)
*must_raw = isl_union_map_subtract (*must_raw, x_must_raw); *must_raw = isl_union_map_subtract (*must_raw, x_must_raw);
...@@ -551,26 +542,22 @@ compute_deps (scop_p scop, vec<poly_bb_p> pbbs, ...@@ -551,26 +542,22 @@ compute_deps (scop_p scop, vec<poly_bb_p> pbbs,
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);
int res;
res = isl_union_map_compute_flow (isl_union_map_copy (reads), isl_union_map_compute_flow (isl_union_map_copy (reads),
isl_union_map_copy (must_writes), isl_union_map_copy (must_writes),
isl_union_map_copy (may_writes), isl_union_map_copy (may_writes),
isl_union_map_copy (original), isl_union_map_copy (original),
must_raw, may_raw, must_raw_no_source, must_raw, may_raw, must_raw_no_source,
may_raw_no_source); may_raw_no_source);
gcc_assert (res == 0); isl_union_map_compute_flow (isl_union_map_copy (all_writes),
res = isl_union_map_compute_flow (isl_union_map_copy (all_writes),
reads, empty, reads, empty,
isl_union_map_copy (original), isl_union_map_copy (original),
must_war, may_war, must_war_no_source, must_war, may_war, must_war_no_source,
may_war_no_source); may_war_no_source);
gcc_assert (res == 0); isl_union_map_compute_flow (all_writes, must_writes, may_writes,
res = isl_union_map_compute_flow (all_writes, must_writes, may_writes,
isl_union_map_copy (original), isl_union_map_copy (original),
must_waw, may_waw, must_waw_no_source, must_waw, may_waw, must_waw_no_source,
may_waw_no_source); may_waw_no_source);
gcc_assert (res == 0);
subtract_commutative_associative_deps subtract_commutative_associative_deps
(scop, pbbs, original, (scop, pbbs, original,
......
...@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include <isl/band.h> #include <isl/band.h>
#include <isl/aff.h> #include <isl/aff.h>
#include <isl/options.h> #include <isl/options.h>
#include <isl/ctx.h>
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
...@@ -422,26 +423,25 @@ static const int CONSTANT_BOUND = 20; ...@@ -422,26 +423,25 @@ static const int CONSTANT_BOUND = 20;
bool bool
optimize_isl (scop_p scop) optimize_isl (scop_p scop)
{ {
#ifdef HAVE_ISL_CTX_MAX_OPERATIONS
isl_schedule *schedule; int old_max_operations = isl_ctx_get_max_operations(scop->ctx);
#ifdef HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE int max_operations = PARAM_VALUE (PARAM_MAX_ISL_OPERATIONS);
isl_schedule_constraints *schedule_constraints; if (max_operations)
isl_ctx_set_max_operations(scop->ctx, max_operations);
#endif #endif
isl_union_set *domain; isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_CONTINUE);
isl_union_map *validity, *proximity, *dependences;
isl_union_map *schedule_map;
domain = scop_get_domains (scop); isl_union_set *domain = scop_get_domains (scop);
dependences = scop_get_dependences (scop); isl_union_map *dependences = scop_get_dependences (scop);
dependences = isl_union_map_gist_domain (dependences, dependences = isl_union_map_gist_domain (dependences,
isl_union_set_copy (domain)); isl_union_set_copy (domain));
dependences = isl_union_map_gist_range (dependences, dependences = isl_union_map_gist_range (dependences,
isl_union_set_copy (domain)); isl_union_set_copy (domain));
validity = dependences; isl_union_map *validity = dependences;
isl_union_map *proximity = isl_union_map_copy (validity);
proximity = isl_union_map_copy (validity);
#ifdef HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE #ifdef HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE
isl_schedule_constraints *schedule_constraints;
schedule_constraints = isl_schedule_constraints_on_domain (domain); schedule_constraints = isl_schedule_constraints_on_domain (domain);
schedule_constraints schedule_constraints
= isl_schedule_constraints_set_proximity (schedule_constraints, = isl_schedule_constraints_set_proximity (schedule_constraints,
...@@ -461,26 +461,39 @@ optimize_isl (scop_p scop) ...@@ -461,26 +461,39 @@ optimize_isl (scop_p scop)
#else #else
isl_options_set_schedule_fuse (scop->ctx, ISL_SCHEDULE_FUSE_MIN); isl_options_set_schedule_fuse (scop->ctx, ISL_SCHEDULE_FUSE_MIN);
#endif #endif
isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_CONTINUE);
#ifdef HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE #ifdef HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE
schedule = isl_schedule_constraints_compute_schedule(schedule_constraints); isl_schedule *schedule
= isl_schedule_constraints_compute_schedule (schedule_constraints);
#else #else
schedule = isl_union_set_compute_schedule (domain, validity, proximity); isl_schedule *schedule
= isl_union_set_compute_schedule (domain, validity, proximity);
#endif #endif
isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_ABORT); isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_ABORT);
#ifdef HAVE_ISL_CTX_MAX_OPERATIONS
isl_ctx_reset_operations(scop->ctx);
isl_ctx_set_max_operations(scop->ctx, old_max_operations);
if (!schedule || isl_ctx_last_error (scop->ctx) == isl_error_quota)
{
if (dump_file && dump_flags)
fprintf (dump_file, "ISL timed out at %d operations\n",
max_operations);
if (schedule)
isl_schedule_free (schedule);
return false;
}
#else
if (!schedule) if (!schedule)
return false; return false;
#endif
schedule_map = getScheduleMap (schedule); isl_union_map *schedule_map = getScheduleMap (schedule);
apply_schedule_map_to_scop (scop, schedule_map); apply_schedule_map_to_scop (scop, schedule_map);
isl_schedule_free (schedule); isl_schedule_free (schedule);
isl_union_map_free (schedule_map); isl_union_map_free (schedule_map);
return true; return true;
} }
......
...@@ -844,6 +844,11 @@ DEFPARAM (PARAM_GRAPHITE_MAX_BBS_PER_FUNCTION, ...@@ -844,6 +844,11 @@ DEFPARAM (PARAM_GRAPHITE_MAX_BBS_PER_FUNCTION,
"maximum number of basic blocks per function to be analyzed by Graphite", "maximum number of basic blocks per function to be analyzed by Graphite",
100, 0, 0) 100, 0, 0)
DEFPARAM (PARAM_MAX_ISL_OPERATIONS,
"max-isl-operations",
"maximum number of ISL operations, 0 means unlimited",
350000, 0, 0)
/* Avoid data dependence analysis on very large loops. */ /* Avoid data dependence analysis on very large loops. */
DEFPARAM (PARAM_LOOP_MAX_DATAREFS_FOR_DATADEPS, DEFPARAM (PARAM_LOOP_MAX_DATAREFS_FOR_DATADEPS,
"loop-max-datarefs-for-datadeps", "loop-max-datarefs-for-datadeps",
......
2015-09-09 Aditya Kumar <hiraditya@msn.com>
Sebastian Pop <s.pop@samsung.com>
PR tree-optimization/53852
* gcc.dg/graphite/uns-interchange-12.c: Adjust pattern to pass with
both isl-0.12 and isl-0.15.
* gcc.dg/graphite/uns-interchange-14.c: Same.
* gcc.dg/graphite/uns-interchange-15.c: Same.
* gcc.dg/graphite/uns-interchange-mvt.c: Same.
2015-09-08 Aditya Kumar <hiraditya@msn.com> 2015-09-08 Aditya Kumar <hiraditya@msn.com>
Sebastian Pop <s.pop@samsung.com> Sebastian Pop <s.pop@samsung.com>
......
...@@ -54,4 +54,4 @@ main (void) ...@@ -54,4 +54,4 @@ main (void)
return 0; return 0;
} }
/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ /* { dg-final { scan-tree-dump "tiled by" "graphite" } } */
...@@ -55,4 +55,4 @@ main (void) ...@@ -55,4 +55,4 @@ main (void)
return 0; return 0;
} }
/* { dg-final { scan-tree-dump-times "tiled by" 5 "graphite" } } */ /* { dg-final { scan-tree-dump "tiled by" "graphite" } } */
...@@ -49,4 +49,4 @@ main (void) ...@@ -49,4 +49,4 @@ main (void)
return 0; return 0;
} }
/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ /* { dg-final { scan-tree-dump "tiled by" "graphite" } } */
...@@ -59,4 +59,4 @@ main (void) ...@@ -59,4 +59,4 @@ main (void)
return 0; return 0;
} }
/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ /* { dg-final { scan-tree-dump "tiled by" "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