#include "beirg.h"
#include "bemachine.h"
#include "belistsched.h"
+#include "bemodule.h"
typedef struct _ilpsched_options_t {
unsigned regpress;
void *irg_env; /**< An environment for the irg scheduling, provided by the backend */
void *block_env; /**< An environment for scheduling a block, provided by the backend */
const arch_env_t *arch_env;
- const be_main_env_t *main_env;
const be_machine_t *cpu; /**< the current abstract machine */
ilpsched_options_t *opts; /**< the ilp options for current irg */
- const be_irg_t *birg; /**< The birg object */
- be_options_t *be_opts; /**< backend options */
const ilp_sched_selector_t *sel; /**< The ILP sched selector provided by the backend */
DEBUG_ONLY(firm_dbg_module_t *dbg);
} be_ilpsched_env_t;
/* the precedence constraints */
stat_ev_tim_push();
- bs_block_irns = bitset_clear_all(bs_block_irns);
+ bitset_clear_all(bs_block_irns);
sta_collect_in_deps(irn, &deps);
foreach_ir_nodeset(&deps, pred, iter) {
int base_num = ba->n_interesting_nodes * ba->n_interesting_nodes;
int estimated_n_var = (int)((double)base_num * fact_var);
int estimated_n_cst = (int)((double)base_num * fact_cst);
+ be_options_t *options = be_get_irg_options(env->irg);
DBG((env->dbg, LEVEL_1, "Creating LPP with estimated numbers: %d vars, %d cst\n",
estimated_n_var, estimated_n_cst));
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({
}
/* solve the ILP */
- lpp_solve_net(lpp, env->main_env->options->ilp_server, env->main_env->options->ilp_solver);
+ lpp_solve_net(lpp, options->ilp_server, options->ilp_solver);
if (logfile)
fclose(logfile);
fclose(f);
snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.mps", get_irn_node_nr(block));
lpp_dump(lpp, buf);
- dump_ir_block_graph(env->irg, "-infeasible");
+ dump_ir_graph(env->irg, "infeasible");
}
})
}
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->birg, block, env->be_opts);
- }
- else {
+ 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);
}
/**
* Perform ILP scheduling on the given irg.
*/
-void be_ilp_sched(const be_irg_t *birg, be_options_t *be_opts)
+void be_ilp_sched(ir_graph *irg)
{
be_ilpsched_env_t env;
- const char *name = "be ilp scheduling";
- ir_graph *irg = be_get_birg_irg(birg);
- const arch_env_t *arch_env = be_get_birg_arch_env(birg);
+ const arch_env_t *arch_env = be_get_irg_arch_env(irg);
const ilp_sched_selector_t *sel = arch_env->impl->get_ilp_sched_selector(arch_env);
FIRM_DBG_REGISTER(env.dbg, "firm.be.sched.ilp");
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;
env.height = heights_new(irg);
- env.main_env = birg->main_env;
env.arch_env = arch_env;
env.cpu = arch_env_get_machine(arch_env);
env.opts = &ilp_opts;
- env.birg = birg;
- env.be_opts = be_opts;
- phase_init(&env.ph, name, env.irg, PHASE_DEFAULT_GROWTH, init_ilpsched_irn, NULL);
+ phase_init(&env.ph, env.irg, init_ilpsched_irn);
/* assign a unique per block number to all interesting nodes */
irg_walk_in_or_dep_graph(env.irg, NULL, build_block_idx, &env);
irg_block_walk_graph(env.irg, NULL, clear_unwanted_data, &env);
/* free all allocated object */
- phase_free(&env.ph);
+ phase_deinit(&env.ph);
heights_free(env.height);
/* notify backend */
- be_ilp_sched_finish_irg_ilp_schedule(sel, birg->irg, env.irg_env);
+ be_ilp_sched_finish_irg_ilp_schedule(sel, irg, env.irg_env);
stat_ev_ctx_pop("ilpsched");
}
/**
* Register ILP scheduler options.
*/
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_ilpsched);
void be_init_ilpsched(void)
{
lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");