Mercurial > hg > Game > Cerium
changeset 1462:8cf62aea798f draft
HTask/TaskList fix (on going)
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 14 Jul 2012 19:15:09 +0900 |
parents | db5c022d871c |
children | f7e497c8e8a3 |
files | TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/TaskList.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskBase.h |
diffstat | 9 files changed, 53 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Sat Jul 14 19:15:09 2012 +0900 @@ -354,7 +354,9 @@ TaskListPtr CellTaskManagerImpl::createTaskList() { - return taskListInfo[0]->create(); + TaskListPtr tl = taskListInfo[0]->create(); + bzero(tl->tasks,sizeof(Task)*TASK_MAX_SIZE); + return tl; }
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Sat Jul 14 19:15:09 2012 +0900 @@ -322,7 +322,9 @@ TaskListPtr FifoTaskManagerImpl::createTaskList() { - return taskListInfo->create(); + TaskListPtr tl = taskListInfo->create(); + bzero(tl->tasks,sizeof(Task)*TASK_MAX_SIZE); + return tl; } /**
--- a/TaskManager/kernel/ppe/HTask.cc Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Sat Jul 14 19:15:09 2012 +0900 @@ -20,6 +20,8 @@ HTask::spawn(void) { tasklog->create_time = rdtsc(); + TaskList *tl = (TaskList*)rbuf; + tl->self = this; mimpl->spawn_task(this); } @@ -82,18 +84,12 @@ HTask::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData) { r_size = 0; - int sz = Task::calc_size(num_param, num_inData, num_outData); TaskListPtr tl = mimpl->createTaskList(); - if (sz>tl-> sizeof(tl->tasks)) { - mimpl->get_scheduler()->printf("too large task array.\n"); - } + tl->self = 0; rbuf = (memaddr)tl; - //printf("r_size %d\n",r_size); - //bzeroするのはcostが高いので外したい - bzero(tl->tasks,sizeof(tasks)); + bzero(tl->tasks,sizeof(Task)*TASK_MAX_SIZE); Task *task = tl->tasks; task->init(id, num_param,num_inData,num_outData); -// task->print(); return task; // first task } @@ -106,18 +102,12 @@ Task * HTask::next_task_array(int id, Task *t) { - Task *first = (Task*)rbuf; + TaskPtr t1 = t; if (t==0) { -// first->print(); - first->init(id, param_count, inData_count, outData_count); - return first; + TaskList *tl = (TaskList*)rbuf; + t1 = tl->tasks; } - - Task *next = t->next(); - next->init(id, first->param_count, first->inData_count, first->outData_count); - if ((memaddr)next - (memaddr)rbuf > r_size) - mimpl->get_scheduler()->printf("too many task array used.\n"); - return next; + return next_task_array(id,t,t1->param_count,t1->inData_count,t1->outData_count); } /*! @@ -129,17 +119,25 @@ Task * HTask::next_task_array(int id, Task *t, int param_count, int inData_count, int outData_count) { - Task *first = (Task*)rbuf; + TaskList *tl = (TaskList*)rbuf; if (t==0) { -// first->print(); - first->init(id, param_count, inData_count, outData_count); - return first; + tl->tasks->init(id, param_count, inData_count, outData_count); + return tl->tasks; } - Task *next = t->next(); + if (next >= tl->last()) { + TaskListPtr nextTaskList = mimpl->createTaskList(); + nextTaskList->prev = tl; + 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); - if ((memaddr)next - (memaddr)rbuf > r_size) - mimpl->get_scheduler()->printf("too many task array used.\n"); return next; } @@ -152,14 +150,8 @@ void HTask::spawn_task_array(Task * last) { - int size = (memaddr)last - rbuf; - if (size!= r_size) { - mimpl->get_scheduler()->printf("spawn task array size differ size 0x%x r_size 0x%x\n", - size, r_size); - } + // do nothing now } - - /* end */
--- a/TaskManager/kernel/ppe/HTask.h Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/ppe/HTask.h Sat Jul 14 19:15:09 2012 +0900 @@ -4,6 +4,7 @@ #include "base.h" #include "types.h" #include "Task.h" +#include "TaskList.h" #include "TaskQueue.h" #include "QueueInfo.h" #include "TaskLog.h" @@ -90,7 +91,7 @@ char *p = (char *)addr; char b = *p; p = (char *)(addr+size-1); b += *p; #endif - Task *t = (Task*)rbuf; + Task *t = ((TaskList*)rbuf)->tasks; t->set_inData_t(index, addr,size); } void set_outData_t(int index, memaddr addr, int size) { @@ -102,12 +103,12 @@ char *p = (char *)addr; char b = *p; p = (char *)(addr+size-1); b += *p; #endif - Task *t = (Task*)rbuf; + Task *t = ((TaskList*)rbuf)->tasks; t->set_outData_t(index, addr,size); } void set_param_t(int index, memaddr param) { if (command==TaskArray1) { - Task *t = (Task*)rbuf; + Task *t = ((TaskList*)rbuf)->tasks; t->set_param_t(index, param); } else { this->param = param;
--- a/TaskManager/kernel/ppe/TaskList.h Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/ppe/TaskList.h Sat Jul 14 19:15:09 2012 +0900 @@ -4,6 +4,7 @@ #include "base.h" #include "Task.h" +class HTask; #define TASK_MAX_SIZE 31 @@ -11,13 +12,15 @@ public: BASE_NEW_DELETE(TaskList); - int length; // 4 byte + long length; // 4 byte TaskList *next; // 4 byte TaskList *prev; // 4 byte TaskList *waiter; // 4 byte - int dummy[4]; // 16 byte - SimpleTask tasks[TASK_MAX_SIZE]; // 32*TASK_MAX_SIZE + HTask *self; // 4 byte + 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; } void initOnce() { } void freeOnce() {}
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Jul 14 19:15:09 2012 +0900 @@ -329,17 +329,10 @@ void TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue) { - for(int i = 0;i<list->length;i++) { - SimpleTaskPtr task = &list->tasks[i]; - HTask *me = (HTask*)task->self; - me->post_func(s, me->post_arg1, me->post_arg2); - if (task->command==TaskArray1) { - int next = ((task->r_size)/sizeof(SimpleTask))+1; - // assert(next<list->length); - i+=next; - } - s->polling(); - check_task_finish(me, wait_queue); + HTask *me = list->self; + if (me) { + me->post_func(s, me->post_arg1, me->post_arg2); + check_task_finish(me, wait_queue); } } @@ -356,50 +349,21 @@ } /** - @brief htask を DMA でCPUに渡すための TaskList に入れる (copy) + @brief htask のTaskListを DMA でCPUに渡すための TaskListQueue に入れる @param htask @param taskList - TaskList は自動的に延長される */ void TaskManagerImpl::set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList) { htask->tasklog->execute_time = rdtsc(); - - TaskListPtr list ; - if ( taskList->empty() ) { - list = taskList->create(); - taskList->addLast(list); - } else - list = taskList->getLast(); - SimpleTaskPtr task = &list->tasks[list->length++]; - if (htask->command==TaskArray1) { - // compatibility - int next = ((htask->r_size)/sizeof(SimpleTask))+1; - if (list->length+next>=TASK_MAX_SIZE) { - list->length--; - TaskListPtr newList = taskList->create(); - taskList->addLast(newList); - list = newList; - task = &list->tasks[list->length++]; - } - Task *array = (Task*)&list->tasks[list->length]; - list->length += next; - if (list->length>=TASK_MAX_SIZE) { - perror("task array1 overflow\n"); - } - memcpy(array, htask->rbuf, htask->r_size); - free(htask->rbuf); - // htask->rbuf = 0; htask->r_size = 0; we need this... - *task = *(SimpleTask*)htask; - } else { - *task = *(SimpleTask*)htask; - } - if (list->length >= TASK_MAX_SIZE) { - TaskListPtr newList = taskList->create(); - taskList->addLast(newList); - list = newList; + TaskListPtr tl = (TaskList*)htask->rbuf; + while(tl->prev) tl=tl->prev; + while(tl) { + TaskListPtr next = tl->next; + taskList->addLast(tl); + tl = next; } }
--- a/TaskManager/kernel/schedule/SchedTask.cc Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 14 19:15:09 2012 +0900 @@ -12,8 +12,6 @@ #include <stdarg.h> #include "SchedTaskArray.h" -#define Task SimpleTask -#define TaskPtr SimpleTaskPtr extern TaskObject task_list[MAX_TASK_OBJECT];
--- a/TaskManager/kernel/schedule/SchedTask.h Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sat Jul 14 19:15:09 2012 +0900 @@ -32,7 +32,7 @@ public: /* functions */ - void init(TaskListPtr _list, SimpleTaskPtr _task, int index, + void init(TaskListPtr _list, TaskPtr _task, int index, Scheduler* sc, int tag); //--- User API ---
--- a/TaskManager/kernel/schedule/SchedTaskBase.h Fri Mar 16 00:51:03 2012 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskBase.h Sat Jul 14 19:15:09 2012 +0900 @@ -87,7 +87,7 @@ TaskManagerImpl *manager; DmaManager* connector; - SimpleTaskPtr task; + TaskPtr task; TaskPtr atask; SchedTaskBase *savedTask;