isl_set_convex_hull: optionally use Fourier-Motzkin based algorithm
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Jan 2011 13:17:25 +0000 (14:17 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 18 Jan 2011 13:22:53 +0000 (14:22 +0100)
The Fourier-Motzkin based algorithm used to be the default but was
disabled when the wrapping based algorithm was completed in 6371ed7
(isl_map_convex_hull: handle unbounded, but pointed, case using wrapping,
Mon Apr 13 23:11:19 2009 +0200).

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/options.h
isl_convex_hull.c
isl_options.c
isl_test.c

index 790972f..673c272 100644 (file)
@@ -54,6 +54,10 @@ struct isl_options {
        int                     bernstein_triangulate;
 
        int                     pip_symmetry;
+
+       #define                 ISL_CONVEX_HULL_WRAP    0
+       #define                 ISL_CONVEX_HULL_FM      1
+       int                     convex;
 };
 
 ISL_ARG_DECL(isl_options, struct isl_options, isl_options_arg)
index 40cca1b..260bbd4 100644 (file)
@@ -1352,6 +1352,9 @@ static struct isl_basic_set *convex_hull_pair(struct isl_basic_set *bset1,
        isl_basic_set *lin, *aff;
        int bounded1, bounded2;
 
+       if (bset1->ctx->opt->convex == ISL_CONVEX_HULL_FM)
+               return convex_hull_pair_elim(bset1, bset2);
+
        aff = isl_set_affine_hull(isl_basic_set_union(isl_basic_set_copy(bset1),
                                                    isl_basic_set_copy(bset2)));
        if (!aff)
@@ -1807,7 +1810,8 @@ static struct isl_basic_set *uset_convex_hull(struct isl_set *set)
        if (isl_set_n_dim(set) == 1)
                return convex_hull_1d(set);
 
-       if (isl_set_is_bounded(set))
+       if (isl_set_is_bounded(set) &&
+           set->ctx->opt->convex == ISL_CONVEX_HULL_WRAP)
                return uset_convex_hull_wrap(set);
 
        lin = uset_combined_lineality_space(isl_set_copy(set));
index d7f4169..c603c2a 100644 (file)
@@ -75,6 +75,12 @@ static struct isl_arg_flags bernstein_recurse[] = {
        {0}
 };
 
+static struct isl_arg_choice convex[] = {
+       {"wrap",        ISL_CONVEX_HULL_WRAP},
+       {"fm",          ISL_CONVEX_HULL_FM},
+       {0}
+};
+
 static void print_version(void)
 {
        printf("%s", isl_version());
@@ -107,6 +113,8 @@ ISL_ARG_BOOL(struct isl_options, bernstein_triangulate, 0,
        "triangulate domains during Bernstein expansion")
 ISL_ARG_BOOL(struct isl_options, pip_symmetry, 0, "pip-symmetry", 1,
        "detect simple symmetries in PIP input")
+ISL_ARG_CHOICE(struct isl_options, convex, 0, "convex-hull", \
+       convex, ISL_CONVEX_HULL_WRAP, "convex hull algorithm to use")
 ISL_ARG_VERSION(print_version)
 ISL_ARG_END
 };
index 4c65209..0382830 100644 (file)
@@ -573,10 +573,12 @@ void test_convex_hull_case(struct isl_ctx *ctx, const char *name)
        fclose(input);
 }
 
-void test_convex_hull(struct isl_ctx *ctx)
+void test_convex_hull_algo(struct isl_ctx *ctx, int convex)
 {
        const char *str1, *str2;
        isl_set *set1, *set2;
+       int orig_convex = ctx->opt->convex;
+       ctx->opt->convex = convex;
 
        test_convex_hull_case(ctx, "convex0");
        test_convex_hull_case(ctx, "convex1");
@@ -605,6 +607,14 @@ void test_convex_hull(struct isl_ctx *ctx)
        assert(isl_set_is_equal(set1, set2));
        isl_set_free(set1);
        isl_set_free(set2);
+
+       ctx->opt->convex = orig_convex;
+}
+
+void test_convex_hull(struct isl_ctx *ctx)
+{
+       test_convex_hull_algo(ctx, ISL_CONVEX_HULL_FM);
+       test_convex_hull_algo(ctx, ISL_CONVEX_HULL_WRAP);
 }
 
 void test_gist_case(struct isl_ctx *ctx, const char *name)