From db6f8d659739d76825ec46169461c3f61408f5cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Sat, 8 Apr 2006 21:06:20 +0000 Subject: [PATCH] added statistics for scheduling [r7606] --- ir/stat/firmstat.c | 39 +++++++++++++++++++++++++++++++++++++++ ir/stat/stat_dmp.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c index c667539e7..a7a4d66e0 100644 --- a/ir/stat/firmstat.c +++ b/ir/stat/firmstat.c @@ -386,7 +386,11 @@ static void be_block_clear_entry(be_block_entry_t *elem) if (elem->reg_pressure) del_pset(elem->reg_pressure); + if (elem->sched_ready) + stat_delete_distrib_tbl(elem->sched_ready); + elem->reg_pressure = new_pset(reg_pressure_cmp, 5); + elem->sched_ready = stat_new_int_distrib_tbl(); } /** @@ -1582,6 +1586,40 @@ static void stat_be_block_regpressure(void *ctx, ir_node *block, ir_graph *irg, STAT_LEAVE; } +/** + * Update the distribution of ready nodes of a block + * + * @param ctx the hook context + * @param block the block for which the reg pressure should be set + * @param irg the irg containing the block + * @param num_ready the number of ready nodes + */ +static void stat_be_block_sched_ready(void *ctx, ir_node *block, ir_graph *irg, int num_ready) +{ + if (! status->stat_options) + return; + + STAT_ENTER; + { + graph_entry_t *graph = graph_get_entry(irg, status->irg_hash); + be_block_entry_t *block_ent; + counter_t cnt_1; + + /* create new be_block hash */ + if (! graph->be_block_hash) + graph->be_block_hash = new_pset(be_block_cmp, 5); + + block_ent = be_block_get_entry(&status->be_data, get_irn_node_nr(block), graph->be_block_hash); + + /* add 1 to the counter of orresponding number of ready nodes */ + cnt_clr(&cnt_1); + cnt_inc(&cnt_1); + stat_add_int_distrib_tbl(block_ent->sched_ready, num_ready, &cnt_1); + } + STAT_LEAVE; +} + + /* Dumps a statistics snapshot */ void stat_dump_snapshot(const char *name, const char *phase) { @@ -1746,6 +1784,7 @@ void firm_init_stat(unsigned enable_options) HOOK(hook_arch_dep_replace_mul_with_shifts, stat_arch_dep_replace_mul_with_shifts); HOOK(hook_arch_dep_replace_division_by_const, stat_arch_dep_replace_division_by_const); HOOK(hook_be_block_regpressure, stat_be_block_regpressure); + HOOK(hook_be_block_sched_ready, stat_be_block_sched_ready); obstack_init(&status->cnts); obstack_init(&status->be_data); diff --git a/ir/stat/stat_dmp.c b/ir/stat/stat_dmp.c index a2ded6dae..3db58b77b 100644 --- a/ir/stat/stat_dmp.c +++ b/ir/stat/stat_dmp.c @@ -186,6 +186,35 @@ static void simple_dump_be_block_reg_pressure(dumper_t *dmp, graph_entry_t *entr } } +void dump_block_sched_ready_distrib(const distrib_entry_t *entry, void *env) { + FILE *dmp_f = env; + char buf[12]; + snprintf(buf, sizeof(buf), "%d:%d", (int)entry->object, entry->cnt.cnt[0]); + fprintf(dmp_f, "%6s", buf); +} + +/** + * dumps the distribution of the amount of ready nodes for each block + */ +static void simple_dump_be_block_sched_ready(dumper_t *dmp, graph_entry_t *entry) { + be_block_entry_t *b_entry = pset_first(entry->be_block_hash); + + /* return if no reg pressure information available */ + if (! b_entry) + return; + + fprintf(dmp->f, "\nSCHED READY:\n"); + for (/* b_entry is already initialized */ ; + b_entry; + b_entry = pset_next(entry->be_block_hash)) + { + fprintf(dmp->f, "BLK %6ld", b_entry->block_nr); + stat_iterate_distrib_tbl(b_entry->sched_ready, dump_block_sched_ready_distrib, dmp->f); + fprintf(dmp->f, "%6.2lf", stat_calc_mean_distrib_tbl(b_entry->sched_ready)); + fprintf(dmp->f, "\n"); + } +} + /** * dumps the number of real_function_call optimization */ @@ -318,6 +347,9 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry) /* dump block reg pressure */ simple_dump_be_block_reg_pressure(dmp, entry); + /* dump block ready nodes distribution */ + simple_dump_be_block_sched_ready(dmp, entry); + if (dmp->status->stat_options & FIRMSTAT_COUNT_EXTBB) { /* dump extended block info */ fprintf(dmp->f, "\n%12s %12s %12s %12s %12s %12s %12s\n", "Extbb Nr", "Nodes", "intern E", "incoming E", "outgoing E", "Phi", "quot"); -- 2.20.1