Mercurial > hg > Game > Cerium
changeset 941:fc6cfaae6de7 draft
add no_auto_free flag on HTask
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 31 Jul 2010 17:50:38 +0900 |
parents | e01b551f25d6 |
children | 27df980045b5 |
files | TaskManager/Cell/spe/SpeTaskManagerImpl.h TaskManager/ChangeLog TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskBase.h example/many_task/sort.cc |
diffstat | 9 files changed, 41 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/spe/SpeTaskManagerImpl.h Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/Cell/spe/SpeTaskManagerImpl.h Sat Jul 31 17:50:38 2010 +0900 @@ -26,6 +26,7 @@ void spawn_task(HTaskPtr); void set_task_cpu(HTaskPtr, CPU_TYPE); void polling() {} + void free_htask(HTaskPtr htask) {} } ;
--- a/TaskManager/ChangeLog Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/ChangeLog Sat Jul 31 17:50:38 2010 +0900 @@ -8,6 +8,9 @@ その代わり、dead lock が起きる。待ち先のtaskが消滅する場合が あるらしい。 + やっぱり、既に終了した task に対して wait for してしまうのが + まずいらしい。自分で HTask をfree してやれば良いわけだが.. + 2010-7-30 Shinji KONO <kono@ie.u-ryukyu.ac.jp> TASK_LIST_MAIL でない方が高速なみたい
--- a/TaskManager/kernel/ppe/HTask.h Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/kernel/ppe/HTask.h Sat Jul 31 17:50:38 2010 +0900 @@ -41,6 +41,10 @@ HTask *next; HTask *prev; + struct { + unsigned no_auto_free:1; // bit 0 auto free flag (0 .. auto, 1 manual) + } flag; + void spawn(); void wait_for(HTask *); void set_cpu(CPU_TYPE type); @@ -91,6 +95,10 @@ t->set_param_t(index, param); } + void no_auto_free() { + flag.no_auto_free = 1; + } + void init(int cmd) { next = prev = NULL; waiter = NULL; @@ -99,6 +107,7 @@ param_index = 0; in_index = 0; out_index = 0; + flag.no_auto_free = 0; self = (memaddr) this; post_func = NULL;
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Sat Jul 31 17:50:38 2010 +0900 @@ -94,6 +94,7 @@ TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave) { TaskQueuePtr m, s; + if (!master->self) return; m = taskQueueImpl->create(master); s = taskQueueImpl->create(slave); @@ -118,8 +119,6 @@ } else { append_waitTask(task); } - - // systask_finish->wait_for(task); } @@ -194,7 +193,8 @@ // id かななんかでチェックした方が良いが... me->self = 0; - htaskImpl->free_(me); + if (!me->flag.no_auto_free) + htaskImpl->free_(me); } /**
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Sat Jul 31 17:50:38 2010 +0900 @@ -54,6 +54,16 @@ virtual void set_task_cpu(HTaskPtr, CPU_TYPE); void set_taskList(HTaskPtr htask, TaskListInfoPtr taskList) ; + void free_htask(HTaskPtr htask) { +#if !defined(__SPU__) + if (htask->self) { + htask->flag.no_auto_free = 0; + return; + } + htaskImpl->free_(htask); +#endif + } + void* allocate(int size, int alignment) { void *buff = 0;
--- a/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sat Jul 31 17:50:38 2010 +0900 @@ -282,6 +282,12 @@ return manager->create_task_array(id, num_task, num_param, num_inData, num_outData, __builtin_return_address(0)); } +void SchedTask::free_htask(HTask *p) { +#if !defined(__SPU__) + manager->free_htask(p); +#endif +} + void SchedTask::set_task_depend(HTaskPtr master, HTaskPtr slave) {
--- a/TaskManager/kernel/schedule/SchedTask.h Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sat Jul 31 17:50:38 2010 +0900 @@ -70,6 +70,7 @@ void *allocate(int size); void free_(void *p) ; + void free_htask(HTask *p) ; void polling();
--- a/TaskManager/kernel/schedule/SchedTaskBase.h Sat Jul 31 16:44:10 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskBase.h Sat Jul 31 17:50:38 2010 +0900 @@ -9,6 +9,7 @@ class Scheduler; class MemorySegment; class MemList; +class HTask; class SchedTaskBase { public: @@ -71,6 +72,7 @@ virtual void* allocate(int size,int align) {return 0;} virtual Scheduler* get_scheduler() {return 0;} virtual long get_random() {return 0;} + virtual void free_htask(HTask *h) {} /* variables */
--- a/example/many_task/sort.cc Sat Jul 31 16:44:10 2010 +0900 +++ b/example/many_task/sort.cc Sat Jul 31 17:50:38 2010 +0900 @@ -106,6 +106,7 @@ if (split_num > 1) { for (int i = 0; i < half_num-1; i++) { + if (bsort[i]) manager->free_htask(bsort[i]); bsort[i] = manager->create_task(QUICK_SORT, (memaddr)&data[i*block_num+half_block_num], sizeof(Data)*block_num, (memaddr)&data[i*block_num+half_block_num], sizeof(Data)*block_num); @@ -115,6 +116,7 @@ { int i = half_num-1; + if (bsort[i]) manager->free_htask(bsort[i]); bsort[i] = manager->create_task(QUICK_SORT, (memaddr)&data[i*block_num+half_block_num], sizeof(Data)*last_half_block_num, (memaddr)&data[i*block_num+half_block_num], sizeof(Data)*last_half_block_num); @@ -124,6 +126,7 @@ for (int i = 0; i < half_num; i++) { bsort[i]->wait_for(fsort[i]); bsort[i]->wait_for(fsort[i+1]); + bsort[i]->no_auto_free(); bsort[i]->spawn(); } } @@ -186,9 +189,9 @@ } if (split_num > 1) { - HTaskPtr bsort[half_num]; for (int i = 0; i < half_num-1; i++) { + if (bsort[i]) manager->free_htask(bsort[i]); bsort[i] = manager->create_task(QUICK_SORT); bsort[i]->add_inData(&data[i*block_num+half_block_num], sizeof(Data)*block_num); @@ -201,6 +204,7 @@ { int i = half_num-1; + if (bsort[i]) manager->free_htask(bsort[i]); bsort[i] = manager->create_task(QUICK_SORT); bsort[i]->add_inData(&data[i*block_num+half_block_num], sizeof(Data)*last_half_block_num); @@ -213,6 +217,7 @@ for (int i = 0; i < half_num; i++) { bsort[i]->wait_for(fsort[i]); bsort[i]->wait_for(fsort[i+1]); + bsort[i]->no_auto_free(); bsort[i]->spawn(); } }