From abd7de72651ce9ef077215cfeec797e0ec89e377 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 18 Sep 2011 06:56:00 -0300 Subject: [PATCH] m1/perf/: added instrumentation for monitoring register allocation --- m1/perf/sched.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/m1/perf/sched.c b/m1/perf/sched.c index 8d09e0c..49c6ed6 100644 --- a/m1/perf/sched.c +++ b/m1/perf/sched.c @@ -31,6 +31,8 @@ #include +#define REG_STATS + #ifdef DEBUG #define Dprintf printf #else @@ -88,6 +90,9 @@ static struct sched_ctx { struct list unscheduled; /* unscheduled insns */ struct list waiting; /* insns waiting to be scheduled */ struct list ready[PFPU_PROGSIZE]; /* insns ready at nth cycle */ +#ifdef REG_STATS + int max_regs, curr_regs; /* allocation statistics */ +#endif } *sc; @@ -211,6 +216,13 @@ static int alloc_reg(struct insn *setter) reg = list_pop(&sc->unallocated); if (!reg) abort(); + +#ifdef REG_STATS + sc->curr_regs++; + if (sc->curr_regs > sc->max_regs) + sc->max_regs = sc->curr_regs; +#endif + reg->vm_reg = vm_reg; pfpu_reg = reg-sc->pfpu_regs; @@ -238,6 +250,10 @@ static void put_reg(int vm_reg) Dprintf(" free reg %d\n", regs[vm_idx].pfpu_reg); +#ifdef REG_STATS + sc->curr_regs--; +#endif + /* * Prepend so that register numbers stay small and bugs reveal * themselves more rapidly. @@ -488,7 +504,13 @@ int gfpus_schedule(struct fpvm_fragment *frag, unsigned int *code, init_scheduler_context(frag, reg); memset(code, 0, PFPU_PROGSIZE*sizeof(*code)); res = schedule(code); + +#ifdef REG_STATS + printf("regs: %d/%d\n", sc->curr_regs, sc->max_regs); +#endif + free(sc->regs); + free(sc); if (res < 0) return res; if (frag->vector_mode)