fix PR53852: stop ISL after a given number of operations
authorSebastian Pop <spop@gcc.gnu.org>
Wed, 9 Sep 2015 04:20:47 +0000 (04:20 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Wed, 9 Sep 2015 04:20:47 +0000 (04:20 +0000)
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

12 files changed:
gcc/ChangeLog
gcc/config.in
gcc/configure
gcc/configure.ac
gcc/graphite-dependences.c
gcc/graphite-optimize-isl.c
gcc/params.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/uns-interchange-12.c
gcc/testsuite/gcc.dg/graphite/uns-interchange-14.c
gcc/testsuite/gcc.dg/graphite/uns-interchange-15.c
gcc/testsuite/gcc.dg/graphite/uns-interchange-mvt.c

index dbd0bd6ad25db4006548f6209059d4d3cb2b53a0..d697eddadc0f13f8a8a4c9f985a95eecd15cee89 100644 (file)
@@ -1,3 +1,17 @@
+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>
             Sebastian Pop  <s.pop@samsung.com>
 
index 22a4e6b7cb22bd7fc3cc6cc52661c1ac5c12e42a..98c46478a144eecff3b5dfea6cedc26a91e3a135 100644 (file)
 #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
index 0d313831aac55bb013cfb7fc6ded63f20276a9c7..07d39f943934863f7f0beb1f8f65a18202f9a179 100755 (executable)
@@ -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 <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"
   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
 
index 846651d01f98f974ec2c0d035844c232051366a8..b6e8bed843f160cd50a50162ee682ce013e9fb31 100644 (file)
@@ -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.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"
   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
index c3c2090914483effaf432727eb075b1793b06029..85f16f3933b4d1e61232e782fa8ca07bff7e069a 100644 (file)
@@ -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<poly_bb_p> 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,
index ffa44652f63a490c6b469cb26cc75a25cb260a9b..811a510ad21cb3093e311b7136948e4d3d7e52a1 100644 (file)
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include <isl/band.h>
 #include <isl/aff.h>
 #include <isl/options.h>
+#include <isl/ctx.h>
 
 #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;
 }
 
index 11238cbbe7818a8165235af4a931f9c3a190cc4b..34e2025f3d279c1012a07664300eb97617e18326 100644 (file)
@@ -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",
index 7ba0c06ea440c636b8a042914c04dacc0bdb0a44..15c503f43f30287821bcdafa89f1611e0fc7af89 100644 (file)
@@ -1,3 +1,13 @@
+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>
             Sebastian Pop  <s.pop@samsung.com>
 
index d9c07e2fe21eb43cba7bf75aa55ba61ea4892435..4e3c705a13a92af4a7bad6b0519a6740a9293511 100644 (file)
@@ -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" } } */
index 1679cc39997fc3f26caee00792cd37b254dab862..a9d4950a525c5ff94e41c3a0d93c19ba0732dd37 100644 (file)
@@ -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" } } */
index 0e32fd61456aa576d3a1e4c61df3ddd9baf4814e..fe2669f15780a47df2ff122c8961837dcb2388fd 100644 (file)
@@ -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" } } */
index eebece386985d26f6f69067d41cd250542c0c14a..211c9ab82bd60535c50113f1f08de2c8b195bddd 100644 (file)
@@ -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" } } */