X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_test.c;h=d6b6f1bf0a1164d8a412ed0240f660dc63bebf57;hb=fe42f67de98fd6eb7e7b6a0a0d5df9711059ae99;hp=a07fe856da282b2dc6ac24364a8665b727cc9962;hpb=d5807900e1fcb817fd0d029f52876a75f32f74b3;p=platform%2Fupstream%2Fisl.git diff --git a/isl_test.c b/isl_test.c index a07fe85..d6b6f1b 100644 --- a/isl_test.c +++ b/isl_test.c @@ -292,7 +292,10 @@ void test_div(struct isl_ctx *ctx) isl_constraint_set_coefficient(c, isl_dim_div, pos, v); bset = isl_basic_set_add_constraint(bset, c); + /* Test disabled for now */ + /* assert(bset->n_div == 1); + */ isl_basic_set_free(bset); /* test 8 */ @@ -321,7 +324,10 @@ void test_div(struct isl_ctx *ctx) isl_constraint_set_constant(c, v); bset = isl_basic_set_add_constraint(bset, c); + /* Test disabled for now */ + /* assert(bset->n_div == 1); + */ isl_basic_set_free(bset); /* test 9 */ @@ -476,6 +482,9 @@ void test_convex_hull_case(struct isl_ctx *ctx, const char *name) void test_convex_hull(struct isl_ctx *ctx) { + const char *str1, *str2; + isl_set *set1, *set2; + test_convex_hull_case(ctx, "convex0"); test_convex_hull_case(ctx, "convex1"); test_convex_hull_case(ctx, "convex2"); @@ -491,6 +500,18 @@ void test_convex_hull(struct isl_ctx *ctx) test_convex_hull_case(ctx, "convex12"); test_convex_hull_case(ctx, "convex13"); test_convex_hull_case(ctx, "convex14"); + test_convex_hull_case(ctx, "convex15"); + + str1 = "{ [i0, i1, i2] : (i2 = 1 and i0 = 0 and i1 >= 0) or " + "(i0 = 1 and i1 = 0 and i2 = 1) or " + "(i0 = 0 and i1 = 0 and i2 = 0) }"; + str2 = "{ [i0, i1, i2] : i0 >= 0 and i2 >= i0 and i2 <= 1 and i1 >= 0 }"; + set1 = isl_set_read_from_str(ctx, str1, -1); + set2 = isl_set_read_from_str(ctx, str2, -1); + set1 = isl_set_from_basic_set(isl_set_convex_hull(set1)); + assert(isl_set_is_equal(set1, set2)); + isl_set_free(set1); + isl_set_free(set2); } void test_gist_case(struct isl_ctx *ctx, const char *name) @@ -528,7 +549,9 @@ void test_gist(struct isl_ctx *ctx) void test_coalesce(struct isl_ctx *ctx) { + const char *str; struct isl_set *set, *set2; + struct isl_map *map, *map2; set = isl_set_read_from_str(ctx, "{[x,y]: x >= 0 & x <= 10 & y >= 0 & y <= 10 or " @@ -635,10 +658,109 @@ void test_coalesce(struct isl_ctx *ctx) assert(isl_set_is_equal(set, set2)); isl_set_free(set); isl_set_free(set2); + + map = isl_map_read_from_str(ctx, + "[n] -> { [i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], " + "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], " + "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and " + "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and " + "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and " + "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and " + "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and " + "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);" + "[i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], " + "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], " + "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and " + "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and " + "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and " + "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and " + "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and " + "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and " + "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and " + "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }", -1); + map = isl_map_coalesce(map); + map2 = isl_map_read_from_str(ctx, + "[n] -> { [i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], " + "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], " + "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and " + "4e4 = -2 + o0 and i0 >= 8 + 2n and o0 >= 2 + i0 and " + "o0 <= 56 + 2n and o0 <= -12 + 4n and i0 <= 57 + 2n and " + "i0 <= -11 + 4n and o0 >= 6 + 2n and 4e0 <= i0 and " + "4e0 >= -3 + i0 and 4e1 <= o0 and 4e1 >= -3 + o0 and " + "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0);" + "[i0] -> [o0] : exists (e0 = [(i0)/4], e1 = [(o0)/4], " + "e2 = [(n)/2], e3 = [(-2 + i0)/4], e4 = [(-2 + o0)/4], " + "e5 = [(-2n + i0)/4]: 2e2 = n and 4e3 = -2 + i0 and " + "4e4 = -2 + o0 and 2e0 >= 3 + n and e0 <= -4 + n and " + "2e0 <= 27 + n and e1 <= -4 + n and 2e1 <= 27 + n and " + "2e1 >= 2 + n and e1 >= 1 + e0 and i0 >= 7 + 2n and " + "i0 <= -11 + 4n and i0 <= 57 + 2n and 4e0 <= -2 + i0 and " + "4e0 >= -3 + i0 and o0 >= 6 + 2n and o0 <= -11 + 4n and " + "o0 <= 57 + 2n and 4e1 <= -2 + o0 and 4e1 >= -3 + o0 and " + "4e5 <= -2n + i0 and 4e5 >= -3 - 2n + i0 ) }", -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); + + str = "[n, m] -> { [] -> [o0, o2, o3] : (o3 = 1 and o0 >= 1 + m and " + "o0 <= n + m and o2 <= m and o0 >= 2 + n and o2 >= 3) or " + "(o0 >= 2 + n and o0 >= 1 + m and o0 <= n + m and n >= 1 and " + "o3 <= -1 + o2 and o3 >= 1 - m + o2 and o3 >= 2 and o3 <= n) }"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_coalesce(map); + map2 = isl_map_read_from_str(ctx, str, -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); + + str = "[M, N] -> { [i0, i1, i2, i3, i4, i5, i6] -> " + "[o0, o1, o2, o3, o4, o5, o6] : " + "(o6 <= -4 + 2M - 2N + i0 + i1 - i2 + i6 - o0 - o1 + o2 and " + "o3 <= -2 + i3 and o6 >= 2 + i0 + i3 + i6 - o0 - o3 and " + "o6 >= 2 - M + N + i3 + i4 + i6 - o3 - o4 and o0 <= -1 + i0 and " + "o4 >= 4 - 3M + 3N - i0 - i1 + i2 + 2i3 + i4 + o0 + o1 - o2 - 2o3 " + "and o6 <= -3 + 2M - 2N + i3 + i4 - i5 + i6 - o3 - o4 + o5 and " + "2o6 <= -5 + 5M - 5N + 2i0 + i1 - i2 - i5 + 2i6 - 2o0 - o1 + o2 + o5 " + "and o6 >= 2i0 + i1 + i6 - 2o0 - o1 and " + "3o6 <= -5 + 4M - 4N + 2i0 + i1 - i2 + 2i3 + i4 - i5 + 3i6 " + "- 2o0 - o1 + o2 - 2o3 - o4 + o5) or " + "(N >= 2 and o3 <= -1 + i3 and o0 <= -1 + i0 and " + "o6 >= i3 + i6 - o3 and M >= 0 and " + "2o6 >= 1 + i0 + i3 + 2i6 - o0 - o3 and " + "o6 >= 1 - M + i0 + i6 - o0 and N >= 2M and o6 >= i0 + i6 - o0) }"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_coalesce(map); + map2 = isl_map_read_from_str(ctx, str, -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); + + str = "[M, N] -> { [] -> [o0] : (o0 = 0 and M >= 1 and N >= 2) or " + "(o0 = 0 and M >= 1 and N >= 2M and N >= 2 + M) or " + "(o0 = 0 and M >= 2 and N >= 3) or " + "(M = 0 and o0 = 0 and N >= 3) }"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_coalesce(map); + map2 = isl_map_read_from_str(ctx, str, -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); + + str = "{ [i0, i1, i2, i3] : (i1 = 10i0 and i0 >= 1 and 10i0 <= 100 and " + "i3 <= 9 + 10 i2 and i3 >= 1 + 10i2 and i3 >= 0) or " + "(i1 <= 9 + 10i0 and i1 >= 1 + 10i0 and i2 >= 0 and " + "i0 >= 0 and i1 <= 100 and i3 <= 9 + 10i2 and i3 >= 1 + 10i2) }"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_coalesce(map); + map2 = isl_map_read_from_str(ctx, str, -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); } void test_closure(struct isl_ctx *ctx) { + const char *str; isl_set *dom; isl_map *up, *right; isl_map *map, *map2; @@ -765,7 +887,12 @@ void test_closure(struct isl_ctx *ctx) up = isl_map_intersect_range(up, dom); map = isl_map_union(up, right); map = isl_map_transitive_closure(map, &exact); - assert(!exact); + assert(exact); + map2 = isl_map_read_from_str(ctx, + "{ [0,0] -> [0,1]; [0,0] -> [1,1]; [0,1] -> [1,1]; " + " [2,2] -> [3,2]; [2,2] -> [3,3]; [3,2] -> [3,3] }", -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map2); isl_map_free(map); /* COCOA Theorem 1 counter example */ @@ -802,6 +929,69 @@ void test_closure(struct isl_ctx *ctx) assert(isl_map_is_equal(map, map2)); isl_map_free(map2); isl_map_free(map); + + /* Omega's closure4 */ + map = isl_map_read_from_str(ctx, + "[m,n] -> { [x,y] -> [x2,y2] : x2 = x and y2 = y + 1 and " + "1 <= x,y <= 10 or " + "x2 = x + 1 and y2 = y and " + "1 <= x <= 20 && 5 <= y <= 15 }", -1); + map = isl_map_transitive_closure(map, &exact); + assert(exact); + isl_map_free(map); + + map = isl_map_read_from_str(ctx, + "[n] -> { [x] -> [y]: 1 <= n <= y - x <= 10 }", -1); + map = isl_map_transitive_closure(map, &exact); + assert(!exact); + map2 = isl_map_read_from_str(ctx, + "[n] -> { [x] -> [y] : 1 <= n <= 10 and y >= n + x }", -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); + + str = "[n, m] -> { [i0, i1, i2, i3] -> [o0, o1, o2, o3] : " + "i3 = 1 and o0 = i0 and o1 = -1 + i1 and o2 = -1 + i2 and " + "o3 = -2 + i2 and i1 <= -1 + i0 and i1 >= 1 - m + i0 and " + "i1 >= 2 and i1 <= n and i2 >= 3 and i2 <= 1 + n and i2 <= m }"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_transitive_closure(map, &exact); + assert(exact); + map2 = isl_map_read_from_str(ctx, str, -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); + + str = "{[0] -> [1]; [2] -> [3]}"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_transitive_closure(map, &exact); + assert(exact); + map2 = isl_map_read_from_str(ctx, str, -1); + assert(isl_map_is_equal(map, map2)); + isl_map_free(map); + isl_map_free(map2); +} + +void test_lexmin(struct isl_ctx *ctx) +{ + const char *str; + isl_map *map; + + str = "[p0, p1] -> { [] -> [] : " + "exists (e0 = [(2p1)/3], e1, e2, e3 = [(3 - p1 + 3e0)/3], " + "e4 = [(p1)/3], e5 = [(p1 + 3e4)/3]: " + "3e0 >= -2 + 2p1 and 3e0 >= p1 and 3e3 >= 1 - p1 + 3e0 and " + "3e0 <= 2p1 and 3e3 >= -2 + p1 and 3e3 <= -1 + p1 and p1 >= 3 and " + "3e5 >= -2 + 2p1 and 3e5 >= p1 and 3e5 <= -1 + p1 + 3e4 and " + "3e4 <= p1 and 3e4 >= -2 + p1 and e3 <= -1 + e0 and " + "3e4 >= 6 - p1 + 3e1 and 3e1 >= p1 and 3e5 >= -2 + p1 + 3e4 and " + "2e4 >= 3 - p1 + 2e1 and e4 <= e1 and 3e3 <= 2 - p1 + 3e0 and " + "e5 >= 1 + e1 and 3e4 >= 6 - 2p1 + 3e1 and " + "p0 >= 2 and p1 >= p0 and 3e2 >= p1 and 3e4 >= 6 - p1 + 3e2 and " + "e2 <= e1 and e3 >= 1 and e4 <= e2) }"; + map = isl_map_read_from_str(ctx, str, -1); + map = isl_map_lexmin(map); + isl_map_free(map); } int main() @@ -822,6 +1012,7 @@ int main() test_gist(ctx); test_coalesce(ctx); test_closure(ctx); + test_lexmin(ctx); isl_ctx_free(ctx); return 0; }