Mercurial > hg > Game > Cerium
changeset 1463:f7e497c8e8a3 draft
TaskList on going...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Jul 2012 20:44:23 +0900 |
parents | 8cf62aea798f |
children | 3f2230d79eba |
files | TaskManager/Makefile.def TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/TaskList.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskBase.h |
diffstat | 6 files changed, 129 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Makefile.def Sat Jul 14 19:15:09 2012 +0900 +++ b/TaskManager/Makefile.def Sat Jul 14 20:44:23 2012 +0900 @@ -29,7 +29,7 @@ ABIBIT = 64 -OPT = -g -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE +OPT = -g -DMAIL_QUEUE -DNOT_CHECK -DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE #OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE
--- a/TaskManager/kernel/ppe/HTask.cc Sat Jul 14 19:15:09 2012 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Sat Jul 14 20:44:23 2012 +0900 @@ -126,6 +126,7 @@ } Task *next = t->next(); if (next >= tl->last()) { + tl->lastTask = t; TaskListPtr nextTaskList = mimpl->createTaskList(); nextTaskList->prev = tl; tl->next = nextTaskList; @@ -150,7 +151,7 @@ void HTask::spawn_task_array(Task * last) { - // do nothing now + tl->lastTask = last; }
--- a/TaskManager/kernel/ppe/TaskList.h Sat Jul 14 19:15:09 2012 +0900 +++ b/TaskManager/kernel/ppe/TaskList.h Sat Jul 14 20:44:23 2012 +0900 @@ -12,7 +12,7 @@ public: BASE_NEW_DELETE(TaskList); - long length; // 4 byte + TaskList *lastTask; // 4 byte TaskList *next; // 4 byte TaskList *prev; // 4 byte TaskList *waiter; // 4 byte @@ -20,8 +20,8 @@ long dummy[3]; // 16 byte Task tasks[TASK_MAX_SIZE]; // 32*TASK_MAX_SIZE - TaskPtr last() { return &tasks[TASK_MAX_SIZE]; } - void init() { length = 0; waiter=this; } + TaskPtr last() { return &tasks; } + void init() { lastTask = &tasks[TASK_MAX_SIZE]; waiter=this; } void initOnce() { } void freeOnce() {}
--- a/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 14 19:15:09 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 14 20:44:23 2012 +0900 @@ -28,8 +28,6 @@ this->stdout_ = stdout; this->stderr_ = stderr; this->stdin_ = stdin; - - } SchedTask::~SchedTask() @@ -40,7 +38,7 @@ SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, Scheduler* sc, int tag) { list = _list; - task = _task; + atask = _task; scheduler = sc; cur_index = index; this->tag = tag; @@ -49,6 +47,18 @@ manager = sc->manager; connector = sc->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 = _task; + this->tag = tag; + #ifdef TASK_LIST_MAIL if (list) waiter = (memaddr) list->waiter; @@ -70,17 +80,31 @@ loadSchedTask(scheduler, task->command); // 読むデータが一つもなければ無視 - if (task->r_size == 0) return; + 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 - readbuf = connector->dma_load(scheduler, task->rbuf,task->r_size, DMA_READ + this->tag); - - + // inListData.print(); + readbuf = connector->dma_loadList(scheduler, &inListData, (DMA_READ + this->tag)); + connector->bound(&inListData); } void SchedTask::setup_outputData() { - writebuf = connector->get_writebuf(scheduler, task->wbuf, task->w_size); + // 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); } void @@ -96,9 +120,10 @@ connector->free_(readbuf); // 書き込む領域がなければ無視 - - if (task->w_size > 0) { - connector->dma_store(writebuf, task->wbuf,task->w_size, DMA_WRITE); + // User 側で作る方法が必要... + if (atask->outData_count > 0) { + // outListData.print(); + connector->dma_storeList(&outListData, writebuf, DMA_WRITE); } } @@ -109,8 +134,10 @@ connector->dma_wait(DMA_WRITE); connector->free_(writebuf); + free(inListData.bound); + free(outListData.bound); #ifdef TASK_LIST_MAIL - if (!(cur_index < list->length) ) + if ((cur_index->next() >= list->last()) ) connector->mail_write(waiter); #else connector->mail_write(waiter); @@ -122,26 +149,13 @@ { __debug("[SchedTask:%s]\n", __FUNCTION__); - if (cur_index < list->length) { + if (cur_index->next() < list->last()) { // Task List が残っているので、次を準備 - TaskPtr nextTask = &list->tasks[cur_index]; + TaskPtr nextTask = cur_index = atask->next(); - SchedTask *nextSched = new SchedTask(); - nextSched->init(list, nextTask, cur_index+1, scheduler, this->tag^1); - // この時点で、TaskList は down load が済んでないことがある - // 最初のTaskの種類に関しては、別な情報で渡す方が良い - // あるいはTaskListの最初には、TaskArray1/TaskArray を置かない? - - if (nextTask->command==TaskArray1) { - // compatibility - return new SchedTaskArray(scheduler, nextSched); - } - if (nextTask->command==TaskArray) { - // Start Task Array - int dma_tag_switch = 0; - return new SchedTaskArrayLoad(scheduler, nextSched, dma_tag_switch); - } + SchedTask *nextSched = new SchedTask(scheduler); + nextSched->init(list, nextTask, scheduler, this->tag^1); return nextSched; } else { memaddr nextList = (memaddr)list->next; @@ -172,14 +186,81 @@ * SimpleTask has one parameter , one input, one output */ -void* SchedTask::get_input(void *buff, int index) { return readbuf; } -memaddr SchedTask::get_inputAddr(int index) { return task->rbuf; } -int SchedTask::get_inputSize(int index) {return task->r_size; } -void* SchedTask::get_output(void *buff, int index) {return writebuf; } -memaddr SchedTask::get_outputAddr(int index) { return task->wbuf; } -int SchedTask::get_outputSize(int index) { return task->w_size; } -void SchedTask::set_outputSize(int index, int size){task->w_size = size;} -memaddr SchedTask::get_param(int index) { return task->param; } +/** + * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 + * buffer から対応するデータを返す。 + */ +void* +SchedTask::get_input(void *buff, int index) +{ + return (void*)((char*)readbuf + inListData.bound[index]); +} + +/** + * get_input(index) のアドレスを返す + */ +memaddr +SchedTask::get_inputAddr(int index) +{ +#ifdef __CERIUM_CELL__ + return (memaddr)inListData.element[index].addr; +#else + return inListData.element[index].addr; +#endif +} + +/** + * get_input(index) のサイズを返す + */ +int +SchedTask::get_inputSize(int index) +{ + return inListData.element[index].size; +} + +/** + * write buffer の領域を返す。 + */ +void* +SchedTask::get_output(void *buff, int index) +{ + return (void*)((char *)writebuf + outListData.bound[index]); +} + +/** + * get_output(index) のアドレスを返す + */ +memaddr +SchedTask::get_outputAddr(int index) +{ +#ifdef __CERIUM_CELL__ + return (memaddr)outListData.element[index].addr; +#else + return outListData.element[index].addr; +#endif +} + +/** + * get_output(index) のサイズを返す + */ +int +SchedTask::get_outputSize(int index) +{ + return outListData.element[index].size; +} + +void +SchedTask::set_outputSize(int index, int size) +{ + outListData.element[index].size = size; +} + +memaddr +SchedTask::get_param(int index) +{ + return *atask->param(index); +} + void*
--- a/TaskManager/kernel/schedule/SchedTask.h Sat Jul 14 19:15:09 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sat Jul 14 20:44:23 2012 +0900 @@ -36,9 +36,9 @@ Scheduler* sc, int tag); //--- User API --- - int read_size() { return task->r_size; } - int write_size() { return task->w_size; } - void set_write_size(int w) { task->w_size = w; } + //int read_size() { return get_inputSize(0); } + //int write_size() { return task->w_size; } + //void set_write_size(int w) { task->w_size = w; } void setup_outputData(); void* get_input(void *buff, int index);
--- a/TaskManager/kernel/schedule/SchedTaskBase.h Sat Jul 14 19:15:09 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskBase.h Sat Jul 14 20:44:23 2012 +0900 @@ -87,20 +87,16 @@ TaskManagerImpl *manager; DmaManager* connector; - TaskPtr task; TaskPtr atask; - SchedTaskBase *savedTask; // 現在スケジューラが実行している TaskList と、このタスクに対応する Task TaskListPtr list; - // Task の、Tasklist での位置。(task = &list[cur_index-1]) - int cur_index; + // Task の、Tasklist での位置 + TaskPtr cur_index; int tag; - memaddr params_addr; memaddr waiter; - Task *array; /** * read データ、write 用のバッファ @@ -117,7 +113,6 @@ FILE *stderr_; FILE *stdin_; - // Task Array しか使わないが、たいした大きさではないのでいいか... ListData inListData; ListData outListData;