Commit 8c9bc8b3 authored by Matthias Braun's avatar Matthias Braun
Browse files

cleanup/fix ilp code

[r27702]
parent 1313146e
......@@ -623,8 +623,9 @@ static void collect_egde_frequency_ilp(ir_node *block, void *data)
static void coalesce_blocks_ilp(blocksched_ilp_env_t *env)
{
int i;
int edge_count = ARR_LEN(env->ilpedges);
int edge_count = ARR_LEN(env->ilpedges);
be_options_t *options = be_get_irg_options(env->env.irg);
int i;
/* complete out constraints */
for (i = 0; i < edge_count; ++i) {
......@@ -645,20 +646,7 @@ static void coalesce_blocks_ilp(blocksched_ilp_env_t *env)
lpp_set_factor_fast(env->lpp, entry->out_cst, edge->ilpvar, 1.0);
}
#if 0
{
FILE *f;
char fname[256];
lpp_dump(env->lpp, "lpp.out");
snprintf(fname, sizeof(fname), "lpp_%s.plain", get_irg_dump_name(env->env.irg));
f = fopen(fname, "w");
lpp_dump_plain(env->lpp, f);
fclose(f);
}
#endif
//lpp_solve_net(env->lpp, main_env->options->ilp_server, main_env->options->ilp_solver);
lpp_solve_net(env->lpp, "i44pc52", "cplex");
lpp_solve_net(env->lpp, options->ilp_server, options->ilp_solver);
assert(lpp_is_sol_valid(env->lpp));
/* Apply results to edges */
......
......@@ -43,7 +43,6 @@
#define DUMP_SOL 2
static int time_limit = 60;
static int solve_net = 1;
static int solve_log = 0;
static unsigned dump_flags = 0;
......@@ -59,7 +58,6 @@ static lc_opt_enum_mask_var_t dump_var = {
static const lc_opt_table_entry_t options[] = {
LC_OPT_ENT_INT ("limit", "time limit for solving in seconds (0 for unlimited)", &time_limit),
LC_OPT_ENT_BOOL ("net", "solve over the net", &solve_net),
LC_OPT_ENT_BOOL ("log", "show ilp solving log", &solve_log),
LC_OPT_ENT_ENUM_MASK("dump", "dump flags", &dump_var),
LC_OPT_LAST
......@@ -233,20 +231,12 @@ lpp_sol_state_t ilp_go(ilp_env_t *ienv)
if (solve_log)
lpp_set_log(ienv->lp, stdout);
if (solve_net)
lpp_solve_net(ienv->lp, options->ilp_server, options->ilp_solver);
else {
#ifdef LPP_SOLVE_NET
fprintf(stderr, "can only solve ilp over the net\n");
#else
lpp_solve_cplex(ienv->lp);
#endif
}
lpp_solve_net(ienv->lp, options->ilp_server, options->ilp_solver);
be_stat_ev_dbl("co_ilp_objval", ienv->lp->objval);
be_stat_ev_dbl("co_ilp_best_bound", ienv->lp->best_bound);
be_stat_ev ("co_ilp_iter", ienv->lp->iterations);
be_stat_ev_dbl("co_ilp_sol_time", ienv->lp->sol_time);
//be_stat_ev_dbl("co_ilp_objval", ienv->lp->objval);
//be_stat_ev_dbl("co_ilp_best_bound", ienv->lp->best_bound);
be_stat_ev ("co_ilp_iter", lpp_get_iter_cnt(ienv->lp));
be_stat_ev_dbl("co_ilp_sol_time", lpp_get_sol_time(ienv->lp));
if (dump_flags & DUMP_ILP) {
char buf[128];
......
......@@ -117,14 +117,7 @@ static inline int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg)
#ifdef WITH_ILP
#include <lpp/lpp.h>
#define LPP_SOLVE_NET
#ifdef LPP_SOLVE_NET
# include <lpp/lpp_net.h>
#else
# include <lpp/lpp_cplex.h>
#endif
#include <lpp/lpp_net.h>
#define EPSILON 0.00001
......@@ -154,6 +147,6 @@ void free_ilp_env(ilp_env_t *ienv);
#define name_cdd_sorted(buf, char1, int1, int2) \
name_cdd(buf, char1, MIN(int1, int2), MAX(int1, int2))
#endif /* WITH_ILP */
#endif
#endif /* FIRM_BE_BECOPYILP_T_H */
#endif
......@@ -1892,7 +1892,7 @@ static void create_ilp(ir_node *block, void *walk_env)
create_pressure_alive_constraint(env, lpp, block_node);
}
DBG((env->dbg, LEVEL_1, "ILP to solve: %u variables, %u constraints\n", lpp->var_next, lpp->cst_next));
DBG((env->dbg, LEVEL_1, "ILP to solve: %u variables, %u constraints\n", lpp_get_var_count(lpp), lpp_get_cst_count(lpp)));
/* debug stuff, dump lpp when debugging is on */
DEBUG_ONLY({
......@@ -1955,35 +1955,36 @@ static void create_ilp(ir_node *block, void *walk_env)
}
DBG((env->dbg, LEVEL_1, "\nSolution:\n"));
DBG((env->dbg, LEVEL_1, "\tsend time: %g sec\n", lpp->send_time / 1000000.0));
DBG((env->dbg, LEVEL_1, "\treceive time: %g sec\n", lpp->recv_time / 1000000.0));
DBG((env->dbg, LEVEL_1, "\tmatrix: %u elements, density %.2f%%, size %.2fMB\n", lpp->n_elems, lpp->density, (double)lpp->matrix_mem / 1024.0 / 1024.0));
DBG((env->dbg, LEVEL_1, "\titerations: %d\n", lpp->iterations));
DBG((env->dbg, LEVEL_1, "\tsolution time: %g\n", lpp->sol_time));
DBG((env->dbg, LEVEL_1, "\tobjective function: %g\n", LPP_VALUE_IS_0(lpp->objval) ? 0.0 : lpp->objval));
DBG((env->dbg, LEVEL_1, "\tbest bound: %g\n", LPP_VALUE_IS_0(lpp->best_bound) ? 0.0 : lpp->best_bound));
DBG((env->dbg, LEVEL_1, "variables used %u bytes\n", obstack_memory_used(&var_obst)));
//DBG((env->dbg, LEVEL_1, "\tsend time: %g sec\n", lpp->send_time / 1000000.0));
//DBG((env->dbg, LEVEL_1, "\treceive time: %g sec\n", lpp->recv_time / 1000000.0));
//DBG((env->dbg, LEVEL_1, "\tmatrix: %u elements, density %.2f%%, size %.2fMB\n", lpp->n_elems, lpp->density, (double)lpp->matrix_mem / 1024.0 / 1024.0));
DBG((env->dbg, LEVEL_1, "\titerations: %d\n", lpp_get_iter_cnt(lpp)));
DBG((env->dbg, LEVEL_1, "\tsolution time: %g\n", lpp_get_sol_time(lpp)));
//DBG((env->dbg, LEVEL_1, "\tobjective function: %g\n", LPP_VALUE_IS_0(lpp->objval) ? 0.0 : lpp->objval));
//DBG((env->dbg, LEVEL_1, "\tbest bound: %g\n", LPP_VALUE_IS_0(lpp->best_bound) ? 0.0 : lpp->best_bound));
//DBG((env->dbg, LEVEL_1, "variables used %u bytes\n", obstack_memory_used(&var_obst)));
}
/* apply solution */
be_stat_ev("nodes", ba->block_last_idx);
be_stat_ev("vars", lpp ? lpp->var_next : 0);
be_stat_ev("csts", lpp ? lpp->cst_next : 0);
be_stat_ev("vars", lpp ? lpp_get_var_count(lpp) : 0);
be_stat_ev("csts", lpp ? lpp_get_cst_count(lpp) : 0);
if (need_heur) {
be_stat_ev("time", -1);
be_stat_ev_dbl("opt", 0.0);
list_sched_single_block(env->irg, block, env->be_opts);
be_stat_ev("time", -1);
be_stat_ev_dbl("opt", 0.0);
list_sched_single_block(env->irg, block);
} else {
#if 0
if (lpp) {
double opt = lpp->sol_state == lpp_optimal ? 100.0 : 100.0 * lpp->best_bound / lpp->objval;
double opt = lpp_get_sol_state(lpp) == lpp_optimal ? 100.0 : 100.0 * lpp->best_bound / lpp->objval;
be_stat_ev_dbl("time", lpp->sol_time);
be_stat_ev_dbl("opt", opt);
}
else {
} else {
be_stat_ev_dbl("time", 0.0);
be_stat_ev_dbl("opt", 100.0);
}
#endif
apply_solution(env, lpp, block);
}
......@@ -2007,8 +2008,6 @@ void be_ilp_sched(ir_graph *irg)
stat_ev_ctx_push("ilpsched");
// firm_dbg_set_mask(env.dbg, 1);
env.irg_env = be_ilp_sched_init_irg_ilp_schedule(sel, irg);
env.sel = sel;
env.irg = irg;
......@@ -2016,7 +2015,6 @@ void be_ilp_sched(ir_graph *irg)
env.arch_env = arch_env;
env.cpu = arch_env_get_machine(arch_env);
env.opts = &ilp_opts;
env.be_opts = be_opts;
phase_init(&env.ph, env.irg, init_ilpsched_irn);
/* assign a unique per block number to all interesting nodes */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment