Date:2011-09-18 12:45:17 (8 years 2 days ago)
Author:Werner Almesberger
Commit:5dc1c6de3638326e1f15405eccbf8be14cf24724
Message:m1/perf/: added LCPF scheduler

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

Change Details

m1/perf/Makefile
3636clean:
3737        $(MAKE) -C $(M1SWLIB_DIR) clean
3838        $(MAKE) -C $(COMPILER_DIR) clean
39        rm -f $(M1SWLIB_DIR)/sched.o
3940        rm -f $(OBJS)
4041
4142path:
m1/perf/TODO
11Done:
22- dynamically allocate scheduler context
3- see if preferring critical path can improve code efficiency (YES !)
34
45Pending:
5- see if preferring critical path can improve code efficiency
6- see if dynamically adjusting the critical path leads to further improvements
67- test IF
78- run result comparison against full set of patches
89- check if result comparison actually compares meaningful data
m1/perf/sched.c
3131#include <hw/pfpu.h>
3232
3333
34#define REG_STATS
34//#define REG_STATS
35//#define LCPF /* longest critical path first */
3536
3637#ifdef DEBUG
3738#define Dprintf printf
...... 
6465    int earliest; /* earliest cycle dependencies seen so far are met */
6566    struct list dependants; /* list of dependencies (constant) */
6667    int num_dependants; /* number of unresolved dependencies */
68#ifdef LCPF
69    int distance; /* minimum cycles on this path until the end */
70#endif
6771};
6872
6973
...... 
376380        else
377381            list_add_tail(&sc->ready[0], &insn->more);
378382    }
383
384#ifdef LCPF
385    struct data_ref *dep;
386
387    for (i = frag->ninstructions-1; i >= 0; i--) {
388        insn = sc->insns+i;
389        foreach (dep, &insn->dependants)
390            if (dep->insn->distance > insn->distance)
391                insn->distance = dep->insn->distance;
392        insn->distance += insn->latency;
393    }
394#endif
379395}
380396
381397
...... 
441457    int remaining;
442458    int i, last, end;
443459    struct insn *insn;
460#ifdef LCPF
461    struct insn *best;
462#endif
444463
445464    remaining = sc->frag->ninstructions;
446465    for (i = 0; remaining; i++) {
...... 
451470            i, remaining, count(&sc->waiting), count(&sc->ready[i]));
452471
453472        list_concat(&sc->waiting, &sc->ready[i]);
473#ifdef LCPF
474        best = NULL;
475#endif
454476        foreach (insn, &sc->waiting) {
455477            end = i+insn->latency;
456478            if (end >= PFPU_PROGSIZE)
457479                return -1;
458480            if (!FIELD(code[end]).dest) {
481#ifdef LCPF
482                if (!best || best->distance < insn->distance)
483                    best = insn;
484#else
459485                issue(insn, i, code);
460486                list_del(&insn->more);
461487                remaining--;
462488                break;
489#endif
463490            }
464491        }
492#ifdef LCPF
493        if (best) {
494            issue(best, i, code);
495            list_del(&best->more);
496            remaining--;
497        }
498#endif
465499        if (FIELD(code[i]).dest)
466500            put_reg(sc->pfpu_regs[FIELD(code[i]).dest].vm_reg);
467501    }

Archive Download the corresponding diff file

Branches:
master



interactive