# HG changeset patch # User Shinji KONO # Date 1260702858 -32400 # Node ID dcaa40ec963d4c18b058b12e3335832db3568b24 # Parent 257ad1a518e33b0926cf7679e509b6fb564632de no compile error for Task Array diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/ppe/Task.h --- a/TaskManager/kernel/ppe/Task.h Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.h Sun Dec 13 20:14:18 2009 +0900 @@ -107,8 +107,22 @@ } return task_size; } - int inData_total_size() ; - int outData_total_size() ; + int inData_total_size() { + int size = 0; + ListElement *inData = inListData(); + for(int i=0; i< inData_count; i++) { + size += inData[i].size; + } + return size; + } + int outData_total_size() { + int size = 0; + ListElement *outData = inListData(); + for(int i=0; i< outData_count; i++) { + size += outData[i].size; + } + return size; + } void set_inData_t( int index, memaddr addr, int size); void set_outData_t(int index, memaddr addr, int size); diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/schedule/SchedTask.cc --- a/TaskManager/kernel/schedule/SchedTask.cc Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sun Dec 13 20:14:18 2009 +0900 @@ -15,7 +15,7 @@ #define TaskPtr SimpleTaskPtr #endif -extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; +extern TaskObject task_list[MAX_TASK_OBJECT]; /** Task Object を作る @@ -28,11 +28,9 @@ return new SchedTask(); } - +#if 0 /** code load を始める。既に get_segment hash に入っていれば何もしない。 - 最初の一回は SchedTaskList:: next から呼ばれる。 - この段階では、SchedTask object は、まだ作られてない。 */ extern void loadSchedTask(Scheduler *scheduler,TaskPtr task) @@ -40,6 +38,7 @@ // fprintf(stderr,"loadSchedTask %d\n",task->command); task_list[task->command].load(scheduler,task->command); } +#endif SchedTask::SchedTask() @@ -95,9 +94,9 @@ // object creation をSchedTask生成時にやらないので、 // exec の直前のread で十分に間に合う - if (cur_index < list->length) { + if (cur_index < list->length) { // if 文は要らないのでは? // load next task - loadSchedTask(scheduler, &list->tasks[cur_index]); + loadSchedTask(scheduler, list->tasks[cur_index].command); } #ifdef SIMPLE_TASK // 読むデータが一つもなければ無視 @@ -270,6 +269,19 @@ { return task->param[index]; } + +#else + +void* SchedTask::get_input(void *buff, int index) { + printf("Cannot use inData in SimpleTask use TaskArray\n"); + return NULL; } +memaddr SchedTask::get_inputAddr(int index) { return NULL; } +int SchedTask::get_inputSize(int index) {return 0; } +void* SchedTask::get_output(void *buff, int index) {return 0; } +memaddr SchedTask::get_outputAddr(int index) { return NULL; } +int SchedTask::get_outputSize(int index) { return 0; } +memaddr SchedTask::get_param(int index) { return 0; } + #endif void* diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/schedule/SchedTask.h --- a/TaskManager/kernel/schedule/SchedTask.h Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sun Dec 13 20:14:18 2009 +0900 @@ -83,14 +83,14 @@ int write_size() { return task->w_size; } void set_write_size(int w) { task->w_size = w; } #endif - void* get_input(void *buff, int index); - void* get_output(void *buff, int index); + virtual void* get_input(void *buff, int index); + virtual void* get_output(void *buff, int index); + virtual memaddr get_param(int index); memaddr get_inputAddr(int index); memaddr get_outputAddr(int index); // 書き出しを追加する API がない... int get_inputSize(int index); int get_outputSize(int index); - memaddr get_param(int index); int get_cpuid(); diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/schedule/SchedTaskArray.cc --- a/TaskManager/kernel/schedule/SchedTaskArray.cc Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskArray.cc Sun Dec 13 20:14:18 2009 +0900 @@ -1,7 +1,6 @@ #include "SchedTaskArray.h" -#include "SchedTask.h" +#include "Scheduler.h" -extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; SchedTaskArray::SchedTaskArray(SchedTaskBase *savedTask_, Task *curTask_, Task *_array) { @@ -44,7 +43,7 @@ // object creation をSchedTaskArray生成時にやらないので、 // exec の直前のread で十分に間に合う - loadSchedTask(scheduler, task); + loadSchedTask(scheduler, task->command); // 読むデータが一つもなければ無視 if (task->inData_count == 0) return; @@ -94,6 +93,8 @@ scheduler->dma_wait(DMA_WRITE); free(writebuf); + free(inListData.bound); + free(outListData.bound); // このTaskArrayは終り。終了を知らせる。 if (task->next() >= last()) { @@ -128,4 +129,75 @@ +/** + * 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; +} + +memaddr +SchedTaskArray::get_param(int index) +{ + memaddr *param = (memaddr*)task->param(index); + return *param; +} + + /* end */ diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/schedule/SchedTaskArray.h --- a/TaskManager/kernel/schedule/SchedTaskArray.h Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskArray.h Sun Dec 13 20:14:18 2009 +0900 @@ -5,6 +5,7 @@ #include "Scheduler.h" #include "SchedTask.h" + class SchedTaskArray : public SchedTask { public: /* constructor */ @@ -19,10 +20,10 @@ private: /* variables */ + TaskPtr task; void *readbuf; void *writebuf; - TaskPtr task; /* functions */ Task *last(); @@ -32,6 +33,13 @@ void write(); SchedTaskBase* next(Scheduler *, SchedTaskBase *); + void* get_input(void*, int); + memaddr get_inputAddr(int); + int get_inputSize(int); + void* get_output(void*, int); + char* get_outputAddr(int); + int get_outputSize(int); + memaddr get_param(int); }; diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/schedule/Scheduler.cc --- a/TaskManager/kernel/schedule/Scheduler.cc Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Sun Dec 13 20:14:18 2009 +0900 @@ -11,7 +11,7 @@ * Do not edit Cell/spe/xx.cc unless there is no kernel/schedule/xx.cc files. */ -Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; +TaskObject task_list[MAX_TASK_OBJECT]; Scheduler::~Scheduler() { diff -r 257ad1a518e3 -r dcaa40ec963d TaskManager/kernel/schedule/Scheduler.h --- a/TaskManager/kernel/schedule/Scheduler.h Sun Dec 13 18:45:09 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Sun Dec 13 20:14:18 2009 +0900 @@ -26,6 +26,21 @@ typedef int (*TaskObjectRun)(SchedTask* smanager, void* r, void *w); +// Task Object Table +// this is named TaskObjectRun but it is not an object. +// It is a pointer to an object creation function +// 大きいので、SPEには置かない方が本当は良い... +// get_segment で取って来るのが、おそらくは正しい。 +typedef struct { + TaskObjectRun run; + memaddr location; // location address in a.out + memaddr end; + uint32 entry_offset; // offset for create(); + MemorySegment *segment; + void (*load)(Scheduler *,int); + void (*wait)(Scheduler *,int); +} TaskObject, *TaskObjectPtr; + extern "C" { extern long random(); } @@ -55,20 +70,6 @@ /* Code Area */ MemList *code_segment_pool; - // Task Object Table - // this is named TaskObjectRun but it is not an object. - // It is a pointer to an object creation function - // 大きいので、SPEには置かない方が本当は良い... - typedef struct { - TaskObjectRun run; - memaddr location; // location address in a.out - memaddr end; - uint32 entry_offset; // offset for create(); - MemorySegment *segment; - void (*load)(Scheduler *,int); - void (*wait)(Scheduler *,int); - } TaskObject, *TaskObjectPtr; - DmaManager* connector; TaskManagerImpl* manager; @@ -152,8 +153,27 @@ unsigned int buf; }; +extern TaskObject task_list[MAX_TASK_OBJECT]; + +#ifdef SIMPLE_TASK +inline void +loadSchedTask(Scheduler *scheduler,int command) +{ +// fprintf(stderr,"loadSchedTask %d\n",task->command); + task_list[command].load(scheduler,command); +} +#else +inline void +loadSchedTask(Scheduler *scheduler,int command) +{ +// fprintf(stderr,"loadSchedTask %d\n",task->command); + task_list[command].load(scheduler,command); +} #endif +#endif + + #define SchedConstructor(str) \ str() {} \ diff -r 257ad1a518e3 -r dcaa40ec963d example/Bulk/main.cc --- a/example/Bulk/main.cc Sun Dec 13 18:45:09 2009 +0900 +++ b/example/Bulk/main.cc Sun Dec 13 20:14:18 2009 +0900 @@ -71,7 +71,7 @@ * Create Task * create_task(Task ID); */ - int size = Task::count_size(2,2,2); + int size = Task::calc_size(2,2,2); printf("allocate task size 0x%0x\n",size); printf("allocate task total size 0x%0x\n",(size *= count));