Mercurial > hg > Game > Cerium
changeset 538:5641d121818e draft
code_load in read()
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 12 Oct 2009 02:50:01 +0900 |
parents | 053da4e2e8bf |
children | 3bc98f6d31ff |
files | TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/CellTaskManagerImpl.h TaskManager/ChangeLog TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/Fifo/FifoTaskManagerImpl.h TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskList.cc TaskManager/kernel/schedule/Scheduler.cc example/renew_task/main.cc example/renew_task/spe/Renew1.cc example/renew_task/spe/RenewStart.cc |
diffstat | 13 files changed, 106 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Mon Oct 12 02:50:01 2009 +0900 @@ -274,6 +274,14 @@ void* +CellTaskManagerImpl::allocate(int size, int alignment) +{ + void *buff; + posix_memalign(&buff, alignment, size); + return buff; +} + +void* CellTaskManagerImpl::allocate(int size) { void *buff; @@ -281,7 +289,7 @@ posix_memalign(&buff, DEFAULT_ALIGNMENT, size); // bzero はコストが高いのでやりたくない - bzero(buff, size); + // bzero(buff, size); return buff; }
--- a/TaskManager/Cell/CellTaskManagerImpl.h Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.h Mon Oct 12 02:50:01 2009 +0900 @@ -30,17 +30,11 @@ // user int add_data(ListDataPtr, uint32, int); void* allocate(int size); + void* allocate(int size,int align); Scheduler* get_scheduler(); private: void send_taskList(int id); }; -#ifdef Cerium_malloc -#undef Cerium_malloc #endif - -#define Cerium_malloc(dest, align, size) \ - posix_memalign((void**)(dest), (align), (size)) - -#endif
--- a/TaskManager/ChangeLog Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/ChangeLog Mon Oct 12 02:50:01 2009 +0900 @@ -1,3 +1,27 @@ +2009-10-11 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + 単純な、rbuf, wbuf + write return size の task のAPI + List DMA の API + 投入 cpu 別の spawn method + Redering 時の内部からの DMA への直接アクセスへの禁止等など + + set_post で登録する関数も、task のrun関数と同じ型にした方が便利そう。 + + SPU側でも配列(TaskList)ではなく、TaskQueue で管理すれば、 + renew task は簡単に実装できる。 + + SchedTask の renew かそうでないかの区別は全部なくす。ex_init とかは、 + なくなるはず。その代わり TaskQueue で管理する。 + + TaskList に inListData/outListData が入っているのは、やはりおかしい。 + もっとコンパクトであるべき。 + + TaskList は、こまめに終了をPPE側へ知らせるのではなく、TaskListの + 書き換えで知らせる方が良い。 + + SPUからPPUへ、create task 出来た方が良い。それはTaskList の書き出し + で行なう。 + 2009-10-11 Shinji KONO <kono@ie.u-ryukyu.ac.jp> ようやっと直せました。inListData/outListData は別に転送しないで、
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Mon Oct 12 02:50:01 2009 +0900 @@ -233,9 +233,27 @@ } void* +FifoTaskManagerImpl::allocate(int size, int alignment) +{ +#ifdef __APPLE__ + return malloc(size); +#else + void *buff; + posix_memalign(&buff, alignment, size); + return buff; +#endif +} + +void* FifoTaskManagerImpl::allocate(int size) { +#ifdef __APPLE__ return malloc(size); +#else + void *buff; + posix_memalign(&buff, DEFAULT_ALIGNMENT, size); + return buff; +#endif } Scheduler*
--- a/TaskManager/Fifo/FifoTaskManagerImpl.h Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.h Mon Oct 12 02:50:01 2009 +0900 @@ -30,13 +30,10 @@ // call by user int add_data(ListDataPtr, uint32, int); + void* allocate(int size,int align); void* allocate(int size); Scheduler* get_scheduler(); }; -#ifndef Cerium_malloc -#define Cerium_malloc(dest, align, size) \ - *dest = malloc(size); -#endif /* Cerium_malloc */ #endif /* INCLUDED_FIFO_TASK_MANAGER_IMPL */
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Mon Oct 12 02:50:01 2009 +0900 @@ -44,6 +44,7 @@ void spawn_task(HTaskPtr); void set_task_cpu(HTaskPtr, CPU_TYPE); virtual void* allocate(int size) = 0; + virtual void* allocate(int size,int align) = 0; virtual Scheduler* get_scheduler() = 0; }; #endif
--- a/TaskManager/kernel/schedule/SchedTask.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Mon Oct 12 02:50:01 2009 +0900 @@ -153,6 +153,34 @@ void SchedTask::read() { + __debug("[SchedTask:%s]\n", __FUNCTION__); + +#if 0 +#if !defined(NO_PIPELINE) + scheduler->dma_wait(DMA_READ_IN_LIST); + scheduler->dma_wait(DMA_READ_OUT_LIST); +#endif +#endif + // object creation をSchedTask生成時にやらないので、 + // exec の直前のread で十分に間に合う + if (cur_index < list->length) { + // load next task + loadSchedTask(scheduler, &list->tasks[cur_index]); + } + + writebuf = scheduler->allocate(outListData->size); + + // 読むデータが一つもなければ無視 + if (inListData->length == 0) return; + + // load Input Data + readbuf = scheduler->allocate(inListData->size); + scheduler->dma_loadList(inListData, readbuf, DMA_READ); + +#if defined(NO_PIPELINE) + scheduler->dma_wait(DMA_READ); +#endif + (this->*ex_read)(); } @@ -170,28 +198,6 @@ void SchedTask::ex_read_normal() { - __debug("[SchedTask:%s]\n", __FUNCTION__); - -#if 0 -#if !defined(NO_PIPELINE) - scheduler->dma_wait(DMA_READ_IN_LIST); - scheduler->dma_wait(DMA_READ_OUT_LIST); -#endif -#endif - - writebuf = scheduler->allocate(outListData->size); - - // 読むデータが一つもなければ無視 - if (inListData->length == 0) return; - - // load Input Data - readbuf = scheduler->allocate(inListData->size); - scheduler->dma_loadList(inListData, readbuf, DMA_READ); - -#if defined(NO_PIPELINE) - scheduler->dma_wait(DMA_READ); -#endif - } void @@ -342,10 +348,6 @@ return nextSched; } else { TaskPtr nextTask = &list->tasks[cur_index++]; - if (cur_index < list->length) { - // load next task - loadSchedTask(scheduler, &list->tasks[cur_index]); - } nextSched = createSchedTask(scheduler, nextTask); ((SchedTask*)nextSched)->init(list, nextTask, cur_index, // scheduler->get_curReadBuf(), @@ -376,10 +378,6 @@ if (cur_index < list->length) { nextTask = &list->tasks[cur_index++]; - if (cur_index < list->length) { - // load next task - loadSchedTask(scheduler, &list->tasks[cur_index]); - } nextSched = createSchedTask(scheduler, nextTask); // RenewTaskList を実行中なので @@ -409,10 +407,6 @@ cur_index = scheduler->get_backupTaskListIndex(); nextTask = &nextList->tasks[cur_index++]; - if (cur_index < list->length) { - // load next task - loadSchedTask(scheduler, &list->tasks[cur_index]); - } nextSched = createSchedTask(scheduler, nextTask); nextSched->init(nextList, nextTask, cur_index,
--- a/TaskManager/kernel/schedule/SchedTask.h Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Mon Oct 12 02:50:01 2009 +0900 @@ -111,10 +111,12 @@ void* get_output(void *buff, int index); uint32 get_inputAddr(int index); uint32 get_outputAddr(int index); + // 書き出しを追加する API がない... int get_inputSize(int index); int get_outputSize(int index); int get_param(int index); + TaskPtr create_task(int cmd); void wait_task(TaskPtr waitTask); @@ -140,6 +142,7 @@ scheduler->free_(p); } + /* これは禁止するべき */ void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask); void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask); void dma_wait(uint32 mask);
--- a/TaskManager/kernel/schedule/SchedTaskList.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskList.cc Mon Oct 12 02:50:01 2009 +0900 @@ -67,13 +67,6 @@ } else { TaskPtr nextTask = &list->tasks[0]; - // code load を開始する。 - loadSchedTask(scheduler, nextTask); - if (1 < list->length) { - // 次のもloadしておく - // load next task - loadSchedTask(scheduler, &list->tasks[1]); - } nextSched = createSchedTask(scheduler, nextTask); if (flag_renewTaskList == SCHED_TASKLIST_RENEW) {
--- a/TaskManager/kernel/schedule/Scheduler.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Mon Oct 12 02:50:01 2009 +0900 @@ -347,12 +347,13 @@ m->code_segment_pool, task_list[task_id].end-task_list[task_id].location); task_list[task_id].segment = s; - +#if 0 fprintf(stderr,"loadng task id %d at 0x%x entry 0x%x\n",task_id, (unsigned int)(task_list[task_id].segment->data ), (unsigned int)( (char*)task_list[task_id].segment->data + task_list[task_id].entry_offset)); +#endif } static void @@ -364,10 +365,12 @@ wait_load(Scheduler *m, int task_id) { MemorySegment *s = task_list[task_id].segment; +#if 0 if (s) fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data); else fprintf(stderr,"wait load task id %d 000000\n",task_id); +#endif // wait for code segment load m->wait_segment(task_list[task_id].segment); // calcurate call address @@ -376,9 +379,11 @@ (char*)task_list[task_id].segment->data + task_list[task_id].entry_offset); task_list[task_id].run = run; +#if 0 fprintf(stderr,"wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, (unsigned int)run, task_list[task_id].entry_offset); +#endif } static void @@ -406,11 +411,13 @@ task_list[cmd].entry_offset = entry_offset; task_list[cmd].load = load_task; task_list[cmd].wait = wait_load; +#if 0 fprintf(stderr,"cmd = %d\n",cmd); fprintf(stderr,"locatation = 0x%x\n",start); fprintf(stderr,"end = 0x%x\n",start+size); fprintf(stderr,"size = 0x%x\n",size); fprintf(stderr,"entry = 0x%x\n",entry_offset); +#endif }
--- a/example/renew_task/main.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/example/renew_task/main.cc Mon Oct 12 02:50:01 2009 +0900 @@ -31,6 +31,7 @@ renew = manager->create_task(RENEW_START); renew->set_cpu(SPE_ANY); renew->add_param(i); + renew->add_param((int)&task_count); // add Active Queue renew->spawn();
--- a/example/renew_task/spe/Renew1.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/example/renew_task/spe/Renew1.cc Mon Oct 12 02:50:01 2009 +0900 @@ -14,7 +14,10 @@ profile->ProfPrint(); int *test_num = (int *)s->get_input(rbuf,0); - s->printf("[SPE] test_num = %d\n", *test_num); + int *local_num = (int *)s->get_param(0); + + s->printf("[SPE] Renew1 test_num = %d\n", *test_num); + s->printf("[SPE] Renew1 local_num = %d\n", *local_num); s->printf("[SPE] ** running Renew1\n");
--- a/example/renew_task/spe/RenewStart.cc Sun Oct 11 20:07:47 2009 +0900 +++ b/example/renew_task/spe/RenewStart.cc Mon Oct 12 02:50:01 2009 +0900 @@ -15,13 +15,18 @@ // overlay で動くの? SpeProfile *profile = new (tmp) SpeProfile; - s->printf("[SPE] Create Task : Renew1\n"); + int id = s->get_param(0); + s->printf("[SPE] Create Task : Renew1 %d\n", id); TaskPtr nextTask = s->create_task(RENEW1); + int *test_num = s->get_param(1); + int *local_num = s->allocate(sizeof(int)); + *local_num = 555; - int *test_num = (int *)s->allocate(sizeof(int)); - *test_num = 10; + // この add_inData は、メインメモリのアドレスになる。 nextTask->add_inData(test_num, sizeof(int)); + // local なアドレスを渡したい時には、set_param を使う。 + nextTask->add_param(local_num); s->wait_task(nextTask);