isl_union_set_compute_schedule: fix check for progress in feautrier scheduler
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 24 May 2013 09:36:50 +0000 (11:36 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 24 May 2013 10:07:05 +0000 (12:07 +0200)
In carry_dependences we check that we have been able to carry at least
(part of) one dependence relation, by checking that the number of
edges that are not carried is smaller than the total number of edges.
However, we were only looking at the numerator.  If the optimal LP
solution is integral then this happens to work out, but otherwise
we could overestimate the number of non-carried edges, possibly
leading to the wrong conclusion.

Reported-by: Tomofumi Yuki <tomofumi.yuki@gmail.com>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c
isl_test.c

index cd027aa..9760c62 100644 (file)
@@ -2609,6 +2609,7 @@ static int carry_dependences(isl_ctx *ctx, struct isl_sched_graph *graph)
                        "error in schedule construction", return -1);
        }
 
+       isl_int_divexact(sol->el[1], sol->el[1], sol->el[0]);
        if (isl_int_cmp_si(sol->el[1], n_edge) >= 0) {
                isl_vec_free(sol);
                isl_die(ctx, isl_error_unknown,
index 951ac75..fb6a5f4 100644 (file)
@@ -2662,6 +2662,20 @@ int test_schedule(isl_ctx *ctx)
        if (test_padded_schedule(ctx) < 0)
                return -1;
 
+       /* Check that check for progress is not confused by rational
+        * solution.
+        */
+       D = "[N] -> { S0[i, j] : i >= 0 and i <= N and j >= 0 and j <= N }";
+       V = "[N] -> { S0[i0, -1 + N] -> S0[2 + i0, 0] : i0 >= 0 and "
+                                                       "i0 <= -2 + N; "
+                       "S0[i0, i1] -> S0[i0, 1 + i1] : i0 >= 0 and "
+                               "i0 <= N and i1 >= 0 and i1 <= -1 + N }";
+       P = "{}";
+       ctx->opt->schedule_algorithm = ISL_SCHEDULE_ALGORITHM_FEAUTRIER;
+       if (test_has_schedule(ctx, D, V, P) < 0)
+               return -1;
+       ctx->opt->schedule_algorithm = ISL_SCHEDULE_ALGORITHM_ISL;
+
        return 0;
 }