Commit 0050bc6b authored by Sebastian Hack's avatar Sebastian Hack
Browse files

More statistics

parent 2c4db174
......@@ -723,9 +723,10 @@ static be_ra_timer_t *be_ra_chordal_main(const be_irg_t *bi)
if(stat_file) {
be_ifg_stat_t stat;
be_ifg_stat(chordal_env.ifg, irg, &stat);
be_ifg_stat(&chordal_env, &stat);
be_stat_ev("ifg_nodes", stat.n_nodes);
be_stat_ev("ifg_edges", stat.n_edges);
be_stat_ev("ifg_comps", stat.n_comps);
}
BE_TIMER_PUSH(ra_timer.t_verify);
......
......@@ -39,8 +39,14 @@
#include "beinsn_t.h"
#include "besched_t.h"
#include "benodesets.h"
#include "bejavacoal.h"
#include "bestatevent.h"
#ifdef WITH_LIBCORE
#include <libcore/lc_timing.h>
#include <libcore/lc_opts.h>
#endif /* WITH_LIBCORE */
#define DUMP_BEFORE 1
#define DUMP_AFTER 2
#define DUMP_APPEL 4
......@@ -151,6 +157,8 @@ void co_register_options(lc_opt_entry_t *grp)
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
void be_copy_opt_init(void) {
if(algo == CO_ALGO_HEUR3)
be_java_coal_start_jvm();
}
copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, cost_fct_t get_costs)
......@@ -1377,6 +1385,9 @@ static co_algo_info_t algos[] = {
void co_driver(be_chordal_env_t *cenv)
{
#ifdef WITH_LIBCORE
lc_timer_t *timer = lc_timer_register("firm.be.copyopt", "runtime");
#endif
co_complete_stats_t before, after;
copy_opt_t *co;
co_algo_t *algo_func;
......@@ -1391,14 +1402,14 @@ void co_driver(be_chordal_env_t *cenv)
co_complete_stats(co, &before);
be_stat_ev("co_aff_nodes", before.aff_nodes);
be_stat_ev("co_aff_edges", before.aff_edges);
be_stat_ev("co_max_costs", before.max_costs);
be_stat_ev("co_inevit_costs", before.inevit_costs);
be_stat_ev("co_aff_int", before.aff_int);
be_stat_ev_ull("co_aff_nodes", before.aff_nodes);
be_stat_ev_ull("co_aff_edges", before.aff_edges);
be_stat_ev_ull("co_max_costs", before.max_costs);
be_stat_ev_ull("co_inevit_costs", before.inevit_costs);
be_stat_ev_ull("co_aff_int", before.aff_int);
be_stat_ev("co_init_costs", before.costs);
be_stat_ev("co_init_unsat", before.unsatisfied_edges);
be_stat_ev_ull("co_init_costs", before.costs);
be_stat_ev_ull("co_init_unsat", before.unsatisfied_edges);
/* Dump the interference graph in Appel's format. */
if(dump_flags & DUMP_APPEL) {
......@@ -1422,12 +1433,23 @@ void co_driver(be_chordal_env_t *cenv)
/* do the stats and provide the current costs */
co_complete_stats(co, &stats);
be_stat_ev("co_prepare_costs", stats.costs);
be_stat_ev_ull("co_prepare_costs", stats.costs);
}
algo_func = algos[algo].algo;
#ifdef WITH_LIBCORE
lc_timer_reset_and_start(timer);
#endif
was_optimal = algo_func(co);
be_stat_ev("co_optimal", was_optimal);
#ifdef WITH_LIBCORE
lc_timer_stop(timer);
be_stat_ev("co_time", lc_timer_elapsed_msec(timer));
#endif
be_stat_ev_ull("co_optimal", was_optimal);
if(dump_flags & DUMP_AFTER) {
FILE *f = be_chordal_open(cenv, "", "-after.dot");
......@@ -1441,16 +1463,17 @@ void co_driver(be_chordal_env_t *cenv)
int optimizable_costs = after.max_costs - after.inevit_costs;
int evitable = after.costs - after.inevit_costs;
ir_printf("%30F %10s %10d%10d%10d", cenv->irg, cenv->cls->name, after.max_costs, before.costs, after.inevit_costs);
ir_printf("%30F ", cenv->irg);
printf("%10s %10llu%10llu%10llu", cenv->cls->name, after.max_costs, before.costs, after.inevit_costs);
if(optimizable_costs > 0)
printf("%10d %5.2f\n", after.costs, (evitable * 100.0) / optimizable_costs);
printf("%10llu %5.2f\n", after.costs, (evitable * 100.0) / optimizable_costs);
else
printf("%10d %5s\n", after.costs, "-");
printf("%10llu %5s\n", after.costs, "-");
}
be_stat_ev("co_after_costs", after.costs);
be_stat_ev("co_after_unsat", after.unsatisfied_edges);
be_stat_ev_ull("co_after_costs", after.costs);
be_stat_ev_ull("co_after_unsat", after.unsatisfied_edges);
co_free_graph_structure(co);
co_free_ou_structure(co);
......
......@@ -109,13 +109,13 @@ int co_get_costs_all_one(const copy_opt_t *co, ir_node *root, ir_node* arg, int
* Statistics over a copy optimization module.
*/
typedef struct {
int aff_edges; /**< number of affinity edges. */
int aff_nodes; /**< number of nodes with incident affinity edges. */
int aff_int; /**< number of affinity edges whose nodes also interfere. */
int inevit_costs; /**< costs which cannot be evited (due to interfering affinities). */
int max_costs; /**< all costs of the affinities. */
int costs; /**< The costs of the current coloring. */
int unsatisfied_edges; /**< The number of unequally colored affinity edges. */
unsigned long long int aff_edges; /**< number of affinity edges. */
unsigned long long int aff_nodes; /**< number of nodes with incident affinity edges. */
unsigned long long int aff_int; /**< number of affinity edges whose nodes also interfere. */
unsigned long long int inevit_costs; /**< costs which cannot be evited (due to interfering affinities). */
unsigned long long int max_costs; /**< all costs of the affinities. */
unsigned long long int costs; /**< The costs of the current coloring. */
unsigned long long int unsatisfied_edges; /**< The number of unequally colored affinity edges. */
} co_complete_stats_t;
/**
......
......@@ -651,22 +651,57 @@ void be_ifg_dump_dot(be_ifg_t *ifg, ir_graph *irg, FILE *file, const be_ifg_dump
bitset_free(nodes);
}
void be_ifg_stat(const be_ifg_t *ifg, ir_graph *irg, be_ifg_stat_t *stat)
static void int_comp_rec(const be_chordal_env_t *cenv, ir_node *n, bitset_t *seen)
{
void *nodes_it = be_ifg_nodes_iter_alloca(ifg);
void *neigh_it = be_ifg_neighbours_iter_alloca(ifg);
bitset_t *nodes = bitset_irg_malloc(irg);
void *neigh_it = be_ifg_neighbours_iter_alloca(cenv->ifg);
ir_node *m;
be_ifg_foreach_neighbour(cenv->ifg, neigh_it, n, m) {
if(!bitset_contains_irn(seen, m) && !arch_irn_is(cenv->birg->main_env->arch_env, m, ignore)) {
bitset_add_irn(seen, m);
int_comp_rec(cenv, m, seen);
}
}
}
static int int_component_stat(const be_chordal_env_t *cenv)
{
int n_comp = 0;
void *nodes_it = be_ifg_nodes_iter_alloca(cenv->ifg);
bitset_t *seen = bitset_irg_malloc(cenv->irg);
ir_node *n;
be_ifg_foreach_node(cenv->ifg, nodes_it, n) {
if(!bitset_contains_irn(seen, n) && !arch_irn_is(cenv->birg->main_env->arch_env, n, ignore)) {
++n_comp;
bitset_add_irn(seen, n);
int_comp_rec(cenv, n, seen);
}
}
free(seen);
return n_comp;
}
void be_ifg_stat(const be_chordal_env_t *cenv, be_ifg_stat_t *stat)
{
void *nodes_it = be_ifg_nodes_iter_alloca(cenv->ifg);
void *neigh_it = be_ifg_neighbours_iter_alloca(cenv->ifg);
bitset_t *nodes = bitset_irg_malloc(cenv->irg);
ir_node *n, *m;
memset(stat, 0, sizeof(stat[0]));
be_ifg_foreach_node(ifg, nodes_it, n) {
be_ifg_foreach_node(cenv->ifg, nodes_it, n) {
stat->n_nodes += 1;
be_ifg_foreach_neighbour(ifg, neigh_it, n, m) {
be_ifg_foreach_neighbour(cenv->ifg, neigh_it, n, m) {
bitset_add_irn(nodes, n);
stat->n_edges += !bitset_contains_irn(nodes, m);
}
}
stat->n_comps = int_component_stat(cenv);
bitset_free(nodes);
}
......@@ -57,9 +57,10 @@ int (be_ifg_degree)(const void *self, const ir_node *irn);
typedef struct {
int n_nodes;
int n_edges;
int n_comps;
} be_ifg_stat_t;
void be_ifg_stat(const be_ifg_t *ifg, ir_graph *irg, be_ifg_stat_t *stat);
void be_ifg_stat(const be_chordal_env_t *cenv, be_ifg_stat_t *stat);
/*
____ _
......
......@@ -205,6 +205,7 @@ static jni_env_t *get_jvm(void)
return &env;
}
static void check(jni_env_t *env, const char *file, int line)
{
JNIEnv *jni = env->jni;
......@@ -397,6 +398,11 @@ int be_java_coal_get_color(be_java_coal_t *c, int n)
return jc_call_int(c, mth_get_color, (jint) n);
}
void be_java_coal_start_jvm(void)
{
get_jvm();
}
#else
be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level)
......@@ -452,5 +458,9 @@ int be_java_coal_get_color(be_java_coal_t *c, int n)
return -1;
}
void be_java_coal_start_jvm(void)
{
}
#endif /* WITH_JVM */
......@@ -84,6 +84,14 @@ int be_java_coal_get_color(be_java_coal_t *c, int n);
*/
be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level);
/**
* Start the JVM.
* This is also done lazily by be_java_coal_init() but as that is called by
* the coalescing driver, it might tamper the runtime measurements. So here is
* an extra call.
*/
void be_java_coal_start_jvm(void);
/**
* Destroy the coalescing object.
*/
......
......@@ -62,6 +62,15 @@ void be_stat_ev_dbl(const char *ev, double value)
}
}
void be_stat_ev_ull(const char *ev, unsigned long long value)
{
if(sp > 0) {
ev_env_t *env = &envs[sp - 1];
if(env->f)
fprintf(env->f, "%s%s;%llu\n", env->tag, ev, value);
}
}
int be_stat_ev_is_active(void)
{
return sp > 0 && envs[sp - 1].f;
......
......@@ -18,6 +18,7 @@ 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);
void be_stat_ev_ull(const char *ev, unsigned long long value);
int be_stat_ev_is_active(void);
......
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