From 07dda083afb68025db61c8278f430e0044e83977 Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Sat, 9 Sep 2006 12:13:14 +0000 Subject: [PATCH] Added some statistics events --- ir/be/Makefile.in | 2 +- ir/be/bechordal.c | 2 +- ir/be/bechordal_main.c | 22 ++++++++++++++++++++- ir/be/becopyilp.c | 7 +++++++ ir/be/becopyopt.c | 45 +++++++++++++++++++++++++++++++----------- ir/be/bespillslots.c | 2 ++ ir/be/bessadestr.c | 2 +- ir/be/bestatevent.c | 9 +++++++++ ir/be/bestatevent.h | 1 + 9 files changed, 76 insertions(+), 16 deletions(-) diff --git a/ir/be/Makefile.in b/ir/be/Makefile.in index c61ba061b..c58d8777e 100644 --- a/ir/be/Makefile.in +++ b/ir/be/Makefile.in @@ -23,7 +23,7 @@ SOURCES += Makefile.in besched.h belistsched.h belistsched.c \ beutil.h bemain.c besched.c bemain.c belive.c belive.h benumb.h \ benumb_t.h benumb.c bechordal.c bera.c beutil.c \ bera.h bechordal_main.c beschedregpress.c beschedtrace.c beschedtrivial.c \ - becopyopt.c becopyheur.c becopyheur2.c becopyilp.c becopyilp1.c \ + beschedrand.c becopyopt.c becopyheur.c becopyheur2.c becopyilp.c becopyilp1.c \ becopyilp2.c beifg.c becopystat.c bearch.c bechordal_draw.c \ bechordal_draw.h beirgmod.c beirgmod.h benode.c benode_t.h \ bessadestr.c beifg_std.c bespill.c bespillbelady.c \ diff --git a/ir/be/bechordal.c b/ir/be/bechordal.c index 2279561b7..ad085aba6 100644 --- a/ir/be/bechordal.c +++ b/ir/be/bechordal.c @@ -425,7 +425,7 @@ static ir_node *pre_process_constraints(be_chordal_alloc_env_t *alloc_env, be_in if(perm) { const ir_edge_t *edge; - be_stat_ev("constr_perm", 1); + be_stat_ev("constr_perm", get_irn_arity(perm)); foreach_out_edge(perm, edge) { ir_node *proj = get_edge_src_irn(edge); arch_set_irn_register(aenv, proj, NULL); diff --git a/ir/be/bechordal_main.c b/ir/be/bechordal_main.c index 8dcff9031..7b1ccffe0 100644 --- a/ir/be/bechordal_main.c +++ b/ir/be/bechordal_main.c @@ -387,8 +387,10 @@ static INLINE void check_for_memory_operands(be_chordal_env_t *chordal_env) { typedef struct _node_stat_t { unsigned int n_phis; /**< Phis of the current register class. */ unsigned int n_mem_phis; /**< Memory Phis (Phis with spill operands). */ + unsigned int n_copies; /**< Copies */ + unsigned int n_perms; /**< Perms */ unsigned int n_spills; /**< Spill nodes */ - unsigned int n_reloads; /**< Reloads. */ + unsigned int n_reloads; /**< Reloads */ } node_stat_t; struct node_stat_walker { @@ -414,6 +416,11 @@ static void node_stat_walker(ir_node *irn, void *data) else if(arch_irn_classify(aenv, irn) & arch_irn_class_reload) ++env->stat->n_reloads; + else if(arch_irn_classify(aenv, irn) & arch_irn_class_copy) + ++env->stat->n_copies; + + else if(arch_irn_classify(aenv, irn) & arch_irn_class_perm) + ++env->stat->n_perms; } /* a mem phi is a PhiM with a mem phi operand or a Spill operand */ @@ -728,10 +735,17 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi) BE_TIMER_POP(ra_timer.t_verify); + if(stat_file) { + node_stats(&chordal_env, &node_stat); + be_stat_ev("perms_before_coal", node_stat.n_perms); + be_stat_ev("copies_before_coal", node_stat.n_copies); + } + /* copy minimization */ BE_TIMER_PUSH(ra_timer.t_copymin); co_driver(&chordal_env); BE_TIMER_POP(ra_timer.t_copymin); + dump(BE_CH_DUMP_COPYMIN, irg, chordal_env.cls, "-copymin", dump_ir_block_graph_sched); BE_TIMER_PUSH(ra_timer.t_verify); @@ -761,6 +775,12 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi) pmap_destroy(chordal_env.border_heads); bitset_free(chordal_env.ignore_colors); + if(stat_file) { + node_stats(&chordal_env, &node_stat); + be_stat_ev("perms_after_coal", node_stat.n_perms); + be_stat_ev("copies_after_coal", node_stat.n_copies); + } + be_stat_ev_pop(); } diff --git a/ir/be/becopyilp.c b/ir/be/becopyilp.c index 0fc169a5b..d17de6e89 100644 --- a/ir/be/becopyilp.c +++ b/ir/be/becopyilp.c @@ -8,6 +8,8 @@ * */ +#include "bestatevent.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif /* HAVE_CONFIG_H */ @@ -215,6 +217,11 @@ lpp_sol_state_t ilp_go(ilp_env_t *ienv) { #endif } + 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); + if(dump_flags & DUMP_ILP) { FILE *f = be_chordal_open(ienv->co->cenv, "", "-co.ilp"); lpp_dump_plain(ienv->lp, f); diff --git a/ir/be/becopyopt.c b/ir/be/becopyopt.c index de059f3f2..536a2a928 100644 --- a/ir/be/becopyopt.c +++ b/ir/be/becopyopt.c @@ -55,6 +55,7 @@ static int style_flags = 0; static int do_stats = 0; static cost_fct_t cost_func = co_get_costs_exec_freq; static int algo = CO_ALGO_HEUR2; +static int improve = 1; #ifdef WITH_LIBCORE static const lc_opt_enum_mask_items_t dump_items[] = { @@ -107,11 +108,12 @@ static lc_opt_enum_func_ptr_var_t cost_func_var = { }; static const lc_opt_table_entry_t options[] = { - LC_OPT_ENT_ENUM_INT ("algo", "select copy optimization algo (heur, heur2, heur3, ilp)", &algo_var), - LC_OPT_ENT_ENUM_FUNC_PTR ("cost", "select a cost function (freq, loop, one)", &cost_func_var), - LC_OPT_ENT_ENUM_MASK ("dump", "dump ifg before or after copy optimization", &dump_var), - LC_OPT_ENT_ENUM_MASK ("style", "dump style for ifg dumping", &style_var), - LC_OPT_ENT_BOOL ("stats", "dump statistics after each optimization", &do_stats), + LC_OPT_ENT_ENUM_INT ("algo", "select copy optimization algo (heur, heur2, heur3, ilp)", &algo_var), + LC_OPT_ENT_ENUM_FUNC_PTR ("cost", "select a cost function (freq, loop, one)", &cost_func_var), + LC_OPT_ENT_ENUM_MASK ("dump", "dump ifg before or after copy optimization", &dump_var), + LC_OPT_ENT_ENUM_MASK ("style", "dump style for ifg dumping", &style_var), + LC_OPT_ENT_BOOL ("stats", "dump statistics after each optimization", &do_stats), + LC_OPT_ENT_BOOL ("improve", "run heur3 before if algo can exploit start solutions", &improve), { NULL } }; @@ -1347,14 +1349,21 @@ static int void_algo(copy_opt_t *co) |___/ */ -static co_algo_t *algos[] = { - void_algo, - co_solve_heuristic, - co_solve_heuristic_new, - co_solve_heuristic_java, +typedef struct { + co_algo_t *algo; + const char *name; + int can_improve_existing; +} co_algo_info_t; + +static co_algo_info_t algos[] = { + { void_algo, "none", 0 }, + { co_solve_heuristic, "heur1", 0 }, + { co_solve_heuristic_new, "heur2", 0 }, + { co_solve_heuristic_java, "heur3", 0 }, #ifdef WITH_ILP - co_solve_ilp2 + { co_solve_ilp2, "ilp", 1 }, #endif + { NULL, "", 0 } }; /* @@ -1404,7 +1413,19 @@ void co_driver(be_chordal_env_t *cenv) fclose(f); } - algo_func = algos[algo]; + /* if the algo can improve results, provide an initial solution with heur3 */ + if(improve && algos[algo].can_improve_existing) { + co_complete_stats_t stats; + + /* produce a heuristical solution */ + co_solve_heuristic_java(co); + + /* do the stats and provide the current costs */ + co_complete_stats(co, &stats); + be_stat_ev("co_prepare_costs", stats.costs); + } + + algo_func = algos[algo].algo; was_optimal = algo_func(co); be_stat_ev("co_optimal", was_optimal); diff --git a/ir/be/bespillslots.c b/ir/be/bespillslots.c index cee2464b8..0c50fb070 100644 --- a/ir/be/bespillslots.c +++ b/ir/be/bespillslots.c @@ -26,6 +26,7 @@ #include "bechordal_t.h" #include "bejavacoal.h" #include "benodesets.h" +#include "bestatevent.h" #define DBG_COALESCING 1 @@ -725,6 +726,7 @@ static void create_memperms(ss_env_t *env) { // insert node into schedule blockend = get_end_of_block_insertion_point(memperm->block); sched_add_before(blockend, mempermnode); + be_stat_ev("mem_perm", memperm->entrycount); for(entry = memperm->entries, i = 0; entry != NULL; entry = entry->next, ++i) { ir_node *proj; diff --git a/ir/be/bessadestr.c b/ir/be/bessadestr.c index 9301e5c61..55878bb11 100644 --- a/ir/be/bessadestr.c +++ b/ir/be/bessadestr.c @@ -140,7 +140,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) { in[pp->pos] = pp->arg; perm = be_new_Perm(chordal_env->cls, irg, pred_bl, n_projs, in); - be_stat_ev("phi_perm", 1); + be_stat_ev("phi_perm", n_projs); free(in); insert_after = sched_skip(sched_last(pred_bl), 0, sched_skip_cf_predicator, chordal_env->birg->main_env->arch_env); diff --git a/ir/be/bestatevent.c b/ir/be/bestatevent.c index 3627ee470..9e4e4d8c4 100644 --- a/ir/be/bestatevent.c +++ b/ir/be/bestatevent.c @@ -53,6 +53,15 @@ void be_stat_ev(const char *ev, int value) } } +void be_stat_ev_dbl(const char *ev, double value) +{ + if(sp > 0) { + ev_env_t *env = &envs[sp - 1]; + if(env->f) + fprintf(env->f, "%s%s;%f\n", env->tag, ev, value); + } +} + int be_stat_ev_is_active(void) { return sp > 0 && envs[sp - 1].f; diff --git a/ir/be/bestatevent.h b/ir/be/bestatevent.h index 2568eb382..59316075d 100644 --- a/ir/be/bestatevent.h +++ b/ir/be/bestatevent.h @@ -17,6 +17,7 @@ void be_stat_ev_push(const char **tags, int n_tags, FILE *f); void be_stat_ev_pop(void); void be_stat_ev(const char *ev, int value); +void be_stat_ev_dbl(const char *ev, double value); int be_stat_ev_is_active(void); -- 2.20.1