From: Sebastian Pop Date: Wed, 9 Sep 2015 04:20:47 +0000 (+0000) Subject: fix PR53852: stop ISL after a given number of operations X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6b3ebcdda18d2b6b0e2bf3857726ab02fbac5ad4;p=gcc.git fix PR53852: stop ISL after a given number of operations 2015-09-02 Sebastian Pop * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dbd0bd6ad25..d697eddadc0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2015-09-09 Sebastian Pop + + 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 Sebastian Pop diff --git a/gcc/config.in b/gcc/config.in index 22a4e6b7cb2..98c46478a14 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1332,6 +1332,12 @@ #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. */ #ifndef USED_FOR_TARGET #undef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS diff --git a/gcc/configure b/gcc/configure index 0d313831aac..07d39f94393 100755 --- a/gcc/configure +++ b/gcc/configure @@ -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 "$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 +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" CXXFLAGS="$saved_CXXFLAGS" @@ -28638,6 +28661,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 + 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 diff --git a/gcc/configure.ac b/gcc/configure.ac index 846651d01f9..b6e8bed843f 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5790,6 +5790,13 @@ if test "x${ISLLIBS}" != "x" ; then [ac_has_isl_options_set_schedule_serialize_sccs=no]) 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_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" CXXFLAGS="$saved_CXXFLAGS" @@ -5802,6 +5809,10 @@ if test "x${ISLLIBS}" != "x" ; then AC_DEFINE(HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS, 1, [Define if isl_options_set_schedule_serialize_sccs exists.]) 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 GCC_ENABLE_PLUGINS diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c index c3c20909144..85f16f3933b 100644 --- a/gcc/graphite-dependences.c +++ b/gcc/graphite-dependences.c @@ -256,17 +256,12 @@ __isl_give isl_union_map * extend_schedule (__isl_take isl_union_map *x) { int max = 0; - isl_stat res; struct extend_schedule_str str; - res = isl_union_map_foreach_map (x, max_number_of_out_dimensions, (void *) &max); - gcc_assert (res == isl_stat_ok); - + isl_union_map_foreach_map (x, max_number_of_out_dimensions, (void *) &max); str.max = max; str.umap = isl_union_map_empty (isl_union_map_get_space (x)); - res = isl_union_map_foreach_map (x, extend_schedule_1, (void *) &str); - gcc_assert (res == isl_stat_ok); - + isl_union_map_foreach_map (x, extend_schedule_1, (void *) &str); isl_union_map_free (x); return str.umap; } @@ -395,7 +390,6 @@ subtract_commutative_associative_deps (scop_p scop, FOR_EACH_VEC_ELT (pbbs, i, pbb) if (PBB_IS_REDUCTION (pbb)) { - int res; 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 *may_w = isl_union_map_empty (isl_space_copy (space)); @@ -432,27 +426,24 @@ subtract_commutative_associative_deps (scop_p scop, (isl_union_map_copy (must_w), isl_union_map_copy (may_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_copy (must_w), - isl_union_map_copy (may_w), - isl_union_map_copy (original), - &x_must_raw, &x_may_raw, - &x_must_raw_no_source, - &x_may_raw_no_source); - gcc_assert (res == 0); - res = isl_union_map_compute_flow (isl_union_map_copy (all_w), - r, empty, - isl_union_map_copy (original), - &x_must_war, &x_may_war, - &x_must_war_no_source, - &x_may_war_no_source); - gcc_assert (res == 0); - res = isl_union_map_compute_flow (all_w, must_w, may_w, - isl_union_map_copy (original), - &x_must_waw, &x_may_waw, - &x_must_waw_no_source, - &x_may_waw_no_source); - gcc_assert (res == 0); + isl_union_map_compute_flow (isl_union_map_copy (r), + isl_union_map_copy (must_w), + isl_union_map_copy (may_w), + isl_union_map_copy (original), + &x_must_raw, &x_may_raw, + &x_must_raw_no_source, + &x_may_raw_no_source); + isl_union_map_compute_flow (isl_union_map_copy (all_w), + r, empty, + isl_union_map_copy (original), + &x_must_war, &x_may_war, + &x_must_war_no_source, + &x_may_war_no_source); + isl_union_map_compute_flow (all_w, must_w, may_w, + isl_union_map_copy (original), + &x_must_waw, &x_may_waw, + &x_must_waw_no_source, + &x_may_waw_no_source); if (must_raw) *must_raw = isl_union_map_subtract (*must_raw, x_must_raw); @@ -551,26 +542,22 @@ compute_deps (scop_p scop, vec pbbs, 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); - int res; - res = isl_union_map_compute_flow (isl_union_map_copy (reads), - isl_union_map_copy (must_writes), - isl_union_map_copy (may_writes), - isl_union_map_copy (original), - must_raw, may_raw, must_raw_no_source, - may_raw_no_source); - gcc_assert (res == 0); - res = isl_union_map_compute_flow (isl_union_map_copy (all_writes), - reads, empty, - isl_union_map_copy (original), - must_war, may_war, must_war_no_source, - may_war_no_source); - gcc_assert (res == 0); - res = isl_union_map_compute_flow (all_writes, must_writes, may_writes, - isl_union_map_copy (original), - must_waw, may_waw, must_waw_no_source, - may_waw_no_source); - gcc_assert (res == 0); + isl_union_map_compute_flow (isl_union_map_copy (reads), + isl_union_map_copy (must_writes), + isl_union_map_copy (may_writes), + isl_union_map_copy (original), + must_raw, may_raw, must_raw_no_source, + may_raw_no_source); + isl_union_map_compute_flow (isl_union_map_copy (all_writes), + reads, empty, + isl_union_map_copy (original), + must_war, may_war, must_war_no_source, + may_war_no_source); + isl_union_map_compute_flow (all_writes, must_writes, may_writes, + isl_union_map_copy (original), + must_waw, may_waw, must_waw_no_source, + may_waw_no_source); subtract_commutative_associative_deps (scop, pbbs, original, diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c index ffa44652f63..811a510ad21 100644 --- a/gcc/graphite-optimize-isl.c +++ b/gcc/graphite-optimize-isl.c @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include #include #include +#include #include "system.h" #include "coretypes.h" @@ -422,26 +423,25 @@ static const int CONSTANT_BOUND = 20; bool optimize_isl (scop_p scop) { - - isl_schedule *schedule; -#ifdef HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE - isl_schedule_constraints *schedule_constraints; +#ifdef HAVE_ISL_CTX_MAX_OPERATIONS + int old_max_operations = isl_ctx_get_max_operations(scop->ctx); + int max_operations = PARAM_VALUE (PARAM_MAX_ISL_OPERATIONS); + if (max_operations) + isl_ctx_set_max_operations(scop->ctx, max_operations); #endif - isl_union_set *domain; - isl_union_map *validity, *proximity, *dependences; - isl_union_map *schedule_map; + isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_CONTINUE); - domain = scop_get_domains (scop); - dependences = scop_get_dependences (scop); + isl_union_set *domain = scop_get_domains (scop); + isl_union_map *dependences = scop_get_dependences (scop); dependences = isl_union_map_gist_domain (dependences, isl_union_set_copy (domain)); dependences = isl_union_map_gist_range (dependences, isl_union_set_copy (domain)); - validity = dependences; - - proximity = isl_union_map_copy (validity); + isl_union_map *validity = dependences; + isl_union_map *proximity = isl_union_map_copy (validity); #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_set_proximity (schedule_constraints, @@ -461,26 +461,39 @@ optimize_isl (scop_p scop) #else isl_options_set_schedule_fuse (scop->ctx, ISL_SCHEDULE_FUSE_MIN); #endif - isl_options_set_on_error (scop->ctx, ISL_ON_ERROR_CONTINUE); #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 - schedule = isl_union_set_compute_schedule (domain, validity, proximity); + isl_schedule *schedule + = isl_union_set_compute_schedule (domain, validity, proximity); #endif 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) return false; +#endif - schedule_map = getScheduleMap (schedule); - + isl_union_map *schedule_map = getScheduleMap (schedule); apply_schedule_map_to_scop (scop, schedule_map); isl_schedule_free (schedule); isl_union_map_free (schedule_map); - return true; } diff --git a/gcc/params.def b/gcc/params.def index 11238cbbe78..34e2025f3d2 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -844,6 +844,11 @@ DEFPARAM (PARAM_GRAPHITE_MAX_BBS_PER_FUNCTION, "maximum number of basic blocks per function to be analyzed by Graphite", 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. */ DEFPARAM (PARAM_LOOP_MAX_DATAREFS_FOR_DATADEPS, "loop-max-datarefs-for-datadeps", diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7ba0c06ea44..15c503f43f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2015-09-09 Aditya Kumar + Sebastian Pop + + 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 Sebastian Pop diff --git a/gcc/testsuite/gcc.dg/graphite/uns-interchange-12.c b/gcc/testsuite/gcc.dg/graphite/uns-interchange-12.c index d9c07e2fe21..4e3c705a13a 100644 --- a/gcc/testsuite/gcc.dg/graphite/uns-interchange-12.c +++ b/gcc/testsuite/gcc.dg/graphite/uns-interchange-12.c @@ -54,4 +54,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 4 "graphite" } } */ +/* { dg-final { scan-tree-dump "tiled by" "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/uns-interchange-14.c b/gcc/testsuite/gcc.dg/graphite/uns-interchange-14.c index 1679cc39997..a9d4950a525 100644 --- a/gcc/testsuite/gcc.dg/graphite/uns-interchange-14.c +++ b/gcc/testsuite/gcc.dg/graphite/uns-interchange-14.c @@ -55,4 +55,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 5 "graphite" } } */ +/* { dg-final { scan-tree-dump "tiled by" "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/uns-interchange-15.c b/gcc/testsuite/gcc.dg/graphite/uns-interchange-15.c index 0e32fd61456..fe2669f1578 100644 --- a/gcc/testsuite/gcc.dg/graphite/uns-interchange-15.c +++ b/gcc/testsuite/gcc.dg/graphite/uns-interchange-15.c @@ -49,4 +49,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 2 "graphite" } } */ +/* { dg-final { scan-tree-dump "tiled by" "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/uns-interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/uns-interchange-mvt.c index eebece38698..211c9ab82bd 100644 --- a/gcc/testsuite/gcc.dg/graphite/uns-interchange-mvt.c +++ b/gcc/testsuite/gcc.dg/graphite/uns-interchange-mvt.c @@ -59,4 +59,4 @@ main (void) return 0; } -/* { dg-final { scan-tree-dump-times "tiled by" 3 "graphite" } } */ +/* { dg-final { scan-tree-dump "tiled by" "graphite" } } */