Date:2011-09-18 06:28:02 (7 years 9 months ago)
Author:Werner Almesberger
Commit:c009a13f5cdd1cc70ef4affa49a7a4e2d1604987
Message:m1/perf/: cleaned up sched.c a little; added TODO

Files: m1/perf/TODO (1 diff)
m1/perf/sched.c (10 diffs)

Change Details

m1/perf/TODO
1- see if preferring critical path can improve code efficiency
2- test IF
3- run result comparison against full set of patches
4- check if result comparison actually compares meaningful data
5- compare run time and code size for all patches
6- see what optimization changes (may interfere with profiling)
7- build into Flickernoise (some things may need adapting, e.g., abort())
8- review code, see if things can be simplified
m1/perf/sched.c
3131#include <hw/pfpu.h>
3232
3333
34#ifdef DEBUG
35#define Dprintf printf
36#else
3437#define Dprintf(...)
38#endif
3539
3640
3741#define MAX_LATENCY 8 /* maximum latency; okay to make this bigger */
...... 
199203        abort();
200204    reg->vm_reg = vm_reg;
201205    pfpu_reg = reg-pfpu_regs;
202Dprintf(" alloc reg %d -> %d\n", vm_reg, pfpu_reg);
206
207    Dprintf(" alloc reg %d -> %d\n", vm_reg, pfpu_reg);
208
203209    vm_idx = reg2idx(vm_reg);
204210    regs[vm_idx].setter = setter;
205211    regs[vm_idx].pfpu_reg = pfpu_reg;
...... 
299305        list_add_tail(&ref->dep->dependants, &ref->more);
300306        ref->dep->num_dependants++;
301307        insn->unresolved++;
302Dprintf("insn %lu: reg %d setter %lu unresolved %d\n",
303   insn-insns, reg_num, reg->setter-insns, insn->unresolved);
308
309        Dprintf("insn %lu: reg %d setter %lu unresolved %d\n",
310            insn-insns, reg_num, reg->setter-insns, insn->unresolved);
304311    } else {
305312        list_init(&ref->more);
306313    }
...... 
308315}
309316
310317
311int catch = 0;
312318static void init_scheduler(struct fpvm_fragment *frag)
313319{
314320    int i;
...... 
319325    for (i = 0; i != PFPU_PROGSIZE; i++)
320326        list_init(&ready[i]);
321327
322#if 0
323if (frag->ninstructions > 10) {
324  frag->ninstructions = 10;
325catch = 1;
326}
327#endif
328328    for (i = 0; i != frag->ninstructions; i++) {
329329        insn = insns+i;
330330        memset(insn, 0, sizeof(struct insn));
...... 
363363    int end;
364364    end = cycle+insn->latency;
365365
366Dprintf("cycle %d: insn %lu L %d (A %d B %d)\n",
367  cycle, insn-insns, insn->latency, insn->vm_insn->opa, insn->vm_insn->opb);
366    Dprintf("cycle %d: insn %lu L %d (A %d B %d)\n", cycle,
367        insn-insns, insn->latency, insn->vm_insn->opa, insn->vm_insn->opb);
368
368369    switch (insn->arity) {
369370    case 3:
370371        /* fall through */
...... 
389390        if (ref->insn->earliest <= end)
390391            ref->insn->earliest = end+1;
391392        if (!--ref->insn->unresolved) {
392Dprintf(" unlocked %lu -> %u\n", ref->insn-insns, ref->insn->earliest);
393            Dprintf(" unlocked %lu -> %u\n", ref->insn-insns,
394                ref->insn->earliest);
393395            list_del(&ref->insn->more);
394396            list_add_tail(ready+ref->insn->earliest,
395397                &ref->insn->more);
...... 
398400}
399401
400402
403#ifdef DEBUG
401404static int count(const struct list *list)
402405{
403406    int n = 0;
...... 
407410        n++;
408411    return n;
409412}
413#endif
410414
411415
412416static int schedule(struct fpvm_fragment *frag, unsigned int *code)
...... 
419423    for (i = 0; remaining; i++) {
420424        if (i == PFPU_PROGSIZE)
421425            return -1;
422Dprintf("@%d --- remaining %d, waiting %d + ready %d = ", i, remaining,
423  count(&waiting), count(&ready[i]));
426
427        Dprintf("@%d --- remaining %d, waiting %d + ready %d\n",
428            i, remaining, count(&waiting), count(&ready[i]));
429
424430        list_concat(&waiting, &ready[i]);
425Dprintf("%d\n", count(&waiting));
426431        foreach (insn, &waiting) {
427432            end = i+insn->latency;
428433            if (end >= PFPU_PROGSIZE)

Archive Download the corresponding diff file

Branches:
master



interactive