From 4de71bbbf4668e1c22749b6eedef45c7a2e41931 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 7 Jun 2010 16:43:55 +0200 Subject: [PATCH] update isl for generic isl_pw_qpolynomial_bound --- Makefile.am | 2 -- bernstein.cc | 1 - bound.cc | 19 +++++++------------ bound_common.c | 32 -------------------------------- bound_common.h | 14 -------------- doc/isl.tex | 4 +--- iscc.c | 30 ++++++++++++++++++++++-------- isl | 2 +- options.c | 28 ---------------------------- test_bound.c | 11 ++++------- 10 files changed, 35 insertions(+), 108 deletions(-) delete mode 100644 bound_common.c delete mode 100644 bound_common.h diff --git a/Makefile.am b/Makefile.am index db495ef..9feea88 100644 --- a/Makefile.am +++ b/Makefile.am @@ -220,8 +220,6 @@ else BERNSTEIN_CC = dummy.c endif libbarvinok_la_SOURCES = \ - bound_common.c \ - bound_common.h \ $(BERNSTEIN_CC) EXTRA_libbarvinok_la_SOURCES = \ bernstein.cc \ diff --git a/bernstein.cc b/bernstein.cc index 6f2cbfa..c0c2858 100644 --- a/bernstein.cc +++ b/bernstein.cc @@ -7,7 +7,6 @@ #include #include #include -#include "bound_common.h" #include "reduce_domain.h" using namespace GiNaC; diff --git a/bound.cc b/bound.cc index b321fec..a6c3f6f 100644 --- a/bound.cc +++ b/bound.cc @@ -4,8 +4,6 @@ #include #include #include -#include -#include #include "bound_options.h" #include "evalue_convert.h" #include "evalue_read.h" @@ -14,7 +12,6 @@ using std::cout; using std::cerr; using std::endl; -using namespace barvinok; #define ALLOCN(type,n) (type*)malloc((n) * sizeof(type)) @@ -22,6 +19,7 @@ struct verify_point_bound { struct verify_point_data vpd; isl_pw_qpolynomial *pwqp; isl_pw_qpolynomial_fold *pwf; + enum isl_fold type; }; static int verify_point(__isl_take isl_point *pnt, void *user) @@ -41,7 +39,7 @@ static int verify_point(__isl_take isl_point *pnt, void *user) vpb->vpd.n--; - if (vpb->vpd.options->barvinok->bernstein_optimize == BV_BERNSTEIN_MAX) { + if (vpb->type == isl_fold_max) { minmax = "max"; sign = 1; } else { @@ -145,7 +143,7 @@ error: } static int verify(__isl_keep isl_pw_qpolynomial_fold *pwf, evalue *EP, unsigned nvar, - struct verify_options *options) + enum isl_fold type, struct verify_options *options) { struct verify_point_bound vpb = { { options } }; isl_ctx *ctx; @@ -158,6 +156,7 @@ static int verify(__isl_keep isl_pw_qpolynomial_fold *pwf, evalue *EP, unsigned nparam = isl_pw_qpolynomial_fold_dim(pwf, isl_dim_param); vpb.pwf = pwf; dim = isl_dim_set_alloc(ctx, nvar + nparam, 0); + vpb.type = type; vpb.pwqp = isl_pw_qpolynomial_from_evalue(dim, EP); vpb.pwqp = isl_pw_qpolynomial_move_dims(vpb.pwqp, isl_dim_set, 0, isl_dim_param, 0, nvar); @@ -300,7 +299,6 @@ static __isl_give isl_pw_qpolynomial_fold *optimize(evalue *EP, unsigned nvar, return pwf; return isl_pw_qpolynomial_fold_add(pwf, pwf_more); } - int method = options->verify->barvinok->bound; isl_dim *dim_EP; isl_pw_qpolynomial *pwqp; enum isl_fold type = options->lower ? isl_fold_min : isl_fold_max; @@ -310,7 +308,7 @@ static __isl_give isl_pw_qpolynomial_fold *optimize(evalue *EP, unsigned nvar, if (options->iterate) pwf = iterate(pwqp, type); else - pwf = isl_pw_qpolynomial_bound(pwqp, type, method); + pwf = isl_pw_qpolynomial_bound(pwqp, type, NULL); return pwf; } @@ -335,10 +333,6 @@ static int optimize(evalue *EP, const char **all_vars, print_solution = 0; } - if (options->lower) - options->verify->barvinok->bernstein_optimize = BV_BERNSTEIN_MIN; - else - options->verify->barvinok->bernstein_optimize = BV_BERNSTEIN_MAX; pwf = optimize(EP, nvar, U, dim, options); assert(pwf); if (print_solution) { @@ -348,7 +342,8 @@ static int optimize(evalue *EP, const char **all_vars, isl_printer_free(p); } if (options->verify->verify) { - result = verify(pwf, EP, nvar, options->verify); + enum isl_fold type = options->lower ? isl_fold_min : isl_fold_max; + result = verify(pwf, EP, nvar, type, options->verify); } isl_pw_qpolynomial_fold_free(pwf); diff --git a/bound_common.c b/bound_common.c deleted file mode 100644 index 3ead230..0000000 --- a/bound_common.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include - -#include "config.h" - -#ifndef HAVE_GINAC -__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound_bernstein( - __isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type) -{ - assert(0); -} -#endif - -__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_upper_bound( - __isl_take isl_pw_qpolynomial *pwqp) -{ -#ifdef HAVE_GINAC - return isl_pw_qpolynomial_bound(pwqp, isl_fold_max, BV_BOUND_BERNSTEIN); -#else - return isl_pw_qpolynomial_bound(pwqp, isl_fold_max, BV_BOUND_RANGE); -#endif -} - -__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound( - __isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type, int method) -{ - if (method == BV_BOUND_BERNSTEIN) - return isl_pw_qpolynomial_bound_bernstein(pwqp, type); - else - return isl_pw_qpolynomial_bound_range(pwqp, type, NULL); -} diff --git a/bound_common.h b/bound_common.h deleted file mode 100644 index 5a2521c..0000000 --- a/bound_common.h +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound_bernstein( - __isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type); -__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound( - __isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type, int method); - -#if defined(__cplusplus) -} -#endif diff --git a/doc/isl.tex b/doc/isl.tex index 4397258..8fecf3e 100644 --- a/doc/isl.tex +++ b/doc/isl.tex @@ -160,9 +160,7 @@ sum $q_1$ over all integer points in the domain of $q_1$ \\ $f$ := \ai[\tt]{ub} $q$ & upper bound on the piecewise quasipolynomial $q$ over -all integer points in the domain of $q$. -The algorithm used to compute the upper bound depends on whether -\ai[\tt]{GiNaC} support was compiled in. +all integer points in the domain of $q$ \\ $s_3$ := $s_1$ \ai{$+$} $s_2$ & union \\ diff --git a/iscc.c b/iscc.c index 6036ce0..6814e5c 100644 --- a/iscc.c +++ b/iscc.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "config.h" @@ -330,14 +329,29 @@ static __isl_give isl_map *map_affine_hull(__isl_take isl_map *map) return isl_map_from_basic_map(isl_map_affine_hull(map)); } -static __isl_give isl_pw_qpolynomial_fold *pw_qpolynomial_upper_bound( +static __isl_give struct isl_list *pw_qpolynomial_upper_bound( __isl_take isl_pw_qpolynomial *pwqp) { -#ifdef HAVE_GINAC - return isl_pw_qpolynomial_bound(pwqp, isl_fold_max, BV_BOUND_BERNSTEIN); -#else - return isl_pw_qpolynomial_bound(pwqp, isl_fold_max, BV_BOUND_RANGE); -#endif + isl_ctx *ctx; + struct isl_list *list; + int tight; + + ctx = isl_pw_qpolynomial_get_ctx(pwqp); + list = isl_list_alloc(ctx, 2); + if (!list) + goto error; + + list->obj[0].type = isl_obj_pw_qpolynomial_fold; + list->obj[0].v = isl_pw_qpolynomial_bound(pwqp, isl_fold_max, &tight); + list->obj[1].type = isl_obj_bool; + list->obj[1].v = tight ? &isl_bool_true : &isl_bool_false; + if (tight < 0 || !list->obj[0].v) + goto error; + + return list; +error: + isl_list_free(list); + return NULL; } typedef void *(*isc_un_op_fn)(void *arg); @@ -393,7 +407,7 @@ struct isc_named_un_op named_un_ops[] = { (isc_un_op_fn) &map_sample } }, {"sum", { -1, isl_obj_pw_qpolynomial, isl_obj_pw_qpolynomial, (isc_un_op_fn) &isl_pw_qpolynomial_sum } }, - {"ub", { -1, isl_obj_pw_qpolynomial, isl_obj_pw_qpolynomial_fold, + {"ub", { -1, isl_obj_pw_qpolynomial, isl_obj_list, (isc_un_op_fn) &pw_qpolynomial_upper_bound } }, NULL }; diff --git a/isl b/isl index 8113984..f6f8ac8 160000 --- a/isl +++ b/isl @@ -1 +1 @@ -Subproject commit 8113984dd153adf8555b9be486e02fa6d238ebb6 +Subproject commit f6f8ac8fa68ebe512d317b967085e83eee84c644 diff --git a/options.c b/options.c index 5c23038..e61194c 100644 --- a/options.c +++ b/options.c @@ -126,18 +126,6 @@ static struct isl_arg_choice specialization[] = { {0} }; -#ifdef HAVE_GINAC -#define DEFAULT_BOUND BV_BOUND_BERNSTEIN -#else -#define DEFAULT_BOUND BV_BOUND_RANGE -#endif - -static struct isl_arg_choice bound[] = { - {"bernstein", BV_BOUND_BERNSTEIN}, - {"range", BV_BOUND_RANGE}, - {0} -}; - #ifdef HAVE_LIBGLPK #define DEFAULT_GBR BV_GBR_GLPK #elif defined HAVE_LIBCDDGMP @@ -158,17 +146,6 @@ static struct isl_arg_choice gbr[] = { {0} }; -static struct isl_arg_flags bernstein_recurse[] = { - {"none", BV_BERNSTEIN_FACTORS | BV_BERNSTEIN_INTERVALS, 0}, - {"factors", BV_BERNSTEIN_FACTORS | BV_BERNSTEIN_INTERVALS, - BV_BERNSTEIN_FACTORS}, - {"intervals", BV_BERNSTEIN_FACTORS | BV_BERNSTEIN_INTERVALS, - BV_BERNSTEIN_INTERVALS}, - {"full", BV_BERNSTEIN_FACTORS | BV_BERNSTEIN_INTERVALS, - BV_BERNSTEIN_FACTORS | BV_BERNSTEIN_INTERVALS}, - {0} -}; - #ifdef HAVE_LIBGLPK #define DEFAULT_LP BV_LP_GLPK #elif defined HAVE_LIBCDDGMP @@ -235,11 +212,6 @@ ISL_ARG_USER(struct barvinok_options, count_sample_infinite, &int_init_one, NULL ISL_ARG_USER(struct barvinok_options, try_Delaunay_triangulation, &int_init_zero, NULL) ISL_ARG_CHOICE(struct barvinok_options, gbr_lp_solver, 0, "gbr", gbr, DEFAULT_GBR, "lp solver to use for basis reduction") -ISL_ARG_CHOICE(struct barvinok_options, bound, 0, "bound", bound, - DEFAULT_BOUND, "algorithm to use for computing bounds") -ISL_ARG_USER(struct barvinok_options, bernstein_optimize, &int_init_zero, NULL) -ISL_ARG_FLAGS(struct barvinok_options, bernstein_recurse, 0, - "bernstein-recurse", bernstein_recurse, BV_BERNSTEIN_FACTORS, NULL) ISL_ARG_CHOICE(struct barvinok_options, lp_solver, 0, "lp", lp, DEFAULT_LP, "lp solver to use") ISL_ARG_CHOICE(struct barvinok_options, summation, 0, "summation", summation, diff --git a/test_bound.c b/test_bound.c index f193400..8310970 100644 --- a/test_bound.c +++ b/test_bound.c @@ -2,9 +2,7 @@ #include #include #include -#include #include -#include #include "evalue_read.h" #include "verify.h" @@ -37,8 +35,8 @@ static my_clock_t time_diff(struct tms *before, struct tms *after) static struct { int method; } methods[] = { - { BV_BOUND_BERNSTEIN }, - { BV_BOUND_RANGE }, + { ISL_BOUND_BERNSTEIN }, + { ISL_BOUND_RANGE }, }; #define nr_methods (sizeof(methods)/sizeof(*methods)) @@ -282,16 +280,15 @@ void handle(FILE *in, struct result_data *result, struct verify_options *options times(&st_cpu); for (j = 0; j < 2; ++j) { evalue *poly = j == 0 ? upper : lower; - int sign = j == 0 ? BV_BERNSTEIN_MAX : BV_BERNSTEIN_MIN; enum isl_fold type = j == 0 ? isl_fold_max : isl_fold_min; isl_dim *dim_poly; isl_pw_qpolynomial *pwqp; - options->barvinok->bernstein_optimize = sign; dim_poly = isl_dim_insert(isl_dim_copy(dim), isl_dim_param, 0, nvar); pwqp = isl_pw_qpolynomial_from_evalue(dim_poly, poly); pwqp = isl_pw_qpolynomial_move_dims(pwqp, isl_dim_set, 0, isl_dim_param, 0, nvar); - pwf[2*i+j] = isl_pw_qpolynomial_bound(pwqp, type, methods[i].method); + options->barvinok->isl->bound = methods[i].method; + pwf[2*i+j] = isl_pw_qpolynomial_bound(pwqp, type, NULL); } times(&en_cpu); result->ticks[i] = time_diff(&en_cpu, &st_cpu); -- 2.11.4.GIT