1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 11:36:15 +02:00

m1/perf/sched.c: synchronize with upstream version

This commit is contained in:
Werner Almesberger 2011-10-09 22:19:28 -03:00
parent 8b4ef502d7
commit 9e32d56ce9

View File

@ -1,7 +1,7 @@
/* /*
* sched.c - O(n) ... O(n^2) scheduler * lnfpus.c - O(n) ... O(n^2) scheduler
* *
* Written 2011 by Werner Almesberger * Copyright (C) 2011 Werner Almesberger
* *
* Based on gfpus.c * Based on gfpus.c
* Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
@ -319,11 +319,6 @@ static int init_registers(struct fpvm_fragment *frag,
{ {
int i; int i;
sc->regs =
calloc(frag->nbindings-frag->next_sur, sizeof(struct vm_reg));
if (!sc->regs)
return -1;
get_registers(frag, registers); get_registers(frag, registers);
for(i = 0; i != frag->ninstructions; i++) { for(i = 0; i != frag->ninstructions; i++) {
@ -615,33 +610,29 @@ static int schedule(unsigned int *code)
} }
static int init_scheduler_context(struct fpvm_fragment *frag,
unsigned int *reg)
{
sc = calloc(1, sizeof(*sc));
if (!sc)
return -1;
sc->frag = frag;
if (init_registers(frag, reg) < 0) {
free(sc);
return -1;
}
init_scheduler(frag);
return 0;
}
int gfpus_schedule(struct fpvm_fragment *frag, unsigned int *code, int gfpus_schedule(struct fpvm_fragment *frag, unsigned int *code,
unsigned int *reg) unsigned int *reg)
{ {
/*
* allocate context and registers on stack because standalone FN has no
* memory allocator
*/
struct sched_ctx sc_alloc;
struct vm_reg regs[frag->nbindings-frag->next_sur];
pfpu_instruction vecout; pfpu_instruction vecout;
int res; int res;
if (init_scheduler_context(frag, reg) < 0) printf("greetings %lu %lu\n", sizeof(*sc), sizeof(regs));
sc = &sc_alloc;
memset(sc, 0, sizeof(*sc));
sc->frag = frag;
sc->regs = regs;
memset(regs, 0, sizeof(regs));
if(init_registers(frag, reg) < 0)
return -1; return -1;
init_scheduler(frag);
memset(code, 0, PFPU_PROGSIZE*sizeof(*code)); memset(code, 0, PFPU_PROGSIZE*sizeof(*code));
res = schedule(code); res = schedule(code);
@ -649,8 +640,6 @@ int gfpus_schedule(struct fpvm_fragment *frag, unsigned int *code,
printf("regs: %d/%d\n", sc->curr_regs, sc->max_regs); printf("regs: %d/%d\n", sc->curr_regs, sc->max_regs);
#endif #endif
free(sc->regs);
free(sc);
if(res < 0) if(res < 0)
return res; return res;
if(frag->vector_mode) if(frag->vector_mode)