isl_mat.c \
isl_name.c \
isl_name.h \
+ isl_options.c \
isl_output.c \
isl_piplib.h \
isl_sample.h \
include/isl_mat.h \
include/isl_map.h \
include/isl_map_polylib.h \
+ include/isl_options.h \
include/isl_polylib.h \
include/isl_seq.h \
include/isl_set.h \
* for Integer Programming" of Cook el al. to compute a reduced basis.
* We use \epsilon = 1/4.
*
- * If ctx->gbr_only_first is set, the user is only interested
+ * If ctx->opt->gbr_only_first is set, the user is only interested
* in the first direction. In this case we stop the basis reduction when
* the width in the first direction becomes smaller than 2.
*/
int fixed_saved = 0;
int mu_fixed[2];
int n_bounded;
+ int gbr_only_first;
if (!tab)
return NULL;
return tab;
ctx = tab->mat->ctx;
+ gbr_only_first = ctx->opt->gbr_only_first;
dim = tab->n_var;
B = tab->basis;
if (!B)
--i;
} else {
GBR_set(F[tab->n_zero], F_new);
- if (ctx->gbr_only_first && GBR_lt(F[tab->n_zero], two))
+ if (gbr_only_first && GBR_lt(F[tab->n_zero], two))
break;
if (fixed) {
#include <stdlib.h>
#include <isl_int.h>
+#include <isl_options.h>
#include <isl_blk.h>
#include <isl_hash.h>
#include <isl_config.h>
struct isl_stats *stats;
+ struct isl_options *opt;
+
isl_int one;
isl_int negone;
#ifdef ISL_POLYLIB
unsigned MaxRays;
#endif
-
- #define ISL_LP_TAB 0
- #define ISL_LP_PIP 1
- unsigned lp_solver;
-
- #define ISL_ILP_GBR 0
- #define ISL_ILP_PIP 1
- unsigned ilp_solver;
-
- #define ISL_PIP_TAB 0
- #define ISL_PIP_PIP 1
- unsigned pip;
-
- #define ISL_CONTEXT_GBR 0
- #define ISL_CONTEXT_LEXMIN 1
- unsigned context;
-
- #define ISL_GBR_NEVER 0
- #define ISL_GBR_ONCE 1
- #define ISL_GBR_ALWAYS 2
- unsigned gbr;
- unsigned gbr_only_first;
};
typedef struct isl_ctx isl_ctx;
/* struct isl_ctx functions */
+struct isl_options *isl_ctx_options(isl_ctx *ctx);
+
+isl_ctx *isl_ctx_alloc_with_options(struct isl_options *opt);
isl_ctx *isl_ctx_alloc();
void isl_ctx_ref(struct isl_ctx *ctx);
void isl_ctx_deref(struct isl_ctx *ctx);
--- /dev/null
+#ifndef ISL_OPTIONS_H
+#define ISL_OPTIONS_H
+
+#include <isl_arg.h>
+
+struct isl_options {
+ #define ISL_LP_TAB 0
+ #define ISL_LP_PIP 1
+ unsigned lp_solver;
+
+ #define ISL_ILP_GBR 0
+ #define ISL_ILP_PIP 1
+ unsigned ilp_solver;
+
+ #define ISL_PIP_TAB 0
+ #define ISL_PIP_PIP 1
+ unsigned pip;
+
+ #define ISL_CONTEXT_GBR 0
+ #define ISL_CONTEXT_LEXMIN 1
+ unsigned context;
+
+ #define ISL_GBR_NEVER 0
+ #define ISL_GBR_ONCE 1
+ #define ISL_GBR_ALWAYS 2
+ unsigned gbr;
+ unsigned gbr_only_first;
+};
+
+ISL_ARG_DECL(isl_options, struct isl_options, isl_options_arg)
+
+extern struct isl_arg isl_options_arg[];
+
+#endif
#include <polylib/polylibgmp.h>
#endif
-struct isl_ctx *isl_ctx_alloc()
+isl_ctx *isl_ctx_alloc_with_options(struct isl_options *opt)
{
struct isl_ctx *ctx = NULL;
+ if (!opt)
+ return NULL;
+
ctx = isl_calloc_type(NULL, struct isl_ctx);
if (!ctx)
goto error;
if (!ctx->stats)
goto error;
+ ctx->opt = opt;
ctx->ref = 0;
isl_int_init(ctx->one);
ctx->MaxRays = POL_NO_DUAL | POL_INTEGER;
#endif
- ctx->lp_solver = ISL_LP_TAB;
- ctx->ilp_solver = ISL_ILP_GBR;
- ctx->pip = ISL_PIP_TAB;
- ctx->context = ISL_CONTEXT_GBR;
-
- ctx->gbr = ISL_GBR_ONCE;
- ctx->gbr_only_first = 0;
-
return ctx;
error:
free(ctx);
return NULL;
}
+struct isl_ctx *isl_ctx_alloc()
+{
+ struct isl_options *opt;
+
+ opt = isl_options_new_with_defaults();
+
+ return isl_ctx_alloc_with_options(opt);
+}
+
void isl_ctx_ref(struct isl_ctx *ctx)
{
ctx->ref++;
isl_int_clear(ctx->one);
isl_int_clear(ctx->negone);
isl_int_clear(ctx->normalize_gcd);
+ free(ctx->opt);
free(ctx->stats);
free(ctx);
}
+
+struct isl_options *isl_ctx_options(isl_ctx *ctx)
+{
+ if (!ctx)
+ return NULL;
+ return ctx->opt;
+}
if (!bmap)
return isl_lp_error;
- switch (bmap->ctx->lp_solver) {
+ switch (bmap->ctx->opt->lp_solver) {
case ISL_LP_PIP:
return isl_pip_solve_lp(bmap, max, f, d, opt, opt_denom, sol);
case ISL_LP_TAB:
{
if (!bmap)
goto error;
- if (bmap->ctx->pip == ISL_PIP_PIP)
+ if (bmap->ctx->opt->pip == ISL_PIP_PIP)
return isl_pip_basic_map_lexopt(bmap, dom, empty, max);
else
return isl_tab_basic_map_partial_lexopt(bmap, dom, empty, max);
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "isl_ctx.h"
+#include "isl_options.h"
+
+struct isl_arg_choice isl_lp_solver_choice[] = {
+ {"tab", ISL_LP_TAB},
+#ifdef ISL_PIPLIB
+ {"pip", ISL_LP_PIP},
+#endif
+ {0}
+};
+
+struct isl_arg_choice isl_ilp_solver_choice[] = {
+ {"gbr", ISL_ILP_GBR},
+#ifdef ISL_PIPLIB
+ {"pip", ISL_ILP_PIP},
+#endif
+ {0}
+};
+
+struct isl_arg_choice isl_pip_solver_choice[] = {
+ {"tab", ISL_PIP_TAB},
+#ifdef ISL_PIPLIB
+ {"pip", ISL_PIP_PIP},
+#endif
+ {0}
+};
+
+struct isl_arg_choice isl_pip_context_choice[] = {
+ {"gbr", ISL_CONTEXT_GBR},
+ {"lexmin", ISL_CONTEXT_LEXMIN},
+ {0}
+};
+
+struct isl_arg_choice isl_gbr_choice[] = {
+ {"never", ISL_GBR_NEVER},
+ {"once", ISL_GBR_ONCE},
+ {"always", ISL_GBR_ALWAYS},
+ {0}
+};
+
+struct isl_arg isl_options_arg[] = {
+ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
+ isl_lp_solver_choice, ISL_LP_TAB)
+ISL_ARG_CHOICE(struct isl_options, ilp_solver, 0, "ilp-solver", \
+ isl_ilp_solver_choice, ISL_ILP_GBR)
+ISL_ARG_CHOICE(struct isl_options, pip, 0, "pip", \
+ isl_pip_solver_choice, ISL_PIP_TAB)
+ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
+ isl_pip_context_choice, ISL_CONTEXT_GBR)
+ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
+ isl_gbr_choice, ISL_GBR_ONCE)
+ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0)
+ISL_ARG_END
+};
+
+ISL_ARG_DEF(isl_options, struct isl_options, isl_options_arg)
*
* The initial basis is the identity matrix. If the range in some direction
* contains more than one integer value, we perform basis reduction based
- * on the value of ctx->gbr
+ * on the value of ctx->opt->gbr
* - ISL_GBR_NEVER: never perform basis reduction
* - ISL_GBR_ONCE: only perform basis reduction the first
* time such a range is encountered
* - ISL_GBR_ALWAYS: always perform basis reduction when
* such a range is encountered
*
- * When ctx->gbr is set to ISL_GBR_ALWAYS, then we allow the basis
+ * When ctx->opt->gbr is set to ISL_GBR_ALWAYS, then we allow the basis
* reduction computation to return early. That is, as soon as it
* finds a reasonable first direction.
*/
ctx = tab->mat->ctx;
dim = tab->n_var;
- gbr = ctx->gbr;
+ gbr = ctx->opt->gbr;
if (tab->n_unbounded == tab->n_var) {
sample = isl_tab_get_sample_value(tab);
goto error;
if (!empty && isl_tab_sample_is_integer(tab))
break;
- if (!empty && !reduced && ctx->gbr != ISL_GBR_NEVER &&
+ if (!empty && !reduced &&
+ ctx->opt->gbr != ISL_GBR_NEVER &&
isl_int_lt(min->el[level], max->el[level])) {
unsigned gbr_only_first;
- if (ctx->gbr == ISL_GBR_ONCE)
- ctx->gbr = ISL_GBR_NEVER;
+ if (ctx->opt->gbr == ISL_GBR_ONCE)
+ ctx->opt->gbr = ISL_GBR_NEVER;
tab->n_zero = level;
- gbr_only_first = ctx->gbr_only_first;
- ctx->gbr_only_first =
- ctx->gbr == ISL_GBR_ALWAYS;
+ gbr_only_first = ctx->opt->gbr_only_first;
+ ctx->opt->gbr_only_first =
+ ctx->opt->gbr == ISL_GBR_ALWAYS;
tab = isl_tab_compute_reduced_basis(tab);
- ctx->gbr_only_first = gbr_only_first;
+ ctx->opt->gbr_only_first = gbr_only_first;
if (!tab || !tab->basis)
goto error;
reduced = 1;
} else
sample = isl_vec_alloc(ctx, 0);
- ctx->gbr = gbr;
+ ctx->opt->gbr = gbr;
isl_vec_free(min);
isl_vec_free(max);
free(snap);
return sample;
error:
- ctx->gbr = gbr;
+ ctx->opt->gbr = gbr;
isl_vec_free(min);
isl_vec_free(max);
free(snap);
if (dim == 1)
return interval_sample(bset);
- switch (bset->ctx->ilp_solver) {
+ switch (bset->ctx->opt->ilp_solver) {
case ISL_ILP_PIP:
return pip_sample(bset);
case ISL_ILP_GBR:
if (!dom)
return NULL;
- if (dom->ctx->context == ISL_CONTEXT_LEXMIN)
+ if (dom->ctx->opt->context == ISL_CONTEXT_LEXMIN)
return isl_context_lex_alloc(dom);
else
return isl_context_gbr_alloc(dom);