Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Commit Details
Date: | 2011-09-18 06:28:02 (12 years 6 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 | ||
---|---|---|
31 | 31 | #include <hw/pfpu.h> |
32 | 32 | |
33 | 33 | |
34 | #ifdef DEBUG | |
35 | #define Dprintf printf | |
36 | #else | |
34 | 37 | #define Dprintf(...) |
38 | #endif | |
35 | 39 | |
36 | 40 | |
37 | 41 | #define MAX_LATENCY 8 /* maximum latency; okay to make this bigger */ |
... | ... | |
199 | 203 | abort(); |
200 | 204 | reg->vm_reg = vm_reg; |
201 | 205 | pfpu_reg = reg-pfpu_regs; |
202 | Dprintf(" alloc reg %d -> %d\n", vm_reg, pfpu_reg); | |
206 | ||
207 | Dprintf(" alloc reg %d -> %d\n", vm_reg, pfpu_reg); | |
208 | ||
203 | 209 | vm_idx = reg2idx(vm_reg); |
204 | 210 | regs[vm_idx].setter = setter; |
205 | 211 | regs[vm_idx].pfpu_reg = pfpu_reg; |
... | ... | |
299 | 305 | list_add_tail(&ref->dep->dependants, &ref->more); |
300 | 306 | ref->dep->num_dependants++; |
301 | 307 | insn->unresolved++; |
302 | Dprintf("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); | |
304 | 311 | } else { |
305 | 312 | list_init(&ref->more); |
306 | 313 | } |
... | ... | |
308 | 315 | } |
309 | 316 | |
310 | 317 | |
311 | int catch = 0; | |
312 | 318 | static void init_scheduler(struct fpvm_fragment *frag) |
313 | 319 | { |
314 | 320 | int i; |
... | ... | |
319 | 325 | for (i = 0; i != PFPU_PROGSIZE; i++) |
320 | 326 | list_init(&ready[i]); |
321 | 327 | |
322 | #if 0 | |
323 | if (frag->ninstructions > 10) { | |
324 | frag->ninstructions = 10; | |
325 | catch = 1; | |
326 | } | |
327 | #endif | |
328 | 328 | for (i = 0; i != frag->ninstructions; i++) { |
329 | 329 | insn = insns+i; |
330 | 330 | memset(insn, 0, sizeof(struct insn)); |
... | ... | |
363 | 363 | int end; |
364 | 364 | end = cycle+insn->latency; |
365 | 365 | |
366 | Dprintf("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 | ||
368 | 369 | switch (insn->arity) { |
369 | 370 | case 3: |
370 | 371 | /* fall through */ |
... | ... | |
389 | 390 | if (ref->insn->earliest <= end) |
390 | 391 | ref->insn->earliest = end+1; |
391 | 392 | if (!--ref->insn->unresolved) { |
392 | Dprintf(" unlocked %lu -> %u\n", ref->insn-insns, ref->insn->earliest); | |
393 | Dprintf(" unlocked %lu -> %u\n", ref->insn-insns, | |
394 | ref->insn->earliest); | |
393 | 395 | list_del(&ref->insn->more); |
394 | 396 | list_add_tail(ready+ref->insn->earliest, |
395 | 397 | &ref->insn->more); |
... | ... | |
398 | 400 | } |
399 | 401 | |
400 | 402 | |
403 | #ifdef DEBUG | |
401 | 404 | static int count(const struct list *list) |
402 | 405 | { |
403 | 406 | int n = 0; |
... | ... | |
407 | 410 | n++; |
408 | 411 | return n; |
409 | 412 | } |
413 | #endif | |
410 | 414 | |
411 | 415 | |
412 | 416 | static int schedule(struct fpvm_fragment *frag, unsigned int *code) |
... | ... | |
419 | 423 | for (i = 0; remaining; i++) { |
420 | 424 | if (i == PFPU_PROGSIZE) |
421 | 425 | return -1; |
422 | Dprintf("@%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 | ||
424 | 430 | list_concat(&waiting, &ready[i]); |
425 | Dprintf("%d\n", count(&waiting)); | |
426 | 431 | foreach (insn, &waiting) { |
427 | 432 | end = i+insn->latency; |
428 | 433 | if (end >= PFPU_PROGSIZE) |
Branches:
master