Mercurial > hg > Game > Cerium
changeset 1464:3f2230d79eba draft
TaskList no compile errors
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Jul 2012 21:16:27 +0900 |
parents | f7e497c8e8a3 |
children | fc5b23108608 |
files | TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/TaskList.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/schedule/SchedMail.cc TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskArray.cc TaskManager/kernel/schedule/SchedTaskArray.h TaskManager/kernel/schedule/SchedTaskArrayLoad.cc TaskManager/kernel/schedule/SchedTaskArrayLoad.h TaskManager/kernel/schedule/SchedTaskArrayNop.cc TaskManager/kernel/schedule/SchedTaskArrayNop.h TaskManager/kernel/schedule/SchedTaskList.cc TaskManager/kernel/schedule/Scheduler.cc |
diffstat | 16 files changed, 25 insertions(+), 529 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Sat Jul 14 21:16:27 2012 +0900 @@ -57,7 +57,7 @@ // 現状では ppe 側からしか動かない // spe 側から Task create できない schedTaskManager = new SchedTask(); - schedTaskManager->init(0, 0, 0, ppeManager->get_scheduler(), 0); + schedTaskManager->init(0, 0, ppeManager->get_scheduler(), 0); ppeManager->schedTaskManager = schedTaskManager; }
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Sat Jul 14 21:16:27 2012 +0900 @@ -45,7 +45,7 @@ schedTaskManager = new SchedTask(); others = 0; - schedTaskManager->init(0,0,0,mainScheduler,0); + schedTaskManager->init(0,0,mainScheduler,0); }
--- a/TaskManager/kernel/ppe/HTask.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Sat Jul 14 21:16:27 2012 +0900 @@ -132,12 +132,9 @@ tl->next = nextTaskList; tl = nextTaskList; next = tl->tasks; - tl->length = 0; tl->self = 0; rbuf = (memaddr)tl; - } else { - tl->length++; - } + } next->init(id, param_count, inData_count, outData_count); return next; } @@ -151,6 +148,7 @@ void HTask::spawn_task_array(Task * last) { + TaskList *tl = (TaskList*)rbuf; tl->lastTask = last; }
--- a/TaskManager/kernel/ppe/TaskList.h Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/ppe/TaskList.h Sat Jul 14 21:16:27 2012 +0900 @@ -12,7 +12,7 @@ public: BASE_NEW_DELETE(TaskList); - TaskList *lastTask; // 4 byte + Task *lastTask; // 4 byte TaskList *next; // 4 byte TaskList *prev; // 4 byte TaskList *waiter; // 4 byte @@ -20,7 +20,7 @@ long dummy[3]; // 16 byte Task tasks[TASK_MAX_SIZE]; // 32*TASK_MAX_SIZE - TaskPtr last() { return &tasks; } + TaskPtr last() { return lastTask; } void init() { lastTask = &tasks[TASK_MAX_SIZE]; waiter=this; } void initOnce() { } void freeOnce() {}
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Jul 14 21:16:27 2012 +0900 @@ -165,10 +165,8 @@ const char * TaskManagerImpl::get_task_name(SchedTaskBase *sched_task) { if (sched_task == NULL) return NULL; - if (sched_task->task != NULL) { - return get_task_name(sched_task->task->command); - } else if (sched_task->atask != NULL) { - return get_task_name(sched_task->atask->command); + if (sched_task->atask != NULL) { + return get_task_name(sched_task->atask->command); } return NULL; }
--- a/TaskManager/kernel/schedule/SchedMail.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedMail.cc Sat Jul 14 21:16:27 2012 +0900 @@ -8,11 +8,11 @@ { connector = scheduler->connector; - params_addr = connector->task_list_mail_read(); + memaddr params_addr = connector->task_list_mail_read(); __debug("[SchedMail:%s]\n", __FUNCTION__); - if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) { + if (params_addr == (memaddr)MY_SPE_COMMAND_EXIT) { return new SchedExit(); } else { int dma_tag_switch = 0;
--- a/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 14 21:16:27 2012 +0900 @@ -4,14 +4,12 @@ #include "SchedTask.h" #include "SysFunc.h" #include "SchedTaskList.h" -#include "SchedTaskArrayLoad.h" #include "SchedNop2Ready.h" #include "DmaManager.h" #include "error.h" #include "TaskManager.h" #include <stdarg.h> -#include "SchedTaskArray.h" extern TaskObject task_list[MAX_TASK_OBJECT]; @@ -20,7 +18,7 @@ SchedTask::SchedTask() { list = NULL; - task = NULL; + atask = NULL; readbuf = NULL; writebuf = NULL; scheduler = NULL; @@ -35,12 +33,11 @@ } void -SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, Scheduler* sc, int tag) +SchedTask::init(TaskListPtr _list, TaskPtr _task, Scheduler* sc, int tag) { list = _list; atask = _task; scheduler = sc; - cur_index = index; this->tag = tag; // scheduler->mainMem_wait(); // これはなんで? @@ -77,7 +74,7 @@ // object creation をSchedTask生成時にやらないので、 // exec の直前のread で十分に間に合う - loadSchedTask(scheduler, task->command); + loadSchedTask(scheduler, atask->command); // 読むデータが一つもなければ無視 if (atask->inData_count == 0) return; @@ -110,17 +107,16 @@ void SchedTask::exec() { - task_list[task->command].wait(scheduler,task->command); - TaskObjectRun run = task_list[task->command].run; - if (task->w_size > 0) { - setup_outputData(); + task_list[atask->command].wait(scheduler,atask->command); + TaskObjectRun run = task_list[atask->command].run; + if (atask->outData_count > 0) { + setup_outputData(); // we need write buffer before run() } - connector->dma_wait(DMA_READ + this->tag); - run(this, readbuf, writebuf); + connector->dma_wait((DMA_READ + this->tag)); + run(this, get_input(readbuf, 0), get_output(writebuf, 0)); connector->free_(readbuf); - + // User 側で作る方法が必要... // 書き込む領域がなければ無視 - // User 側で作る方法が必要... if (atask->outData_count > 0) { // outListData.print(); connector->dma_storeList(&outListData, writebuf, DMA_WRITE); @@ -154,7 +150,7 @@ TaskPtr nextTask = cur_index = atask->next(); - SchedTask *nextSched = new SchedTask(scheduler); + SchedTask *nextSched = new SchedTask(); nextSched->init(list, nextTask, scheduler, this->tag^1); return nextSched; } else {
--- a/TaskManager/kernel/schedule/SchedTask.h Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sat Jul 14 21:16:27 2012 +0900 @@ -32,7 +32,7 @@ public: /* functions */ - void init(TaskListPtr _list, TaskPtr _task, int index, + void init(TaskListPtr _list, TaskPtr _task, Scheduler* sc, int tag); //--- User API ---
--- a/TaskManager/kernel/schedule/SchedTaskArray.cc Sat Jul 14 20:44:23 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,259 +0,0 @@ -#include "SchedTaskArray.h" -#include "SchedTaskArrayNop.h" -#include "Scheduler.h" -#include "TaskManagerImpl.h" - - -SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_, Task *curTask_, Task *_array, int tag) -{ - savedTask = savedTask_; - atask = curTask_; - array = _array; - scheduler = s; - connector = s->connector; - - inListData.bound = 0; - inListData.size = 0; - inListData.length = 0; - inListData.element = 0; - outListData.bound = 0; - outListData.size = 0; - outListData.length = 0; - outListData.element = 0; - - cur_index = -1; - task = 0; - - this->tag = tag; - -} - -/** - Constructor for old Task with ListData - next TaskList entry contains Task object. - savedTask->rbuf is 0, it has only one Task. - */ - -SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_) -{ - savedTask = savedTask_; - scheduler = s; - connector = s->connector; - - inListData.bound = 0; - inListData.size = 0; - inListData.length = 0; - inListData.element = 0; - outListData.bound = 0; - outListData.size = 0; - outListData.length = 0; - outListData.element = 0; - - SimpleTaskPtr st = &savedTask->list->tasks[savedTask->cur_index]; - atask = (TaskPtr)st; - array = 0; - savedTask->cur_index += (atask->size()+sizeof(SimpleTask))/sizeof(SimpleTask); - cur_index = -1; - task = 0; - - this->tag = 0; - -} - -/** - */ -SchedTaskArray::~SchedTaskArray() -{ -} - - -/** - * Task data / code read - */ -void -SchedTaskArray::read() -{ - - // object creation をSchedTaskArray生成時にやらないので、 - // exec の直前のread で十分に間に合う - loadSchedTask(scheduler, atask->command); - - // 読むデータが一つもなければ無視 - if (atask->inData_count == 0) return; - - inListData.length = atask->inData_count; - inListData.size = atask->inData_total_size(); - inListData.element = atask->inData(0); - inListData.bound = (int*)manager->allocate(inListData.length*sizeof(int)); - - // load Input Data - // inListData.print(); - readbuf = connector->dma_loadList(scheduler, &inListData, (DMA_READ + this->tag)); - connector->bound(&inListData); - -} - -void -SchedTaskArray::setup_outputData() -{ - // allocate write buffer - outListData.length = atask->outData_count; - outListData.size = atask->outData_total_size(); - // atask->outData_offset += cur_index + 1 ; // to avoid compiler bug - outListData.element = atask->outData(0); - free(outListData.bound); - outListData.bound = (int*)manager->allocate(outListData.length*sizeof(int)); - connector->bound(&outListData); - writebuf = connector->get_writebuf(scheduler, (memaddr)outListData.element[0].addr, outListData.size); - //if (outListData.element == inListData.element ) { - // printf("bad %x\n",outListData.element); - //} -} - -/** - * Wait read data and execute task - * Start write DMA - */ -void -SchedTaskArray::exec() -{ - task_list[atask->command].wait(scheduler,atask->command); - TaskObjectRun run = task_list[atask->command].run; - if (atask->outData_count > 0) { - setup_outputData(); // we need write buffer before run() - } - connector->dma_wait((DMA_READ + this->tag)); - run(this, get_input(readbuf, 0), get_output(writebuf, 0)); - connector->free_(readbuf); - // User 側で作る方法が必要... - // 書き込む領域がなければ無視 - if (atask->outData_count > 0) { - // outListData.print(); - connector->dma_storeList(&outListData, writebuf, DMA_WRITE); - } -} - -/** - * Wait write DMA - * send finish mail - */ -void -SchedTaskArray::write() -{ - - connector->dma_wait(DMA_WRITE); - connector->free_(writebuf); - free(inListData.bound); - free(outListData.bound); -} - -Task *SchedTaskArray::last() -{ - SchedTask *s = (SchedTask *)savedTask; - return (Task*)(((char*)array)+ s->read_size()); -} - -SchedTaskBase* -SchedTaskArray::next(Scheduler *scheduler, SchedTaskBase *p) -{ - - Task *next = atask->next(); - if (next < last()) { - // Task List が残っているので、次を準備 - //scheduler->printf("hog\n"); - return new SchedTaskArray(scheduler, savedTask, next, array, this->tag^1); - } else { - - //このTaskArrayは終わったが、Pipeline 上にread の TaskArray が残っているので - //1ステージを稼ぐ必要がある - //scheduler->printf("auau\n"); - return new SchedTaskArrayNop(scheduler, savedTask, next, array); - - } -} - - - -/** - * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 - * buffer から対応するデータを返す。 - */ -void* -SchedTaskArray::get_input(void *buff, int index) -{ - return (void*)((char*)readbuf + inListData.bound[index]); -} - -/** - * get_input(index) のアドレスを返す - */ -memaddr -SchedTaskArray::get_inputAddr(int index) -{ -#ifdef __CERIUM_CELL__ - return (memaddr)inListData.element[index].addr; -#else - return inListData.element[index].addr; -#endif -} - -/** - * get_input(index) のサイズを返す - */ -int -SchedTaskArray::get_inputSize(int index) -{ - return inListData.element[index].size; -} - -/** - * write buffer の領域を返す。 - */ -void* -SchedTaskArray::get_output(void *buff, int index) -{ - return (void*)((char *)writebuf + outListData.bound[index]); -} - -/** - * get_output(index) のアドレスを返す - */ -memaddr -SchedTaskArray::get_outputAddr(int index) -{ -#ifdef __CERIUM_CELL__ - return (memaddr)outListData.element[index].addr; -#else - return outListData.element[index].addr; -#endif -} - -/** - * get_output(index) のサイズを返す - */ -int -SchedTaskArray::get_outputSize(int index) -{ - return outListData.element[index].size; -} - -void -SchedTaskArray::set_outputSize(int index, int size) -{ - outListData.element[index].size = size; -} - -memaddr -SchedTaskArray::get_param(int index) -{ - return *atask->param(index); -} - -int -SchedTaskArray::read_size() -{ - return get_inputSize(0); -} - - -/* end */
--- a/TaskManager/kernel/schedule/SchedTaskArray.h Sat Jul 14 20:44:23 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -#ifndef INCLUDED_SCHED_TASK_ARRAY -#define INCLUDED_SCHED_TASK_ARRAY - -#include "base.h" -#include "Scheduler.h" -#include "SchedTask.h" - - -class SchedTaskArray : public SchedTask { -public: - BASE_NEW_DELETE(SchedTaskArray); - - /* constructor */ - SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_, Task *task_, Task *array_, int tag); - /* constructor for old style task */ - SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_); - - virtual ~SchedTaskArray(); - - -private: - /* variables */ - - /* functions */ - Task *last(); - - // override - void read(); - void exec(); - void write(); - SchedTaskBase* next(Scheduler *, SchedTaskBase *); - - void setup_outputData(); - - void* get_input(void*, int); - memaddr get_inputAddr(int); - int get_inputSize(int); - void* get_output(void*, int); - memaddr get_outputAddr(int); - int get_outputSize(int); - void set_outputSize(int index, int size); - memaddr get_param(int); - int read_size(); - -} ; - - -#endif -
--- a/TaskManager/kernel/schedule/SchedTaskArrayLoad.cc Sat Jul 14 20:44:23 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#include "SchedTaskArrayLoad.h" -#include "SchedTaskArray.h" -#include "Task.h" -#include "TaskManagerImpl.h" - - -SchedTaskArrayLoad::SchedTaskArrayLoad(Scheduler *s, SchedTaskBase *savedTask_, int dma_tag_switch) -{ - scheduler = s; - connector = s->connector; - savedTask = savedTask_; - task = savedTask->task; - cur_index = -2; - - this->tag = dma_tag_switch; - -} - -SchedTaskArrayLoad::~SchedTaskArrayLoad() {} - -void -SchedTaskArrayLoad::read() -{ - // if (task->r_size == 0) return; cannot happen... - // load Task Array Data - readbuf = connector->dma_load(scheduler, task->rbuf,task->r_size, DMA_READ); - connector->dma_wait(DMA_READ); -} - -void -SchedTaskArrayLoad::exec() { - // もっと、はやめに DMA_READ して、最初のcodeをloadするべきか? -} // to empty the pipeline - -void -SchedTaskArrayLoad::write() {} // to empty the pipeline - -SchedTaskBase* -SchedTaskArrayLoad::next(Scheduler *scheduler, SchedTaskBase *p) -{ - - Task *nextTask = (Task *)readbuf; - return new SchedTaskArray(scheduler, savedTask, nextTask, nextTask, this->tag); -} - -/* end */
--- a/TaskManager/kernel/schedule/SchedTaskArrayLoad.h Sat Jul 14 20:44:23 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#ifndef INCLUDED_SCHED_TASK_ARRAY_LOAD -#define INCLUDED_SCHED_TASK_ARRAY_LOAD - -#include "base.h" -#include "Scheduler.h" -#include "SchedTask.h" - -class SchedTaskArrayLoad : public SchedTask { -public: - /* constructor */ - SchedTaskArrayLoad(Scheduler *s, SchedTaskBase *savedTask_, int dma_tag_switch); - virtual ~SchedTaskArrayLoad(); - - BASE_NEW_DELETE(SchedTaskArrayLoad); - -private: - /* variables */ - - /* functions */ - - // override - void read(); - void exec(); - void write(); - SchedTaskBase* next(Scheduler *, SchedTaskBase *); - - -} ; - - -#endif -
--- a/TaskManager/kernel/schedule/SchedTaskArrayNop.cc Sat Jul 14 20:44:23 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -#include "SchedTaskArrayNop.h" -#include "Scheduler.h" - - -SchedTaskArrayNop::SchedTaskArrayNop(Scheduler *s, SchedTaskBase *savedTask_, Task *curTask_, Task *_array) -{ - savedTask = savedTask_; - atask = _array; - scheduler = s; - connector = s->connector; - - inListData.bound = 0; - inListData.size = 0; - inListData.length = 0; - inListData.element = 0; - outListData.bound = 0; - outListData.size = 0; - outListData.length = 0; - outListData.element = 0; - cur_index = -3; -} - - - -/** - */ -SchedTaskArrayNop::~SchedTaskArrayNop() -{ -} - - -/** - * Task data / code read - */ -void -SchedTaskArrayNop::read() -{ - -} - -/** - * Wait read data and execute task - * Start write DMA - */ -void -SchedTaskArrayNop::exec() -{ - -} - -/** - * Wait write DMA - * send finish mail - */ -void -SchedTaskArrayNop::write() -{ - savedTask->write(); - - connector->free_(atask); - delete savedTask; - savedTask = 0; -} - -SchedTaskBase* -SchedTaskArrayNop::next(Scheduler *scheduler, SchedTaskBase *p) -{ - - // 最後のTask が exec されて、次の Task を実行してかまわない。 - - return savedTask->next(scheduler, savedTask); - -} - - -/* end */
--- a/TaskManager/kernel/schedule/SchedTaskArrayNop.h Sat Jul 14 20:44:23 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -#ifndef INCLUDED_SCHED_TASK_ARRAY_NOP -#define INCLUDED_SCHED_TASK_ARRAY_NOP - -#include "base.h" -#include "Scheduler.h" -#include "SchedTask.h" - - -class SchedTaskArrayNop : public SchedTask { -public: - BASE_NEW_DELETE(SchedTaskArrayNop); - - /* constructor */ - SchedTaskArrayNop(Scheduler *s, SchedTaskBase *savedTask_, Task *task_, Task *array_); - - virtual ~SchedTaskArrayNop(); - -private: - /* variables */ - - /* functions */ - - // override - void read(); - void exec(); - void write(); - SchedTaskBase* next(Scheduler *, SchedTaskBase *); - -} ; - - -#endif -
--- a/TaskManager/kernel/schedule/SchedTaskList.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskList.cc Sat Jul 14 21:16:27 2012 +0900 @@ -3,8 +3,6 @@ #include "SchedTaskList.h" #include "SchedTask.h" #include "SysFunc.h" -#include "SchedTaskArray.h" -#include "SchedTaskArrayLoad.h" #include "SchedNop2Ready.h" #include "DmaManager.h" #include "error.h" @@ -22,7 +20,8 @@ SchedTaskList::SchedTaskList(memaddr addr, Scheduler *sched, int tag) { // next() で生成された時に、Task List read を始める - params_addr = addr; + memaddr params_addr = addr; + // should check TaskList size Todo scheduler = sched; cur_index = 0; list = scheduler->get_curListBuf();
--- a/TaskManager/kernel/schedule/Scheduler.cc Sat Jul 14 20:44:23 2012 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Sat Jul 14 21:16:27 2012 +0900 @@ -29,7 +29,7 @@ static int null_run(SchedTask* smanager, void* r, void *w) { - smanager->printf("Calling Undefined Task %d\n", smanager->task->command==TaskArray1? smanager->atask->command: smanager->task->command); + smanager->printf("Calling Undefined Task %d\n", smanager->atask->command); return 0; }