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)