Mercurial > hg > Members > kono > Cerium
changeset 779:4455e7b0caf3
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 05 Mar 2010 13:12:31 +0900 |
parents | 2b5ff18976cb (diff) 97a514cf6ad3 (current diff) |
children | 50cff7c4d255 |
files | Renderer/Engine/Camera.cc Renderer/Engine/Makefile.def Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/SgChange.cc Renderer/Engine/SgChange.h Renderer/Engine/global_alloc.h Renderer/Engine/spe/DataLoad.cc Renderer/Engine/spe/DataUpdate.cc Renderer/Engine/spe/DrawSpan.cc Renderer/Engine/spe/Makefile Renderer/Engine/spe/spe-main.cc Renderer/Engine/task/DataLoad.cc Renderer/Engine/task/DataUpdate.cc Renderer/Engine/task/task_init.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h Renderer/Test/Makefile.cell Renderer/Test/Makefile.def Renderer/Test/Makefile.macosx Renderer/Test/SgRootChange.cc Renderer/Test/ball_bound.h Renderer/Test/property_test.cc Renderer/Test/property_test.h Renderer/Test/vacuum.cc |
diffstat | 98 files changed, 1732 insertions(+), 1011 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Tue Feb 16 15:09:54 2010 +0900 +++ b/.hgtags Fri Mar 05 13:12:31 2010 +0900 @@ -3,3 +3,6 @@ 30568cef3899caea3db0fb9e28b0e6f889c60679 double-linked-task-list 8fca17aa57dfe07aeff46a3ae1707c795c762d72 examples 9df0112f7ccfe03caffb06e64160ae2a6f3a22dd before_simple_task +a06eef665c455b4da8dbe05595a5628aedd3eb3a before-task-array +226d95fa26917a3242f7700916c3c9823bd2d33d TaskArray +e4d2b823903cc85f54fc47a685e955df8fa866f4 simple-task-regression
--- a/Renderer/Engine/SceneGraphRoot.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Engine/SceneGraphRoot.cc Fri Mar 05 13:12:31 2010 +0900 @@ -25,6 +25,7 @@ sg_src = (SceneGraphPtr*) malloc(sizeof(SceneGraphPtr)*SGLIST_LENGTH); camera = new Camera(w, h, this); + iterator = new SceneGraphIterator; controller = create_controller(); @@ -37,9 +38,6 @@ screen_w = (int)w; screen_h = (int)h; - //int size = 4; - //light_vector = (float*)malloc(sizeof(float)*size); - int light_num = 4; for (int i = 0; i < light_num; i++) { @@ -50,6 +48,7 @@ } move_finish_flag = 0; + // TODO // 今はとりあえず camera を Root にしています // 今はそれすらもしてません @@ -648,3 +647,5 @@ { return light_vector; } + +/* end */
--- a/Renderer/Engine/SgChange.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Engine/SgChange.cc Fri Mar 05 13:12:31 2010 +0900 @@ -26,7 +26,6 @@ /* Data Pack sent to Other CPUs (ex. SPE) */ extern SceneGraphPack *sgpack; -//extern PolygonPack *ppack; extern SpanPackPtr spackList; extern SpanPackPtr *spackList_ptr; @@ -55,30 +54,18 @@ { HTaskPtr task_next = initLoop(); - //task_next->set_post(&post2runLoop, (void *)this, 0); task_next->set_post(&post2run, (void *)this, 0); task_next->spawn(); } + + static void post2run(SchedTask *s, void *sgchange_, void *arg) { SgChange *sgchange = (SgChange*)sgchange_; HTaskPtr task_next = sgchange->manager->create_task(Dummy); sgchange->run_loop(task_next); - - psx_sync_n(); -} - -static void -post2runLoop(SchedTask *s, void *sgchange_, void *arg) -{ - SgChange *sgchange = (SgChange*)sgchange_; - HTaskPtr task_next = sgchange->manager->create_task(Dummy); - sgchange->viewer->light_xyz_stock = sgchange->sgroot_A->getLightVector(); - sgchange->pass_draw_tree(); - sgchange->run_loop(task_next); - psx_sync_n(); } @@ -90,7 +77,6 @@ void SgChange::run_loop(HTaskPtr task_next) -{ viewer->dev->clear_screen(); bool quit_flg; @@ -108,11 +94,6 @@ } sgroot_A->updateControllerState(); - /* - sgroot_A->updateControllerState(); - sgroot_A->allExecute(viewer->width, viewer->height); - viewer->light_xyz_stock = sgroot_A->getLightVector(); - */ HTaskPtr loop_task = manager->create_task(Dummy); loop_task->set_post(post2runLoop, (void *)this, 0); @@ -144,6 +125,7 @@ 描画の最後で spwan させる */ HTaskPtr dummy_task = manager->create_task(Dummy); + draw_finish = dummy_task; loop_task->wait_for(draw_finish);
--- a/Renderer/Engine/show_time.cc Tue Feb 16 15:09:54 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#include <stdio.h> -#include "TaskManager.h" -#include "Func.h" - -void -show_time() -{ - /* - HTaskPtr show; - HTaskPtr pre_show; - */ - /* - show = manager->create_task(ShowTime); - show->set_cpu(SPE_0); - show->spawn(); - printf("testですよ\n"); - */ - - /* - pre_show = manager->create_task(ShowTime); - pre_show->set_cpu((CPU_TYPE)((int)SPE_0)); - pre_show->spawn(); - - for (int i = 1; i < 6; i++) { - show = manager->create_task(ShowTime); - show->set_cpu((CPU_TYPE)((int)SPE_0 + i)); - show->wait_for(pre_show); - show->spawn(); - pre_show = show; - } - */ -}
--- a/Renderer/Engine/show_time.h Tue Feb 16 15:09:54 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -#ifndef SHOW_TIME_H -#define SHOW_TIME_H - -void show_time(); - -#endif
--- a/Renderer/Engine/spe/DataLoad.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Engine/spe/DataLoad.cc Fri Mar 05 13:12:31 2010 +0900 @@ -13,13 +13,9 @@ int size = (int)s->get_param(0); int load_id = (int)s->get_param(1); - //printf("size %d\n",size); s->global_alloc(load_id, size); - //MemList *ml = s->createMemList(length,length); - //s->global_set(load_id, (void *)ml); - return 0; }
--- a/Renderer/Engine/spe/DataUpdate.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Engine/spe/DataUpdate.cc Fri Mar 05 13:12:31 2010 +0900 @@ -15,10 +15,6 @@ int load_id = (int)s->get_param(1); void *global_data = (void*)s->global_get(load_id); - if (size != 64) { - printf("hogehoge\n"); - } - memcpy(global_data,idata,size); return 0;
--- a/Renderer/Engine/spe/Makefile Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Engine/spe/Makefile Fri Mar 05 13:12:31 2010 +0900 @@ -11,6 +11,7 @@ CC = spu-g++ CFLAGS = -Wall -fno-exceptions -fno-rtti $(OPT)#-DDEBUG + INCLUDE = -I$(TOP)/include/TaskManager -I. -I.. LIBS = -L$(TOP)/TaskManager -lspemanager
--- a/Renderer/Engine/spe/Set_Texture.cc Tue Feb 16 15:09:54 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -// #define DEBUG -#include "error.h" -#include <string.h> -#include "Set_Texture.h" -#include "texture.h" -#include "global_alloc.h" - -SchedDefineTask(SetTexture); - -//texture をglobal 領域にコピーするタスク -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - __debug_spe(s, "SetTexture\n"); - void *src[4]; - - src[0] = s->get_input(rbuf, 0); - src[1] = s->get_input(rbuf, 1); - src[2] = s->get_input(rbuf, 2); - src[3] = s->get_input(rbuf, 3); - - if (s->global_get(TEXTURE_ID)) { - return 0; - } else { - //タスクが共有できる領域確保 - void *data = s->global_alloc(TEXTURE_ID, MAX_LOAD_SIZE*4); - - memcpy(data, src[0], MAX_LOAD_SIZE); - memcpy((void*)((int)data + MAX_LOAD_SIZE), src[1], MAX_LOAD_SIZE); - memcpy((void*)((int)data + MAX_LOAD_SIZE*2), src[2], MAX_LOAD_SIZE); - memcpy((void*)((int)data + MAX_LOAD_SIZE*3), src[3], MAX_LOAD_SIZE); - } - - return 0; -}
--- a/Renderer/Engine/spe/Set_Texture.h Tue Feb 16 15:09:54 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#ifndef INCLUDED_TASK_LOAD_TEXTURE -#define INCLUDED_TASK_LOAD_TEXTURE - -#include "SchedTask.h" - - -#endif -
--- a/Renderer/Engine/task/Set_Texture.cc Tue Feb 16 15:09:54 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -#include <string.h> -#include "Set_Texture.h" -#include "texture.h" -#include "global_alloc.h" - -SchedDefineTask(SetTexture); - -//texture をglobal 領域にコピーするタスク -static int -run(SchedTask *s,void *rbuf, void *wbuf) -{ - void *src[4]; - - src[0] = s->get_input(rbuf, 0); - src[1] = s->get_input(rbuf, 1); - src[2] = s->get_input(rbuf, 2); - src[3] = s->get_input(rbuf, 3); - - if (s->global_get(TEXTURE_ID)) { - return 0; - } else { - //タスクが共有できる領域確保 - void *data = s->global_alloc(TEXTURE_ID, MAX_LOAD_SIZE*4); - - memcpy(data, src[0], MAX_LOAD_SIZE); - memcpy((void*)((memaddr)data + MAX_LOAD_SIZE), src[1], MAX_LOAD_SIZE); - memcpy((void*)((memaddr)data + MAX_LOAD_SIZE*2), src[2], MAX_LOAD_SIZE); - memcpy((void*)((memaddr)data + MAX_LOAD_SIZE*3), src[3], MAX_LOAD_SIZE); - } - - return 0; -}
--- a/Renderer/Engine/task/Set_Texture.h Tue Feb 16 15:09:54 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#ifndef INCLUDED_TASK_LOAD_TEXTURE -#define INCLUDED_TASK_LOAD_TEXTURE - -#include "SchedTask.h" - - -#endif -
--- a/Renderer/Engine/viewer.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Engine/viewer.cc Fri Mar 05 13:12:31 2010 +0900 @@ -112,9 +112,7 @@ light_xyz = (float *)manager->allocate(size); for (int i = 0; i < light_size ; i++) { - light_xyz[i] = 0.0f; - } HTaskPtr data_load; @@ -480,9 +478,7 @@ int light_size = size / sizeof(float); for (int i = 0; i < light_size; i++) { - light_xyz[i] = light_xyz_stock[i]; - } data_update_wait = manager->create_task(DataUpdate);
--- a/Renderer/Test/Makefile.cell Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Test/Makefile.cell Fri Mar 05 13:12:31 2010 +0900 @@ -12,6 +12,7 @@ $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ ALL = spe-main ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum dynamic viewer SgRootChange property_test create_task property_universe chain_old property_chain + all: $(ALL) speobject:
--- a/Renderer/Test/Makefile.macosx Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Test/Makefile.macosx Fri Mar 05 13:12:31 2010 +0900 @@ -11,6 +11,7 @@ $(CC) $(CFLAGS) -c $< -o $@ ALL = ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange + oFLAGS=-g -O2 CFLAGt=-g -O2 all: $(ALL)
--- a/Renderer/Test/property_test.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Test/property_test.cc Fri Mar 05 13:12:31 2010 +0900 @@ -9,8 +9,6 @@ ChainPropertyPtr properties[2]; ChainProperty cv[CHAIN_LEN]; -// -//void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, Viewer *sgroot); void createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, SgChange *sgroot); void @@ -141,11 +139,7 @@ void -#if 1 -createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, Viewer *sgroot) -#else createSceneGraphFromProperty(SceneGraphPtr root, ChainPropertyPtr cv, SgChange *sgroot) -#endif { SceneGraphPtr node; @@ -177,11 +171,6 @@ MainLoopPtr Chain::init(Viewer *sgroot, int w, int h) { -#if 0 - SgChange *sgroot = new SgChange(sgroot_); - sgroot->run_init(); -#endif - SceneGraphPtr root, chain; sgroot->createFromXMLfile("xml_file/chain.xml");
--- a/Renderer/Test/property_test.h Tue Feb 16 15:09:54 2010 +0900 +++ b/Renderer/Test/property_test.h Fri Mar 05 13:12:31 2010 +0900 @@ -1,4 +1,4 @@ -#include "Application.h" + #include "SgChange.h" typedef void (*spe_move_func)(void *cv, int screen_w, int screen_h);
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Fri Mar 05 13:12:31 2010 +0900 @@ -11,6 +11,7 @@ #include "types.h" #include "SysFunc.h" +static void send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads); CellTaskManagerImpl::~CellTaskManagerImpl() { @@ -90,10 +91,8 @@ void CellTaskManagerImpl::set_runTaskList() { - // ここ...直すかな TaskListPtr list; - - TaskPtr task; + SimpleTaskPtr task; int speid; while (HTaskPtr htask = activeTaskQueue->poll()) { @@ -128,8 +127,40 @@ } task = &list->tasks[list->length++]; - TaskPtr stask = (TaskPtr) task; - *stask = *(TaskPtr) htask; + + if (htask->command==TaskArray1) { + // compatibility + // Task with ListData is stored in the ListData + int next = (htask->r_size)/sizeof(SimpleTask) + 1; + if (list->length+next>=TASK_MAX_SIZE) { + list->length--; + TaskListPtr newList = taskListImpl->create(); + newList = TaskListInfo::append(newList, speTaskList_bg[speid]); + speTaskList_bg[speid] = newList; + list = newList; + task = &list->tasks[list->length++]; + } + Task *array = (Task*)&list->tasks[list->length]; + list->length += next; + memcpy(array, htask->rbuf, htask->r_size); + free(htask->rbuf); + htask->rbuf = 0; htask->r_size = 0; + *task = *(SimpleTask*)htask; + } else { + *task = *(SimpleTask*)htask; + } + + } +} + +void +CellTaskManagerImpl::sendTaskList() +{ + for (int i = 0; i < machineNum; i++) { + if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) { + send_taskList(i); + spe_running++; + } } } @@ -138,129 +169,81 @@ { TaskListPtr ppeTaskList = NULL; - // PPE 側で動く TaskList です - // FifoTaskManagerImpl::run と上手く合うように - // こんなことやってますよ - // - // 本来は、別 thread で動かすべきだろう... - ppeTaskList = ppeManager->get_runTaskList(); - if (!ppeTaskList) { - goto cont; + do { + // PPE side + ppeTaskList = ppeManager->get_runTaskList(); + if (ppeTaskList) + ppeManager->sendTaskList(ppeTaskList); + ppeManager->mail_check(); + // SPE side + do { + mail_check(); + // SPE に送る TaskList の準備 + set_runTaskList(); + // TaskList 待ちの SPE に TaskList を送る + sendTaskList(); + } while (ppeManager->activeTaskQueue->empty() && spe_running >0 ); + } while (ppeTaskList || spe_running >0); + if (!waitTaskQueue->empty()) { + get_scheduler()->printf("Dead lock detected\n"); } - - // SPE からの Mailbox Check は - // PPE 側の schedule から抜けて来たときに行う - // (speThreads で Blocking Mailbox read と - // セマフォとか使ってやってもいいが、今はこの方式で) - // - // すべてのspe task が finish task を待つ場合は、ppeTaskList の - // 判定だけで十分だが、そうでない場合は、spe の task が残っているか - // どうかを調べる必要がある。 - // - do { - ppeManager->schedule(ppeTaskList); - cont: - ppeTaskList = mail_check(waitTaskQueue); - } while (ppeTaskList || spe_running >0); } /** * SPE からのメールをチェックする - * - * @param [mail_list] - * PPE 側で動く Scheduler からのメールリスト - * この中で PPE 側の mail check も行う - * - * @return PPE Scheduler に対してのメール。 - * 次に実行する TaskList のアドレスや、終了コマンドを送る */ -TaskListPtr -CellTaskManagerImpl::mail_check(HTaskInfo *wait_queue) +void +CellTaskManagerImpl::mail_check() { - // PPE Scheduler からの mail check - ppeManager->mail_check(waitTaskQueue); - - do { - memaddr data; + memaddr data; - // SPE Scheduler からの mail check - for (int id = 0; id < machineNum; id++) { - while (speThreads->has_mail(id, 1, &data)) { - /** - * MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了 - * MY_SPE_NOP: 特に意味のないコマンド - * それ以外:終了したタスク(PPEにあるのでアドレス - * - * MY_SPE_NOP が 0 なので、 - * 下のように data > MY_SPE_NOP とかしています。 - * 一目でよくわからない書き方なんで、直したいところですが。。。 - */ - // 名前あとでちゃんと決めよう => MY_SPE_... とかじゃなくて - if (data == (memaddr)MY_SPE_STATUS_READY) { - //__debug_ppe("[SPE %d] finish\n", id); - flag_sendTaskList[id] = 1; - spe_running--; - } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) { - //__debug_ppe("[PPE] MALLOC COMMAND from [SPE %d]\n", id); - - /** - * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照) - * info[1] = alloc_addr; - */ - memaddr alloc_info[2]; - long alloc_size; - long command; - - speThreads->get_mail(id, 2, alloc_info); - command = (long)alloc_info[0]; - alloc_size = (long)alloc_info[1]; + // SPE Scheduler からの mail check + for (int id = 0; id < machineNum; id++) { + while (speThreads->has_mail(id, 1, &data)) { + if (data == (memaddr)MY_SPE_STATUS_READY) { + // MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了 + flag_sendTaskList[id] = 1; + spe_running--; + } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) { + // MY_SPE_COMMAND_MALLOC SPE からのmain memory request + send_alloc_reply(this, id, speThreads); + } else if (data > (memaddr)MY_SPE_NOP) { + // 終了したタスク(PPEにあるのでアドレス) + HTaskPtr task = (HTaskPtr)data; + task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); + check_task_finish(task,waitTaskQueue); + } + // MY_SPE_NOP: 特に意味のないコマンド + } + } +} - - alloc_info[1] = (memaddr)allocate(alloc_size); - /* - * allocate された領域は今の SPE buffer にリンクとして接続する - * ここでは TaskList を allocate(new) して登録してやろうか - */ - - //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id); - // 今のところ何もしてない。どうも、この allocate を free - // するのは、SPE task が返した値を見て行うらしい。それは、 - // 忘れやすいのではないか? - speThreads->add_output_tasklist(command, alloc_info[1], alloc_size); - - speThreads->send_mail(id, 2, alloc_info); - } else if (data > (memaddr)MY_SPE_NOP) { - //__debug_ppe("[PPE] recv from [SPE %d] : 0x%x\n", id, data); - HTaskPtr task = (HTaskPtr)data; - task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); - check_task_finish(task,waitTaskQueue); - } - } - } +static void +send_alloc_reply(CellTaskManagerImpl *tm, int id, SpeThreads *speThreads) +{ - // 依存関係を満たしたタスクをアクティブに - wakeup_waitTask(); - - // SPE に送る TaskList の準備 - set_runTaskList(); + /** + * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照) + * info[1] = alloc_addr; + */ + memaddr alloc_info[2]; + long alloc_size; + long command; + + speThreads->get_mail(id, 2, alloc_info); + command = (long)alloc_info[0]; + alloc_size = (long)alloc_info[1]; - // TaskList 待ちの SPE に TaskList を送る - for (int i = 0; i < machineNum; i++) { - if (flag_sendTaskList[i] == 1 && speTaskList_bg[i]->length >= 1 ) { - send_taskList(i); - spe_running++; - } - } + + alloc_info[1] = (memaddr)tm->allocate(alloc_size); + //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id); + // 今のところ何もしてない。どうも、この allocate を free + // するのは、SPE task が返した値を見て行うらしい。それは、 + // 忘れやすいのではないか? + speThreads->add_output_tasklist(command, alloc_info[1], alloc_size); - // 現在の FifoTaskManager の仕様では - // ・PPE で実行するタスクが無くなれば終了する - // であり、この場合もし SPE にタスクが残っていても - // メインループから抜けてプログラム終了となってしまうので - // ここでストップかけてます。 - } while (ppeManager->activeTaskQueue->empty() && !waitTaskQueue->empty()); - - return ppeManager->get_runTaskList(); + speThreads->send_mail(id, 2, alloc_info); } /**
--- a/TaskManager/Cell/CellTaskManagerImpl.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.h Fri Mar 05 13:12:31 2010 +0900 @@ -24,8 +24,9 @@ // system void init(); void run(); - TaskListPtr mail_check(HTaskInfo *); + void mail_check(); void set_runTaskList(); + void sendTaskList(); void append_activeTask(HTaskPtr); void show_profile() ; void start_profile() ;
--- a/TaskManager/Cell/SpeThreads.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/SpeThreads.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,6 +1,7 @@ #include <stdlib.h> #include "types.h" #include "SpeThreads.h" +#include "Scheduler.h" SpeThreads::SpeThreads(int num) : spe_num(num) {} @@ -44,8 +45,7 @@ | (stop_info.result.spe_signal_code & 0xff); switch(stop_info.stop_reason) { - case SPE_EXIT: - //printf("SPE_EXIT stop_info.result.stop_exit_code=0x%x\n", stop_info.result.spe_exit_code); + case SPE_EXIT: break; case SPE_STOP_AND_SIGNAL: printf("[SPE %d] SPE_STOP_AND_SIGNAL stop_info.result.stop_signal_code=%d\n", arg_t->speid, stop_info.result.spe_signal_code);
--- a/TaskManager/Cell/SpeThreads.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/SpeThreads.h Fri Mar 05 13:12:31 2010 +0900 @@ -11,6 +11,7 @@ spe_context_ptr_t ctx; } thread_arg_t; + class SpeThreads { public: /* constructor */
--- a/TaskManager/Cell/spe/CellDmaManager.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include "CellDmaManager.h" - +#include "Scheduler.h" /** @@ -120,13 +120,13 @@ void CellDmaManager::null_end_dmawait_profile(unsigned long long *counter) {} void -CellDmaManager::show_dma_wait(int cpu) +CellDmaManager::show_dma_wait(Scheduler *s, int cpu) { double r = ((double)global_busy_time)/((double)( global_busy_time+global_wait_time+global_mail_time ))*100.0; - printf("spu%d: busy_time = %lld" + s->printf("spu%d: busy_time = %lld" " wait_time = %lld" " mail_time = %lld" " busy_ratio = %g%%\n", cpu, global_busy_time,
--- a/TaskManager/Cell/spe/CellDmaManager.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.h Fri Mar 05 13:12:31 2010 +0900 @@ -9,6 +9,8 @@ #define SPU_PROFILE 1 +class Scheduler; + class CellDmaManager : public DmaManager { public: BASE_NEW_DELETE(CellDmaManager); @@ -35,7 +37,7 @@ void stop_profile(); - void show_dma_wait(int cpu); + void show_dma_wait(Scheduler *s, int cpu); void mail_write(memaddr data); memaddr mail_read();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/TaskArray.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,29 @@ +#include "Finish.h" +#include "SysFunc.h" +#include "Scheduler.h" +#include "Task.h" + + +SchedDefineTask(TaskArray); + +static Task * +next(Task *t) +{ + char *p = (char*)t; + p += t->size(); + return (Task*)p; +} + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + Task *task = (Task *)rbuf; + Task *last = ((char*)rbuf)+ s->read_size(); + + while( task < last) { + task->print(s); + task = next(task); + } + + return 0; +}
--- a/TaskManager/Cell/spe/main.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Cell/spe/main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -4,6 +4,8 @@ #include "spu_mfcio.h" #include "error.h" #include "SysFunc.h" +#include "SchedNop.h" + extern unsigned char _end[]; @@ -36,7 +38,7 @@ tm->set_scheduler(manager); - manager->run(); + manager->run(new SchedNop()); manager->finish();
--- a/TaskManager/ChangeLog Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/ChangeLog Fri Mar 05 13:12:31 2010 +0900 @@ -1,3 +1,118 @@ +2009-12-19 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + そうか、TaskList->next は、SPE 側で自分で呼び出しているわけね。 + と言うことは、schdule(list) が終るまでは、mail check に戻って + こない... それだと、ちょっとまずいね。 + + となると、TaskList のfree(clear)のtimingは? schdule から抜けた + 時と言うことになるわけだけど。 + + waitQueue は、実は不要。しかし、終了条件、dead lock detection には + 必要らしい。 + +2009-12-16 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + CellTaskManagerのTaskList_bg は変だよ。TaskList 自体が + queue なんだから、トップ二つを特別扱いしているだけでしょう。 + + TaskList をread()しているのと同時にnext()されてしまうので、 + next()の中で、TaskList の中身に触るのは良くない。SchedTask + は微妙に大丈夫らしい。TLのdma waitは、write になっていた。 + + TaskArray/TaskArray1 は、TAの中身をnext()で判断しているので、 + これはただしくない。TaskListLoad を間にはさむ手もあるが... + + write T3 T2 T1 TL TA0 ! TL の dma wait + exec T2 T1 TL! TA0 TA1 + read T1 TL* TA TA1 TA2 * TL の dma start + next T1 TL% TA TA1 TA2 % TAの作成判断 + + TaskListLoad をはさむ、安全だけど遅い方法 + + write T3 T2 T1 TLL TL + exec T2 T1 TLL! TL TA0 + read T1 TLL*TL TA0 TA1 + next T1 TLL TL% TA0 TA1 + + なんだけど、pointer の下位ビットで送ると、前者で実行できる。 + next で、TaskList のloadを始めてしまうという手もあるな... + + write T3 T2 T1 TL TA0 ! TL の dma wait + exec T2 T1 TL TA0 TA1 + read T1 TL! TA TA1 TA2 * TL の dma start + next T1* TL% TA TA1 TA2 + + こっっちかな... + +2009-12-15 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + SimpleTask の実装が出来たので、TaskArray からは、 + PPU側に詳細な情報を返せる。と言うことは、SPU側から + PPU Task を投入出来る。実装すればだけど。 + + Task 側から書き出し情報を設定するAPIが必要。 + マニュアルも書くか。 + + Down cast をすべてなくしたい。Sched*.cc からは取れました。 + + まだ、いらないものが結構あるらしい... + +2009-12-14 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + ようやっと動きました。SIMPLE_TASK でないのとの互換性 + を維持するべきか? 頑張れば出来ると思うけど... + + 方法は二つ。TaskList に無理矢理 Task を詰め込むか、 + 今までのHTaskを、TaskArray に読み変えるか。前者は変更が + 多い。後者は、wait_for が微妙。 + + 前者で実装しました。そのうち落すかも。エラーチェックと、 + エラー処理関数が必要。コメントを書かないと。 + +2009-12-12 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + SchedTask::next で、TaskArray を認識して、そこで、 + SchedTaskArrayLoad を作る。次のSchedTask を用意して、 + SchedTaskArrayLoad にsavedSchedTaskとして引き渡す。 + + SchedTaskArrayLoad::read は、TaskArray をload する。 + SchedTaskArrayLoad::next は、SchedTaskArray を返す。 + この時に、saveedSchedTask を引き継ぐ。 + write/exec は何もしない。(これで、pipe line を空ける) + + SchedTaskArray::read は、List DMA をload する。 + SchedTaskArrayLoad::next は、TaskArray 上のTaskを返す。 + exec/write は、List DMA 対応で動作する。 + もうない場合には、SchedTaskArrayLoad から伝えられた + saveされた SchedTask を返す。mail も送る。 + +2009-12-7 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + pipeline stageは、loop local だから、instance 変数である必 + 要はない。途中で中断することはない。これを一時変数にして、 + 再帰的にpipeline stage を呼び出せば良いらしい。 + + pipeline stage のtask1に引数で new SchedTaskList を渡すと、 + run()でtask1 = new SchedNop() するよりループ二回ぐらい高速 + になるらしい。が、おそらく、ほとんど影響はない。 + + pipelineで既に走っている次のTaskのreadを停める必要があるら + しい。前もってNopを入れて置く方法もあるが、TaskListの境界が + 問題になる。停めないとパイプラインバッファを新たに取る必要 + があり連鎖的にはまる。 + + writeしている奴もいるしな。スケジューラは一段しかネストしな + いから新しくバッファ取るか? いや、やっぱり許されないか。い + や、取るか。うーん、悩ましい。どうせ、Task list は確保しな + いとだめだから… 再帰しないで、もとのスケジューラで動かした + い + + そのためには、既に Pipeline に入っているTaskが邪魔か。2つTask + を投入して、間に TaskList read が入ってもなんとかなるように + 工夫するのが良いっぽい + + なんか、Renew Task の道を歩んでいる気もするが... + 2009-12-6 Shinji KONO <kono@ie.u-ryukyu.ac.jp> やっぱり、Graphical なprofileが欲しいかな。どのDMA/Taskに時間がかかっている @@ -15,6 +130,18 @@ ぐらい? get_segment 使うべきか。連続領域に使える get_segement があると 良いわけね。write とも言うが。 + sort で、memcpy しているのは変。read/write buffer をflipしてやると + 良い。両方とも握っているんだから問題ない。ただし、read/write buffer + の大きさは等しい必要がある。SchedTask->flip_read_write_buffer(); か? + sort ちゃんとは動いているんだよ。 + + word_count_test の稼働率が10%なのはひどい。word_count の方だと偏りが + あって、一部が50%になるが10%ぐらい。DMA待ちではなくて、メール待ちに + なっている。PPUネックになっているっぽい。 + + TaskArray は、SchedTask を拡張して処理する。next で、次のTaskを + 用意する感じか。inData/outData の処理も。 + 2009-12-5 Shinji KONO <kono@ie.u-ryukyu.ac.jp> なんかなぁ。一つの機能を付け加えようとすると、 @@ -112,6 +239,7 @@ 2009-11-14 Shinji KONO <kono@ie.u-ryukyu.ac.jp> Scheduler / TaskManger / TaskManagerImpl の区別が不明 + HTask は、TaskManagerImpl を持ってる。 Scheduler は SchedTask から直接見えないはずだが、SchedTask は、 Scheduler は知っているが、TaskManager は知らない。これがかなりの
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Fri Mar 05 13:12:31 2010 +0900 @@ -6,6 +6,10 @@ #include "SchedTask.h" #include "types.h" #include "error.h" +#include "SchedNop.h" +#include "SysFunc.h" + +// static void send_alloc_reply(FifoTaskManagerImpl *tm, int id, MainScheduler *s); FifoTaskManagerImpl::~FifoTaskManagerImpl() { @@ -25,14 +29,16 @@ void FifoTaskManagerImpl::init() { + // TaskManager から呼ばれるので、かなりの部分は初期化されている。 + mainScheduler = new MainScheduler(); mainScheduler->init(this); mainScheduler->id = 0; set_scheduler(mainScheduler); taskListImpl = new TaskListInfo; - taskQueueImpl = new TaskQueueInfo; - htaskImpl = new HTaskInfo(); + // taskQueueImpl = new TaskQueueInfo; + // htaskImpl = new HTaskInfo(); mainTaskList = taskListImpl->create(); @@ -58,7 +64,7 @@ taskListImpl = tm-> taskListImpl ; taskQueueImpl = tm-> taskQueueImpl ; htaskImpl = tm-> htaskImpl ; - waitTaskQueue = NULL; // mail_check で外から設定される + waitTaskQueue = tm->waitTaskQueue; mainTaskList = taskListImpl->create(); @@ -67,10 +73,8 @@ } -void FifoTaskManagerImpl::show_profile() { - printf("HEHEHEHEH\n"); -} -void FifoTaskManagerImpl::start_profile() {} +// void FifoTaskManagerImpl::show_profile() {} +// void FifoTaskManagerImpl::start_profile() {} /** * スケジューラに渡す TaskList を取得する。 @@ -84,11 +88,7 @@ FifoTaskManagerImpl::get_runTaskList() { TaskListPtr list, list_top; -#ifdef SIMPLE_TASK SimpleTaskPtr task; // Task (SPE に送る Task) -#else - TaskPtr task; // Task (SPE に送る Task) -#endif if (activeTaskQueue->empty()) { return NULL; @@ -104,11 +104,29 @@ // printf("active task queue length = %d\n",activeTaskQueue->length()); while (HTaskPtr htask = activeTaskQueue->poll()) { task = &list->tasks[list->length++]; -#ifdef SIMPLE_TASK - *task = *(SimpleTask*)htask; -#else - memcpy(task, (Task*)htask, sizeof(Task)); -#endif + + if (htask->command==TaskArray1) { + // compatibility + int next = ((htask->r_size)/sizeof(SimpleTask))+1; + if (list->length+next>=TASK_MAX_SIZE) { + list->length--; + TaskListPtr newList = taskListImpl->create(); + list_top = TaskListInfo::append(list_top, 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; + *task = *(SimpleTask*)htask; + } else { + *task = *(SimpleTask*)htask; + } if (list->length >= TASK_MAX_SIZE) { TaskListPtr newList = taskListImpl->create(); list_top = TaskListInfo::append(list_top, newList); @@ -129,19 +147,15 @@ { TaskListPtr list; - list = get_runTaskList(); - - do { + while((list = get_runTaskList())) { // list を実行する - schedule(list); - + sendTaskList(list); // ppe scheduler からの mail を調べる - mail_check(waitTaskQueue); - - // 依存関係を満たしたものは実行可能キューへ - wakeup_waitTask(); - list = get_runTaskList(); - } while (list); + mail_check(); + } + if (!waitTaskQueue->empty()) { + get_scheduler()->printf("Dead lock detected\n"); + } } /** @@ -151,19 +165,18 @@ * [Tasklist] -> [番兵] -> scheduler->run を抜ける */ void -FifoTaskManagerImpl::schedule(TaskListPtr list) +FifoTaskManagerImpl::sendTaskList(TaskListPtr list) { - if (list) { - // TaskList のアドレスを送る - mainScheduler->mail_write_from_host((memaddr)list); + // TaskList のアドレスを送る + mainScheduler->mail_write_from_host((memaddr)list); - // EXIT_COMMAND (番兵的な意味で) - // これを読むと、mainScheduler->run() から抜けて来る。 - mainScheduler->mail_write_from_host((memaddr)MY_SPE_COMMAND_EXIT); + // EXIT_COMMAND (番兵的な意味で) + // これを読むと、mainScheduler->run() から抜けて来る。 + mainScheduler->mail_write_from_host((memaddr)MY_SPE_COMMAND_EXIT); - // scheduler は受け取ったメールを元に実行する - mainScheduler->run(); - } + // scheduler は受け取ったメールを元に実行する + mainScheduler->run(new SchedNop()); + // すべてのlistを実行するまで戻らない } /** @@ -177,7 +190,7 @@ * NULL なら全てのタスクが実行終了したということ */ void -FifoTaskManagerImpl::mail_check(HTaskInfo *wait_queue) +FifoTaskManagerImpl::mail_check() { while (mainScheduler->has_mail_from_host()) { memaddr data = mainScheduler->mail_read_from_host(); @@ -186,17 +199,46 @@ __debug_ppe("mail_check(): Task List finish\n"); } else if (data == (memaddr)MY_SPE_COMMAND_EXIT) { __debug_ppe("mail_check(): Task List finish COMMAND\n"); + } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) { + // MY_SPE_COMMAND_MALLOC PPE からのmain memory request + // 本来は呼ばれないはず... + get_scheduler()->printf("error: MY_SPE_COMMAND_MALLOC from PPE\n"); + // send_alloc_reply(this, 0, mainScheduler); } else if (data != (memaddr)MY_SPE_NOP) { __debug_ppe("mail_check(): recv from 0x%x\n", data); // post_func を先に実行しないと、systask_finish が active_queue // 移されてから、wait_for されるという事態が起きることがある。 HTaskPtr task = (HTaskPtr)data; task->post_func(schedTaskManager, task->post_arg1, task->post_arg2); - check_task_finish(task, wait_queue); + check_task_finish(task, waitTaskQueue); } } } +#if 0 +static void +send_alloc_reply(FifoTaskManagerImpl *tm, int id, MainScheduler *s) +{ + /** + * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照) + * info[1] = alloc_addr; + */ + memaddr alloc_info[2]; + long alloc_size; + long command; + + alloc_info[0] = s->mail_read_from_host(); + alloc_info[1] = s->mail_read_from_host(); + command = (long)alloc_info[0]; + alloc_size = (long)alloc_info[1]; + + alloc_info[1] = (memaddr)tm->allocate(alloc_size); + + s->mail_write_from_host(alloc_info[0]); + s->mail_write_from_host(alloc_info[1]); +} +#endif + /** * # # # # # # # #
--- a/TaskManager/Fifo/FifoTaskManagerImpl.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.h Fri Mar 05 13:12:31 2010 +0900 @@ -23,15 +23,14 @@ void init(void); void init(MainScheduler*, TaskManagerImpl*); void run(void); - void show_profile() ; - void start_profile() ; + void show_profile() {}; + void start_profile() {}; void mail_check(); - void mail_check(HTaskInfo *waitQueue); TaskListPtr get_runTaskList(void); - void schedule(TaskListPtr); + void sendTaskList(TaskListPtr); // call by user
--- a/TaskManager/Makefile Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Makefile Fri Mar 05 13:12:31 2010 +0900 @@ -9,6 +9,9 @@ fifo: FORCE @$(MAKE) -f Makefile.fifo +depend: FORCE + @$(MAKE) -f Makefile.fifo depend + cell: FORCE @$(MAKE) -f Makefile.cell @@ -42,3 +45,5 @@ tags: $(TAGS) $(TAGSOPTION) + +-include ./Makefile.dep
--- a/TaskManager/Makefile.cell Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Makefile.cell Fri Mar 05 13:12:31 2010 +0900 @@ -11,6 +11,8 @@ $(CELL_SPE_DIR)/SchedTaskList.cc \ $(CELL_SPE_DIR)/SchedMail.cc \ $(CELL_SPE_DIR)/SchedTask.cc \ + $(CELL_SPE_DIR)/SchedTaskArray.cc \ + $(CELL_SPE_DIR)/SchedTaskArrayLoad.cc \ $(CELL_SPE_DIR)/Scheduler.cc\ $(CELL_SPE_DIR)/SchedNop.cc \ $(CELL_SPE_DIR)/MemList.cc \
--- a/TaskManager/Makefile.def Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -29,14 +29,12 @@ ABIBIT = 32 -# SIMPLE_TASK=-DSIMPLE_TASK -SIMPLE_TASK= -OPT = -O9 -# OPT = -g +OPT = #-O9 +OPT = -g CC = g++ -CFLAGS = $(SIMPLE_TASK) -Wall `sdl-config --cflags` -m$(ABIBIT) $(OPT) +CFLAGS = -Wall `sdl-config --cflags` -m$(ABIBIT) $(OPT) LIBS = -m$(ABIBIT) INCLUDE = -I../include/TaskManager
--- a/TaskManager/Makefile.fifo Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/Makefile.fifo Fri Mar 05 13:12:31 2010 +0900 @@ -1,19 +1,25 @@ include ./Makefile.def - TARGET = libFifoManager.a .SUFFIXES: .cc .o -EXTRA_CFLAGS = -D__CERIUM_FIFO__ +EXTRA_CFLAGS = -D__CERIUM_FIFO__ .cc.o: $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ + all: default default: $(TARGET) ALL_OBJS = $(KERN_MAIN_OBJS) $(KERN_PPE_OBJS) $(KERN_SCHED_OBJS) $(KERN_SYSTASK_OBJS) $(IMPL_FIFO_OBJS) $(KERN_MEM_OBJS) +Makefile.dep: + make -f Makefile.fifo depend + +depend: + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) $(ALL_OBJS:.o=.cc) -MM > Makefile.dep + $(TARGET): $(ALL_OBJS) ar crus $@ $(ALL_OBJS) @@ -21,3 +27,4 @@ rm -f $(TARGET) fifoclean: +
--- a/TaskManager/include/error.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/include/error.h Fri Mar 05 13:12:31 2010 +0900 @@ -3,8 +3,8 @@ #ifdef DEBUG # include <stdio.h> -# define __debug(...) do { \ - fprintf(stderr, __VA_ARGS__); \ +# define __debugs(s, ...) do { \ + s->printf(__VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug(...) @@ -12,8 +12,8 @@ #ifdef DEBUG # include <stdio.h> -# define __debug_ppe(...) do { \ - printf("[PPE] "); printf(__VA_ARGS__); \ +# define __debugs_ppe(s, ...) do { \ + s->printf("[PPE] ", __VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug_ppe(...) @@ -21,8 +21,8 @@ #ifdef DEBUG # include <stdio.h> -# define __debug_spe(...) do { \ - printf("[SPE] "); printf(__VA_ARGS__); \ +# define __debugs_spe(s, ...) do { \ + s->printf("[SPE] ", __VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug_spe(...)
--- a/TaskManager/kernel/main.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -40,12 +40,6 @@ machineNum = atoi(argv[++i]); } else if (strcmp(argv[i], "-p") == 0) { profile = 1; - } else if (strcmp(argv[i], "-help") == 0) { - if (usr_help_str) { - printf("%s", usr_help_str); - } - printf("%s", help_str); - return EXIT_SUCCESS; } } @@ -54,6 +48,15 @@ manager->set_TMend(defaultTMend); + for (int i = 1; argv[i]; ++i) { + if (strcmp(argv[i], "-help") == 0) { + if (usr_help_str) { + manager->get_scheduler()->printf("%s", usr_help_str); + } + manager->get_scheduler()->printf("%s", help_str); + return EXIT_SUCCESS; + } + } if (profile) manager->start_profile(); if (TMmain(manager, argc, argv) < 0) {
--- a/TaskManager/kernel/ppe/DmaBuffer.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/DmaBuffer.cc Fri Mar 05 13:12:31 2010 +0900 @@ -9,7 +9,7 @@ DmaBuffer::DmaBuffer(int size) { -#ifdef NO_POSIX_MEMALIGN +#ifndef HAS_POSIX_MEMALIGN buffer[0] = malloc(size); buffer[1] = malloc(size); #else
--- a/TaskManager/kernel/ppe/HTask.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,6 +1,7 @@ #include "HTask.h" #include "ListData.h" #include "TaskManagerImpl.h" +#include "strings.h" /*! @@ -49,4 +50,45 @@ this->post_arg2 = arg2; } + +Task * +HTask::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData) +{ + r_size = Task::calc_size(num_param, num_inData, num_outData)*num_task; + rbuf = (memaddr) mimpl->allocate(r_size); + bzero(rbuf,r_size); + Task *task = (Task*)rbuf; + task->init(id, num_param,num_inData,num_outData); +// task->print(); + return task; // first task +} + +Task * +HTask::next_task_array(int id, Task *t) +{ + Task *first = (Task*)rbuf; + if (t==0) { +// first->print(); + return first; + } + + 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; +} + +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); + } +} + + + /* end */
--- a/TaskManager/kernel/ppe/HTask.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/HTask.h Fri Mar 05 13:12:31 2010 +0900 @@ -21,11 +21,10 @@ 特定の Task を待ち合わせる事が可能。 Task の入出力は dma などで copy される。 */ -#ifdef SIPMLE_TASK + +#include "SimpleTask.h" + class HTask : public SimpleTask { -#else -class HTask : public Task { -#endif public: BASE_NEW_DELETE(HTask); @@ -41,10 +40,71 @@ HTask *next; HTask *prev; - void spawn(void); + void spawn(); void wait_for(HTask *); void set_cpu(CPU_TYPE type); void set_post(PostFunction func, void *read, void *write); + Task *create_task_array(int task_id, int num_task, int num_param, int num_inData, int num_outData); + Task *next_task_array(int task_id, Task *t); + void spawn_task_array(Task *t); + + + private: + + int param_index; + int in_index; + int out_index; + +// compatibility + public: // functions + void add_inData_t(memaddr addr, int size) { + Task *t = (Task*)rbuf; + t->set_inData_t(in_index++, addr,size); + } + void add_outData_t(memaddr addr, int size) { + Task *t = (Task*)rbuf; + t->set_outData_t(out_index++, addr,size); + } + void set_inData_t(int index, memaddr addr, int size) { + Task *t = (Task*)rbuf; + t->set_inData_t(index, addr,size); + } + void set_outData_t(int index, memaddr addr, int size) { + Task *t = (Task*)rbuf; + t->set_inData_t(index, addr,size); + } + void add_param_t(memaddr param) { + Task *t = (Task*)rbuf; + t->set_param_t(param_index++, param); + } + void set_param_t(int index, memaddr param) { + Task *t = (Task*)rbuf; + t->set_param_t(index, param); + } + + void init(int cmd) { + next = prev = NULL; + waiter = NULL; + + command = cmd; + param_index = 0; + in_index = 0; + out_index = 0; + self = (memaddr) this; + + post_func = NULL; + mimpl = NULL; + cpu_type = CPU_PPE; + } +#define add_param(param) add_param_t((memaddr)(param)) +#define set_param(index,param) set_param_t(index, (memaddr) (param)) + +#define add_inData(addr, size) \ + add_inData_t((memaddr)(addr), (size)); +#define add_outData(addr, size) \ + add_outData_t((memaddr)(addr), (size)); + + }; typedef HTask* HTaskPtr;
--- a/TaskManager/kernel/ppe/HTaskInfo.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/HTaskInfo.cc Fri Mar 05 13:12:31 2010 +0900 @@ -60,39 +60,17 @@ taskQueuePool.extend_pool(64); q = taskQueuePool.poll(); } - q->next = q->prev = NULL; - q->waiter = NULL; - - q->command = cmd; -#ifndef SIMPLE_TASK - q->inData.clear(); - q->outData.clear(); - q->param_size = 0; -#endif - q->self = (memaddr) q; - - q->post_func = NULL; - q->mimpl = NULL; - q->cpu_type = CPU_PPE; - - // q->wait_me.clear(); - // q->wait_i.clear(); - + q->init(cmd); return q; } HTaskPtr HTaskInfo::create(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) { -#ifdef SIMPLE_TASK HTaskPtr task = create(cmd); task->set_input(rbuf, rs); task->set_output(wbuf, ws); return task; -#else - fprintf(stderr, "TaskManager is not SIMPLE_TASK mode\n"); - return 0; -#endif }
--- a/TaskManager/kernel/ppe/MailManager.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/MailManager.cc Fri Mar 05 13:12:31 2010 +0900 @@ -13,6 +13,7 @@ } MailManager::MailManager(unsigned int qsize) { + read = write = 0; calc_mask(qsize); queue = New(memaddr,size); }
--- a/TaskManager/kernel/ppe/SimpleTask.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/SimpleTask.h Fri Mar 05 13:12:31 2010 +0900 @@ -13,18 +13,15 @@ int command; // 4 byte memaddr self; // 4 byte (or 8byte on 64bit mode) -#ifdef SIMPLE_TASK memaddr rbuf; memaddr wbuf; int r_size; int w_size; -#endif public: // functions SimpleTask() {}; -#ifdef SIMPLE_TASK SimpleTask(int r, memaddr read, int w, memaddr write) { r_size = r; rbuf = read; w_size = w; wbuf = write; @@ -32,7 +29,6 @@ void set_input(memaddr i,int size) { r_size = size; rbuf= i; } void set_output(memaddr o,int size) { w_size = size; wbuf= o; } -#endif };
--- a/TaskManager/kernel/ppe/Task.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/Task.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,96 +1,19 @@ #include "Task.h" +#include "Scheduler.h" -/** - * タスクの入力データを追加する - * - * @param [addr] add input data - * @param [size] size of data at [addr] - * - * @return if ([ret] == 0) ? success : failuer; - */ -int -Task::add_inData_t(memaddr addr, int size) +void +Task::print(Scheduler *s) { -#ifdef SIMPLE_TASK - return 0; -#else - return add_data(inData, addr, size); -#endif -} + s->printf("task id %d task size = %d param size %d " + "inData size %d " + "outData size %d\n", command, size(), param_count, inData_count, outData_count + ); + for(int i=0; i< param_count && i<5; i++) { + // large param_count shall be a bug + s->printf("param %d = 0x%ld\n", i, (long)param(i)); + } -/** - * タスクの出力先を追加する - * - * @param[in] addr Address at out data - * @param[in] size Size of data transfer - * - * @return if ([ret] == 0) ? success : failuer; - */ -int -Task::add_outData_t(memaddr addr, int size) -{ -#ifdef SIMPLE_TASK - return 0; -#else - return add_data(outData, addr, size); -#endif } -/** - * エラーの時に -1 を返す、ってことするよりは - * perror みたいにしたほうがわかりやすいかな。 - * - * 現在は MAX_PARAMS 個まで。 - * 本当は、MAX_PARAMS個以上にすると task->param[] には アドレスが入り - * そのアドレスは メインメモリでアロケートされた int の集合。 - */ -// こちらのAPIは、受け側と出力側での対応を良く見れない。廃止の方向。 -int -Task::add_param0(memaddr _param) -{ -#ifndef SIMPLE_TASK - if (param_size >= MAX_PARAMS) return -1; - - this->param[param_size++] = _param; -#endif - return 0; -} - -int -Task::set_param0(int index, memaddr _param) -{ -#ifndef SIMPLE_TASK - if (index >= MAX_PARAMS) return -1; - - this->param[index] = _param; -#endif - return 0; -} - -/* - * エラーの時に -1 を返す、ってことするよりは - * perror みたいにしたほうがわかりやすいかな。 - */ -int -Task::add_data(ListData& list, memaddr addr, int size) -{ -#ifndef SIMPLE_TASK - if (list.length >= MAX_LIST_DMA_SIZE) return -1; - - list.bound[list.length] = list.size; - - // size でも制限かけるべき? - list.size += size; - - ListElementPtr elm = &list.element[list.length++]; -#ifdef __CERIUM_CELL__ - elm->addr = (uint32)(unsigned long)addr; -#else - elm->addr = addr; -#endif - elm->size = size; -#endif - - return 0; -} +/* end */
--- a/TaskManager/kernel/ppe/Task.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/Task.h Fri Mar 05 13:12:31 2010 +0900 @@ -6,33 +6,120 @@ #include "ListData.h" #include "SimpleTask.h" -#define MAX_PARAMS 8 -class Task : public SimpleTask { -public: // variables +class SchedTask; +class Scheduler; - BASE_NEW_DELETE(Task); -#ifndef SIMPLE_TASK - int param_size; // 4 byte - memaddr param[MAX_PARAMS]; // 4*MAX_PARAMS byte - ListData inData __attribute__ ((aligned (DEFAULT_ALIGNMENT))); - ListData outData __attribute__ ((aligned (DEFAULT_ALIGNMENT))); -#endif +class Task { +public: // variables + int task_size; + int command; + int param_count; + int inData_count; + int outData_count; + int inData_offset; + int outData_offset; + void *data[] __attribute__ ((aligned (DEFAULT_ALIGNMENT))); public: // functions - int add_inData_t(memaddr addr, int size); // unsigned int ではなく 64bit - int add_outData_t(memaddr addr, int size); // unsigned int ではなく 64bit - int add_data(ListData &list, memaddr addr, int size); - int add_param0(memaddr param); // obsolete. do not use. - int set_param0(int index, memaddr param); + + void print(Scheduler *s); + + memaddr *param(int index) { + memaddr p = (memaddr)data + sizeof(memaddr)*index; + return (memaddr *)p; + } + + ListElement *inData(int index) { + memaddr p = (memaddr)data + inData_offset; + p += sizeof(ListElement)*index; + return (ListElement*)p; + } + + ListElement *outData(int index) { + memaddr p = (memaddr)data + outData_offset; + p += sizeof(ListElement)* index; + return (ListElement*)p; + } + + static int calc_size(int params, int ins, int outs) { + int size = round_up16(sizeof(Task)) + + round_up16(sizeof(memaddr)*params) + + round_up16(sizeof(ListElement)*ins) + + round_up16(sizeof(ListElement)*outs); + return size; + } + + void init(int task_id, int params, int ins, int outs) { + set_task_id(task_id); + param_count = params; + inData_count = ins; + outData_count = outs; + inData_offset = round_up16(sizeof(memaddr)*params); + outData_offset = round_up16(inData_offset+sizeof(ListElement)*ins); + task_size = round_up16(sizeof(Task)+outData_offset+sizeof(ListElement)*outs); + } + + int size() { + return task_size; + } -#define add_param(param) add_param0((memaddr)(param)) -#define set_param(index,param) set_param0(index, (memaddr) (param)) + int inData_total_size() { + int size = 0; + ListElement *in= inData(0); + for(int i=0; i< inData_count; i++) { + size += in[i].size; + } + return size; + } + int outData_total_size() { + int size = 0; + ListElement *out= outData(0); + for(int i=0; i< outData_count; i++) { + size += out[i].size; + } + return size; + } + + void set_inData_t( int index, memaddr addr, int size) { + ListElement *list = inData(index); +#ifdef __CERIUM_CELL__ + list->addr = (uint32)addr; +#else + list->addr = addr; +#endif + list->size = size; + } -#define add_inData(addr, size) \ - add_inData_t((memaddr)(addr), (size)); -#define add_outData(addr, size) \ - add_outData_t((memaddr)(addr), (size)); + void set_outData_t(int index, memaddr addr, int size) { + ListElement *list = outData(index); +#ifdef __CERIUM_CELL__ + list->addr = (uint32)addr; +#else + list->addr = addr; +#endif + list->size = size; + } + void set_task_id(int id) { command = id; } + void set_param_t(int index, memaddr param) { + memaddr *p = (memaddr*)this->param(index); + *p = param; + } + + Task * next() + { + char *p = (char*)this; + p += size(); + return (Task*)p; + } + + +#define set_param(index,param) set_param_t(index, (memaddr) (param)) + +#define set_inData(index, addr, size) \ + set_inData_t(index, (memaddr)(addr), (size)); +#define set_outData(index, addr, size) \ + set_outData_t(index, (memaddr)(addr), (size)); }; typedef Task* TaskPtr;
--- a/TaskManager/kernel/ppe/TaskList.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskList.h Fri Mar 05 13:12:31 2010 +0900 @@ -5,19 +5,15 @@ #include "Task.h" -#define TASK_MAX_SIZE 16 +#define TASK_MAX_SIZE 32 -class TaskList { // 528byte +class TaskList { // 784 byte public: BASE_NEW_DELETE(TaskList); int length; // 4 byte TaskList *next; // 4 byte -#ifdef SIMPLE_TASK - SimpleTask tasks[TASK_MAX_SIZE]; // 512 -#else - Task tasks[TASK_MAX_SIZE]; // 512 -#endif + SimpleTask tasks[TASK_MAX_SIZE]; // 24*TASK_MAX_SIZE TaskList *output; // 4 byte int a[1]; // padding
--- a/TaskManager/kernel/ppe/TaskManager.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,5 +1,8 @@ #include "TaskManager.h" #include "Scheduler.h" +#include "HTask.h" +#include "Task.h" +#include "SysFunc.h" TaskManager::TaskManager(int num) : machineNum(num) { @@ -59,6 +62,12 @@ return m_impl->create_task(cmd,r,rs,w,ws); } +HTaskPtr +TaskManager::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData) { + HTaskPtr ta = create_task(TaskArray,0,0,0,0); + ta->create_task_array(id, num_task, num_param, num_inData, num_outData) ; + return ta; +} /** * TaskManaer 終了時に実行される関数の設定
--- a/TaskManager/kernel/ppe/TaskManager.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskManager.h Fri Mar 05 13:12:31 2010 +0900 @@ -36,11 +36,12 @@ void init(); void finish(); + HTask *create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData); + + private: int machineNum; }; #endif -//extern TaskManager *manager; -
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Fri Mar 05 13:12:31 2010 +0900 @@ -30,13 +30,8 @@ TaskManagerImpl::systask_init() { systask_register(); -#ifdef SIMPLE_TASK systask_start = create_task(StartTask,0,0,0,0); systask_finish = create_task(FinishTask,0,0,0,0); -#else - systask_start = create_task(StartTask); - systask_finish = create_task(FinishTask); -#endif systask_start->spawn(); @@ -64,9 +59,13 @@ { HTaskPtr new_task; - new_task = htaskImpl->create(cmd); + // for compatibility + new_task = htaskImpl->create(TaskArray1); new_task->post_func = noaction; new_task->mimpl = this; + new_task->create_task_array(cmd,1,8,8,8); + // rbuf, r_size were set + new_task->command = TaskArray1; return new_task; } @@ -168,15 +167,6 @@ waitTaskQueue ->addLast(q); } -/** - * waitQueue の中で依存関係を満たしたタスクは - * activeQueue へ移す - */ -void -TaskManagerImpl::wakeup_waitTask() -{ - // done in check_task_finish -} /* end */
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Fri Mar 05 13:12:31 2010 +0900 @@ -6,7 +6,8 @@ #include "TaskListInfo.h" #include "TaskQueueInfo.h" #include "HTaskInfo.h" -class Scheduler; +#include "Scheduler.h" +//class Scheduler; class MemList; @@ -40,7 +41,6 @@ virtual void append_waitTask(HTaskPtr); void check_task_finish(HTaskPtr task, HTaskInfo *wait_queue); - void wakeup_waitTask(); void systask_init(); @@ -60,7 +60,8 @@ #else posix_memalign(&buff, alignment, size); #endif - if (buff==0) fprintf(stderr,"Can't allocate memory\n"); + if (buff==0) + get_scheduler()->printf("Can't allocate memory\n"); return buff; } @@ -73,7 +74,8 @@ #else posix_memalign(&buff, DEFAULT_ALIGNMENT, size); #endif - if (buff==0) fprintf(stderr,"Can't allocate memory\n"); + if (buff==0) + get_scheduler()->printf("Can't allocate memory\n"); return buff; }
--- a/TaskManager/kernel/schedule/ListData.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/ListData.h Fri Mar 05 13:12:31 2010 +0900 @@ -27,14 +27,22 @@ int length; // The number of data (4) int size; // Total size of data (4) - int a[2]; // for alignment - int bound[MAX_LIST_DMA_SIZE]; // (4 * MAX_LIST_DMA_SIZE) - ListElement element[MAX_LIST_DMA_SIZE]; // (8 * MAX_LIST_DMA_SIZE) + int *bound; + ListElement *element; void clear(void) { length = 0; size = 0; } + +/* + void print(Scheduler *s) { + s->printf("inList length %d size %d\n",length, size); + for(int i=0;i<length;i++) { + s->printf("inList element[%d] size %d addr %lx\n",i, element[i].size, (unsigned long)element[i].addr); + } + } +*/ }; typedef ListData* ListDataPtr;
--- a/TaskManager/kernel/schedule/SchedExit.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedExit.cc Fri Mar 05 13:12:31 2010 +0900 @@ -5,7 +5,6 @@ SchedTaskBase* SchedExit::next(Scheduler *scheduler, SchedTaskBase *p) { - // delete p; __debug("SchedExit::next()\n");
--- a/TaskManager/kernel/schedule/SchedTask.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,48 +1,28 @@ + #include <stdlib.h> #include <string.h> #include "SchedTask.h" +#include "SysFunc.h" #include "SchedTaskList.h" +#include "SchedTaskArrayLoad.h" #include "SchedNop2Ready.h" #include "DmaManager.h" #include "error.h" #include "TaskManager.h" #include <stdarg.h> -extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT]; - -/** - Task Object を作る - */ - - -SchedTask * -createSchedTask(Scheduler *scheduler, TaskPtr task) -{ - return new SchedTask(); -} +#include "SchedTaskArray.h" +#define Task SimpleTask +#define TaskPtr SimpleTaskPtr +extern TaskObject task_list[MAX_TASK_OBJECT]; -/** - code load を始める。既に get_segment hash に入っていれば何もしない。 - 最初の一回は SchedTaskList:: next から呼ばれる。 - この段階では、SchedTask object は、まだ作られてない。 - */ -static void -loadSchedTask(Scheduler *scheduler,TaskPtr task) -{ -// fprintf(stderr,"loadSchedTask %d\n",task->command); - task_list[task->command].load(scheduler,task->command); -} SchedTask::SchedTask() { list = NULL; task = NULL; -#ifndef SIMPLE_TASK - inListData = NULL; - outListData = NULL; -#endif readbuf = NULL; writebuf = NULL; scheduler = NULL; @@ -63,20 +43,14 @@ void -SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, - // ListDataPtr rbuf, ListDataPtr wbuf, - Scheduler* sc) +SchedTask::init(TaskListPtr _list, TaskPtr _task, int index, Scheduler* sc) { list = _list; task = _task; -#ifndef SIMPLE_TASK - inListData = &_task->inData; - outListData = &_task->outData; -#endif scheduler = sc; cur_index = index; - scheduler->mainMem_wait(); + scheduler->mainMem_wait(); // これはなんで? } @@ -88,27 +62,13 @@ // object creation をSchedTask生成時にやらないので、 // exec の直前のread で十分に間に合う - if (cur_index < list->length) { - // load next task - loadSchedTask(scheduler, &list->tasks[cur_index]); - } -#ifdef SIMPLE_TASK - writebuf = scheduler->allocate(task->w_size); + loadSchedTask(scheduler, task->command); + // 読むデータが一つもなければ無視 if (task->r_size == 0) return; // load Input Data readbuf = scheduler->allocate(task->r_size); scheduler->dma_load(readbuf, task->rbuf,task->r_size, DMA_READ); -#else - 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); -#endif } @@ -119,21 +79,19 @@ { __debug("[SchedTask:%s]\n", __FUNCTION__); + if (task->w_size > 0) { + writebuf = scheduler->allocate(task->w_size); + } scheduler->dma_wait(DMA_READ); task_list[task->command].wait(scheduler,task->command); task_list[task->command].run(this, readbuf, writebuf); free(readbuf); // 書き込む領域がなければ無視 -#ifdef SIMPLE_TASK + if (task->w_size > 0) { scheduler->dma_store(writebuf, task->wbuf,task->w_size, DMA_WRITE); } -#else - if (outListData->length > 0) { - scheduler->dma_storeList(outListData, writebuf, DMA_WRITE); - } -#endif } void @@ -147,7 +105,6 @@ scheduler->mail_write((memaddr)task->self); } - SchedTaskBase* SchedTask::next(Scheduler *scheduler, SchedTaskBase *p) { @@ -157,10 +114,20 @@ // Task List が残っているので、次を準備 TaskPtr nextTask = &list->tasks[cur_index++]; - SchedTaskBase *nextSched = createSchedTask(scheduler, nextTask); - // この up cast は汚い... - ((SchedTask*)nextSched)->init(list, nextTask, cur_index, - scheduler); + SchedTask *nextSched = new SchedTask(); + nextSched->init(list, nextTask, cur_index, scheduler); + // この時点で、TaskList は down load が済んでないことがある + // 最初のTaskの種類に関しては、別な情報で渡す方が良い + // あるいはTaskListの最初には、TaskArray1/TaskArray を置かない? + + if (nextTask->command==TaskArray1) { + // compatibility + return new SchedTaskArray(scheduler, nextSched); + } + if (nextTask->command==TaskArray) { + // Start Task Array + return new SchedTaskArrayLoad(scheduler, nextSched); + } return nextSched; } else { memaddr nextList = (memaddr)list->next; @@ -169,7 +136,7 @@ return new SchedNop2Ready(scheduler); } else { // 新しいリストに取り掛かる - return createSchedTaskList(nextList, scheduler, 0); + return new SchedTaskList(nextList, scheduler); } } } @@ -181,84 +148,21 @@ return scheduler->id; } -#ifndef SIMPLE_TASK -/** - * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 - * buffer から対応するデータを返す。 - */ -void* -SchedTask::get_input(void *buff, int index) -{ - if (buff != NULL) { - return (void*)((char*)buff + inListData->bound[index]); - } else { - return NULL; - } -} - -/** - * 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; +void SchedTask::free_(void *p) { + scheduler->free_(p); } -/** - * write buffer の領域を返す。 - */ -void* -SchedTask::get_output(void *buff, int index) -{ - if (buff != NULL) { - return (void*)((char *)buff + outListData->bound[index]); - } else { - return NULL; - } -} -/** - * 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 -} +void* SchedTask::get_input(void *buff, int index) { + scheduler->printf("Cannot use inData in SimpleTask use TaskArray\n"); + return NULL; } +memaddr SchedTask::get_inputAddr(int index) { return 0; } +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 0; } +int SchedTask::get_outputSize(int index) { return 0; } +memaddr SchedTask::get_param(int index) { return 0; } -/** - * get_output(index) のサイズを返す - */ -int -SchedTask::get_outputSize(int index) -{ - return outListData->element[index].size; -} - -memaddr -SchedTask::get_param(int index) -{ - return task->param[index]; -} -#endif void* SchedTask::global_alloc(int id, int size) { @@ -390,25 +294,14 @@ /* system call */ int -SchedTask::fprintf(FILE * stream, const char * format, ...) -{ - va_list ap; - va_start(ap,format); - int ret = vfprintf(stream,format, ap); - va_end(ap); - return ret; -} - -int SchedTask::printf(const char * format, ...) { va_list ap; va_start(ap,format); - int ret= vfprintf(stdout,format, ap); + int ret= scheduler->vprintf0(format, ap); va_end(ap); return ret; } - /* end */
--- a/TaskManager/kernel/schedule/SchedTask.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Fri Mar 05 13:12:31 2010 +0900 @@ -10,10 +10,6 @@ #include "HTask.h" #include "MemList.h" -#ifdef SIMPLE_TASK -#define Task SimpleTask -#define TaskPtr SimpleTaskPtr -#endif class SchedTask : public SchedTaskBase { public: @@ -23,22 +19,13 @@ BASE_NEW_DELETE(SchedTask); -private: + // Task Array しか使わないが、たいした大きさではないのでいいか... + ListData inListData; + ListData outListData; + /* variables */ - // Task を実行するスケジューラ自身 - Scheduler *scheduler; - - // 現在スケジューラが実行している TaskList と、このタスクに対応する Task - TaskListPtr list; - TaskPtr task; - - // read/write 用の ListData - ListDataPtr inListData; - ListDataPtr outListData; -#ifndef SIMPLE_TASK - memaddr *param; -#endif +private: /** * read データ、write 用のバッファ @@ -49,8 +36,6 @@ void *readbuf; void *writebuf; - // Task の、Tasklist での位置。(task = &list[cur_index-1]) - int cur_index; /* functions */ @@ -69,25 +54,22 @@ public: /* functions */ - void init(TaskListPtr _list, TaskPtr _task, int index, - // ListDataPtr rbuf, ListDataPtr wbuf, + void init(TaskListPtr _list, SimpleTaskPtr _task, int index, Scheduler* sc); //--- User API --- -#ifdef SIMPLE_TASK int read_size() { return task->r_size; } int write_size() { return task->w_size; } void set_write_size(int w) { task->w_size = w; } -#else - 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); -#endif int get_cpuid(); @@ -109,9 +91,7 @@ void *allocate(int size); - void free_(void *p) { - scheduler->free_(p); - } + void free_(void *p) ; /* これは禁止するべき */ void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask); @@ -125,7 +105,6 @@ /*! SPU用の get_input, get_output */ -#ifndef SIMPLE_TASK void* get_input(int index) { return get_input(readbuf, index); } @@ -133,7 +112,6 @@ void* get_output(int index) { return get_output(writebuf, index); } -#endif // user HTaskPtr create_task(int cmd); @@ -152,14 +130,13 @@ FILE *stdout_; FILE *stderr_; FILE *stdin_; - int fprintf(FILE * stream, const char * format, ...); + int printf(const char * format, ...); }; -extern SchedTask* createSchedTask(Scheduler *,TaskPtr); - +extern void loadSchedTask(Scheduler *scheduler,TaskPtr task); #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskArray.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,240 @@ +#include "SchedTaskArray.h" +#include "Scheduler.h" + + +SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_, Task *curTask_, Task *_array) +{ + savedTask = savedTask_; + atask = curTask_; + array = _array; + scheduler = s; + + inListData.bound = 0; + inListData.size = 0; + inListData.length = 0; + inListData.element = 0; + outListData.bound = 0; + outListData.size = 0; + outListData.length = 0; + outListData.element = 0; +} + +/** + Constructor for old Task with ListData + next TaskList entry contains Task object. + savedTask->rbuf is 0, it has only one Task. + */ + +SchedTaskArray::SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_) +{ + savedTask = savedTask_; + scheduler = s; + + inListData.bound = 0; + inListData.size = 0; + inListData.length = 0; + inListData.element = 0; + outListData.bound = 0; + outListData.size = 0; + outListData.length = 0; + outListData.element = 0; + + atask = (TaskPtr)&savedTask->list->tasks[savedTask->cur_index]; + array = 0; + savedTask->cur_index += (atask->size()+sizeof(SimpleTask))/sizeof(SimpleTask); + +} + +/** + */ +SchedTaskArray::~SchedTaskArray() +{ +} + +/** + * DMA buffer offset in rbuf + */ +static void +bound(ListData *list) +{ + ListElement *elm = list->element; + int *bound = list->bound; + int offset=0; + for(int i=0;i<list->length;i++) { + bound[i] = offset; + offset += elm[i].size; + } +} + +/** + * Task data / code read + */ +void +SchedTaskArray::read() +{ + + // object creation をSchedTaskArray生成時にやらないので、 + // exec の直前のread で十分に間に合う + loadSchedTask(scheduler, atask->command); + + // 読むデータが一つもなければ無視 + 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*)scheduler->allocate(inListData.length*sizeof(int)); + + // load Input Data + readbuf = scheduler->allocate(inListData.size); + // inListData.print(); + scheduler->dma_loadList(&inListData, readbuf, DMA_READ); + bound(&inListData); + +} + +/** + * Wait read data and execute task + * Start write DMA + */ +void +SchedTaskArray::exec() +{ + + if (atask->outData_count > 0) { + outListData.length = atask->outData_count; + outListData.size = atask->outData_total_size(); + outListData.element = atask->outData(0); + outListData.bound = (int*)scheduler->allocate(outListData.length*sizeof(int)); + bound(&outListData); + + writebuf = scheduler->allocate(outListData.size); + } + + scheduler->dma_wait(DMA_READ); + task_list[atask->command].wait(scheduler,atask->command); + task_list[atask->command].run(this, readbuf, writebuf); + free(readbuf); + // 書き込む領域がなければ無視 + + // User 側で作る方法が必要... + + if (atask->outData_count > 0) { + // outListData.print(); + scheduler->dma_storeList(&outListData, writebuf, DMA_WRITE); + } +} + +/** + * Wait write DMA + * send finish mail + */ +void +SchedTaskArray::write() +{ + + scheduler->dma_wait(DMA_WRITE); + free(writebuf); + free(inListData.bound); + free(outListData.bound); +} + +Task *SchedTaskArray::last() +{ + SchedTask *s = (SchedTask *)savedTask; + return (Task*)(((char*)array)+ s->read_size()); +} + +SchedTaskBase* +SchedTaskArray::next(Scheduler *scheduler, SchedTaskBase *p) +{ + + Task *next = atask->next(); + if (next < last()) { + // Task List が残っているので、次を準備 + return new SchedTaskArray(scheduler, savedTask, next, array); + } else { + // このTaskArrayは終り。save していた Task の次を返す。 + // savedTask の read/exec は実行されない (command = TaskArray) + SchedTask *s = (SchedTask *)savedTask; + SchedTaskBase *n = savedTask->next(scheduler, savedTask); + scheduler->mail_write((memaddr)savedTask->task->self); + free(array); + delete savedTask; + return n; + } +} + + + +/** + * 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) +{ + return *atask->param(index); +} + + +/* end */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskArray.h Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,52 @@ +#ifndef INCLUDED_SCHED_TASK_ARRAY +#define INCLUDED_SCHED_TASK_ARRAY + +#include "base.h" +#include "Scheduler.h" +#include "SchedTask.h" + + +class SchedTaskArray : public SchedTask { +public: + BASE_NEW_DELETE(SchedTaskArray); + + /* constructor */ + SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_, Task *task_, Task *array_); + /* constructor for old style task */ + SchedTaskArray(Scheduler *s, SchedTaskBase *savedTask_); + + virtual ~SchedTaskArray(); + + + SchedTaskBase *savedTask; + Task *array; + +private: + /* variables */ + + TaskPtr atask; + void *readbuf; + void *writebuf; + + /* functions */ + Task *last(); + + // override + void read(); + void exec(); + void write(); + SchedTaskBase* next(Scheduler *, SchedTaskBase *); + + void* get_input(void*, int); + memaddr get_inputAddr(int); + int get_inputSize(int); + void* get_output(void*, int); + memaddr get_outputAddr(int); + int get_outputSize(int); + memaddr get_param(int); + +}; + + +#endif +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskArrayLoad.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,40 @@ +#include "SchedTaskArrayLoad.h" +#include "SchedTaskArray.h" +#include "Task.h" + + +SchedTaskArrayLoad::SchedTaskArrayLoad(Scheduler *s, SchedTaskBase *savedTask_) +{ + scheduler = s; + savedTask = savedTask_; + task = savedTask->task; +} + +SchedTaskArrayLoad::~SchedTaskArrayLoad() {} + +void +SchedTaskArrayLoad::read() +{ + // if (task->r_size == 0) return; cannot happen... + // load Task Array Data + readbuf = scheduler->allocate(task->r_size); + scheduler->dma_load(readbuf, task->rbuf,task->r_size, DMA_READ); +} + +void +SchedTaskArrayLoad::exec() { + // もっと、はやめに DMA_READ して、最初のcodeをloadするべきか? + scheduler->dma_wait(DMA_READ); +} // to empty the pipeline + +void +SchedTaskArrayLoad::write() {} // to empty the pipeline + +SchedTaskBase* +SchedTaskArrayLoad::next(Scheduler *scheduler, SchedTaskBase *p) +{ + Task *nextTask = (Task *)readbuf; + return new SchedTaskArray(scheduler, savedTask, nextTask, nextTask); +} + +/* end */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskArrayLoad.h Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,37 @@ +#ifndef INCLUDED_SCHED_TASK_ARRAY_LOAD +#define INCLUDED_SCHED_TASK_ARRAY_LOAD + +#include "base.h" +#include "Scheduler.h" +#include "SchedTask.h" + +class SchedTaskArrayLoad : public SchedTask { +public: + /* constructor */ + SchedTaskArrayLoad(Scheduler *s, SchedTaskBase *savedTask_); + virtual ~SchedTaskArrayLoad(); + + BASE_NEW_DELETE(SchedTaskArrayLoad); + + SchedTaskBase *savedTask; + +private: + /* variables */ + + void *readbuf; + SimpleTask *task; + + /* functions */ + + // override + void read(); + void exec(); + void write(); + SchedTaskBase* next(Scheduler *, SchedTaskBase *); + + +}; + + +#endif +
--- a/TaskManager/kernel/schedule/SchedTaskBase.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskBase.h Fri Mar 05 13:12:31 2010 +0900 @@ -9,19 +9,36 @@ class SchedTaskBase { public: /* constructor */ - SchedTaskBase(void) {} - virtual ~SchedTaskBase(void) {} + // void *called ; // for debug + SchedTaskBase() { + // called = __builtin_return_address(1); + } + virtual ~SchedTaskBase() {} BASE_NEW_DELETE(SchedTaskBase); // noaction in default - virtual void load(void) {} - virtual void read(void) {} - virtual void exec(void) {} - virtual void write(void) {} + virtual void load() {} + virtual void read() {} + virtual void exec() {} + virtual void write() {} /* functions */ virtual SchedTaskBase* next(Scheduler *, SchedTaskBase*) {return 0;} + + /* variables */ + + // Task を実行するスケジューラ自身 + Scheduler *scheduler; + + SimpleTaskPtr task; + + // 現在スケジューラが実行している TaskList と、このタスクに対応する Task + TaskListPtr list; + // Task の、Tasklist での位置。(task = &list[cur_index-1]) + int cur_index; + + }; #endif
--- a/TaskManager/kernel/schedule/SchedTaskList.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskList.cc Fri Mar 05 13:12:31 2010 +0900 @@ -2,6 +2,9 @@ #include <string.h> #include "SchedTaskList.h" #include "SchedTask.h" +#include "SysFunc.h" +#include "SchedTaskArray.h" +#include "SchedTaskArrayLoad.h" #include "SchedNop2Ready.h" #include "DmaManager.h" #include "error.h" @@ -15,50 +18,43 @@ * SPE で生成されている場合、DMA の必要は無い * 0: メインメモリ, 1: SPE */ -SchedTaskList* -createSchedTaskList(memaddr next_list, Scheduler* scheduler, int renew_flag) -{ - SchedTaskList* sched = new SchedTaskList(next_list, scheduler); - return sched; -} SchedTaskList::SchedTaskList(memaddr addr, Scheduler *sched) { + // next() で生成された時に、Task List read を始める params_addr = addr; - list = NULL; scheduler = sched; - + cur_index = 0; + list = scheduler->get_curListBuf(); + scheduler->dma_load(list, params_addr, + sizeof(TaskList), DMA_READ_TASKLIST); } void SchedTaskList::read() { + // next() で TaskListの中身を見られてしまうので、 + // ここで DMA 待ちを行う __debug("[SchedTaskList:%s]\n", __FUNCTION__); + scheduler->dma_wait(DMA_READ_TASKLIST); +} - list = scheduler->get_curListBuf(); - scheduler->dma_load(list, params_addr, - sizeof(TaskList), DMA_READ_TASKLIST); +void +SchedTaskList::exec() { } -SchedTaskBase* -SchedTaskList::next(Scheduler *scheduler, SchedTaskBase *p) +void +SchedTaskList::write() { - SchedTaskBase *nextSched; - - __debug("[SchedTaskList:%s]\n", __FUNCTION__); - - scheduler->dma_wait(DMA_READ_TASKLIST); - if (list->length < 1) { - nextSched = new SchedNop2Ready(scheduler); - } else { - TaskPtr nextTask = &list->tasks[0]; - nextSched = createSchedTask(scheduler, nextTask); - ((SchedTask*)nextSched)->init(list, nextTask, 1, - scheduler); - } - - return nextSched; } +/** + * next は、SchedTask のものが使われる。 + * それで正しく動くはず。 + * + * next() が呼ばれた時点で、TaskList のloadが終了しているように工夫する。 + * + */ + /* end */
--- a/TaskManager/kernel/schedule/SchedTaskList.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskList.h Fri Mar 05 13:12:31 2010 +0900 @@ -3,11 +3,12 @@ #include "base.h" #include "Scheduler.h" -#include "SchedTaskBase.h" +#include "SchedTask.h" +#include "TaskList.h" #include "error.h" -class SchedTaskList : public SchedTaskBase { +class SchedTaskList : public SchedTask { public: /* constructor */ SchedTaskList(memaddr addr, Scheduler *sched); @@ -16,23 +17,15 @@ /* variables */ memaddr params_addr; - TaskListPtr list; - Scheduler *scheduler; - /* functions */ - SchedTaskBase* next(Scheduler *, SchedTaskBase *); - /* override functions */ - void read(void); + void read(); + void exec(); + void write(); -#ifdef DEBUG - void exec(void) { __debug("[SchedTaskList:%s]\n", __FUNCTION__); } - void write(void) { __debug("[SchedTaskList:%s]\n", __FUNCTION__); } -#endif }; -extern SchedTaskList* createSchedTaskList(memaddr, Scheduler*, int); #endif
--- a/TaskManager/kernel/schedule/Scheduler.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,6 +1,8 @@ #include <stdio.h> #include <stdlib.h> +#include <stdarg.h> #include "Scheduler.h" +#include "SchedTask.h" #include "SchedNop.h" #include "error.h" #include <assert.h> @@ -11,7 +13,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() { @@ -21,10 +23,12 @@ static int null_run(SchedTask* smanager, void* r, void *w) { - printf("Calling Undefined Task\n"); + smanager->printf("Calling Undefined Task\n"); return 0; } +static void null_loader(Scheduler *m, int task_id); + /*! @brief speTaskの入出力のパイプラインバッファを確保する */ @@ -34,7 +38,9 @@ hash = 0; for (int i = 0; i< MAX_TASK_OBJECT; i++) { - task_list[0].run = null_run; + task_list[i].run = null_run; + task_list[i].load = null_loader; + task_list[i].wait = null_loader; } set_manager(m); @@ -59,11 +65,12 @@ } void -Scheduler::run() +Scheduler::run(SchedTaskBase* task1) { - task1 = new SchedNop(); - task2 = new SchedNop(); - task3 = new SchedNop(); + + // Pipeline Stage + SchedTaskBase* task2 = new SchedNop(); + SchedTaskBase* task3 = new SchedNop(); // main loop do { @@ -206,7 +213,7 @@ 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, + m->printf("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 + @@ -225,9 +232,9 @@ #if 0 MemorySegment *s = task_list[task_id].segment; if (s) - fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data); + m->printf("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); + m->printf("wait load task id %d 000000\n",task_id); #endif // wait for code segment load m->wait_segment(task_list[task_id].segment); @@ -238,7 +245,7 @@ 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, + m->printf("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 @@ -270,11 +277,11 @@ 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); +this->printf("cmd = %d\n",cmd); +this->printf("locatation = 0x%x\n",start); +this->printf("end = 0x%x\n",start+size); +this->printf("size = 0x%x\n",size); +this->printf("entry = 0x%x\n",entry_offset); #endif } @@ -337,7 +344,7 @@ MemorySegment *s = hash->get(addr); if (s) { /* 既に load されている */ -// fprintf(stderr,"get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); +// this->printf("get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); m->moveToFirst(s); return s; } @@ -356,7 +363,7 @@ s->address = addr; hash->put(s->address, s); -// fprintf(stderr,"get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); +// this->printf("get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); return s; } @@ -427,4 +434,31 @@ } +int +Scheduler::printf(const char * format, ...) +{ +#if !defined(__SPU__) + va_list ap; + va_start(ap,format); + int ret= vprintf0(format, ap); + va_end(ap); + return ret; +#else + return 0; +#endif +} + + +int +Scheduler::vprintf0(const char * format, va_list ap) +{ +#if !defined(__SPU__) + int ret= vprintf(format, ap); + return ret; +#else + return 0; +#endif +} + + /* end */
--- a/TaskManager/kernel/schedule/Scheduler.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Fri Mar 05 13:12:31 2010 +0900 @@ -2,12 +2,12 @@ #define INCLUDED_SCHEDULER #include <stdlib.h> +#include <stdarg.h> #include "base.h" #include "TaskList.h" #include "ListData.h" #include "DmaManager.h" #include "SchedTaskBase.h" -#include "SchedTaskList.h" #include "MemList.h" #include "MemHash.h" @@ -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,31 +70,14 @@ /* 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; - // Pipeline Stage - SchedTaskBase* task1; - SchedTaskBase* task2; - SchedTaskBase* task3; /* functions */ void init(TaskManagerImpl *m); - void run(); + void run(SchedTaskBase* task1); + virtual void init_impl() {}; void finish(); @@ -139,7 +137,8 @@ void* allocate(int size,int align) ; long get_random() ; Scheduler *get_scheduler() { return this; }; - + int printf(const char *format, ...); + int vprintf0(const char *format, va_list ap); }; @@ -155,9 +154,18 @@ unsigned int buf; }; +extern TaskObject task_list[MAX_TASK_OBJECT]; + +inline void +loadSchedTask(Scheduler *scheduler,int command) +{ + task_list[command].load(scheduler,command); +} + #endif + #define SchedConstructor(str) \ str() {} \ BASE_NEW_DELETE(str) \
--- a/TaskManager/kernel/sys_task/SysTasks.h Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/sys_task/SysTasks.h Fri Mar 05 13:12:31 2010 +0900 @@ -3,3 +3,5 @@ ShowTime, StartProfile, #define Dummy StartTask +#define TaskArray (-1) +#define TaskArray1 (-2)
--- a/TaskManager/kernel/sys_task/systask_register.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/TaskManager/kernel/sys_task/systask_register.cc Fri Mar 05 13:12:31 2010 +0900 @@ -3,10 +3,12 @@ SchedExternTask(StartTask); SchedExternTask(FinishTask); +// SchedExternTask(TaskArray); void systask_register() { SchedRegister(StartTask); SchedRegister(FinishTask); +// SchedRegister(TaskArray); }
--- a/example/Bulk/Makefile.def Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Bulk/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -8,7 +8,8 @@ CERIUM = ../../../Cerium CC = g++ -CFLAGS = -g -Wall -O9 +OPT = -g +CFLAGS = -Wall $(OPT) ABIBIT = 32
--- a/example/Bulk/main.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Bulk/main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -2,20 +2,23 @@ #include <stdlib.h> #include <string.h> #include "TaskManager.h" +#include "Task.h" +#include "ListData.h" #include "Func.h" extern void task_init(void); static int length = DATA_NUM; -static int task = 1; -static int count = 1; +static int task = 3; +static int count = 3; +static int data_count = 3; const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ -length Number of data (default DATA_NUM (Func.h))\n\ -count Number of task (default 1)\n"; -void +static void print_data(int *data, int size, const char *title) { printf("%s ---\n", title); @@ -28,79 +31,107 @@ /** * タスク終了後の data1, data2 の確認 */ -void +static void twice_result(SchedTask *s, void *a, void *b) { int* data = (int*)a; - print_data(data, length, "after"); + int* task_buf = (int*)b; + print_data(data, length*count, "after"); free(data); + free(task_buf); } -int +static int init(int argc, char **argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-length") == 0) { length = atoi(argv[++i]); - } else if (strcmp(argv[i], "-count") == 0) { + } else if (strcmp(argv[i], "-task") == 0) { task = atoi(argv[++i]); - } else if (strcmp(argv[i], "-bluk") == 0) { + } else if (strcmp(argv[i], "-count") == 0) { count = atoi(argv[++i]); + } else if (strcmp(argv[i], "-data_count") == 0) { + data_count = atoi(argv[++i]); } } return 0; } -void -twice_init(TaskManager *manager) +#if 0 +static void print_ListData(int size, ListElement *t) { - TaskArray *twice; + for(int i = 0;i<size;i++) { + printf("ListData %d %d %lx\n",i,t[i].size,(unsigned long)t[i].addr); + } +} +#endif - int *data = (int*)manager->allocate(sizeof(int)*length); +void +twice_init(TaskManager *manager,int *data, int length) +{ - for (int i = 0; i < length; i++) { + + for (int i = 0; i < length*count; i++) { data[i] = i; } - print_data(data, length, "before"); + print_data(data, length*count, "before"); /** * Create Task * create_task(Task ID); */ - twice = manager->create_bulk_task(count); + + HTask *twice_main = manager->create_task_array(Twice,count,data_count+1,data_count,data_count); + Task *t = twice_main->next_task_array(Twice, 0); +#if 0 + printf("allocate task size 0x%0x\n",t->size()); + printf("allocate task total size 0x%0x = 0x%0x * %d\n",twice_main->r_size, + t->size(), count); +#endif + void *task_buf = twice_main->rbuf; + twice_main->set_post(twice_result, (void*)data, task_buf); + + t = 0; for(int i = 0;i<count;i++) { - Task t = twice_main->create_stask(Twice); - int length2 = length/2; - /** - * Set 32bits parameter - * add_param(32bit parameter); - */ - t->set_param(0, (memaddr)length2); - t->set_param(1, (memaddr)length2); - /** - * Set of Input Data - * add_inData(address of input data, size of input data); - */ - t->add_inData(data, sizeof(int)*length2); - t->add_inData(data+length2, sizeof(int)*length2); - /** - * Set of OutPut area - * add_outData(address of output area, size of output area); - */ - t->add_outData(data, sizeof(int)*length2); - t->add_outData(data+length2, sizeof(int)*length2); + t = twice_main->next_task_array(Twice, t); + int length2 = length/data_count; + t->set_param(0, (memaddr)data_count); + + for(int j = 0;j<data_count;j++) { + /** + * Set 32bits parameter + * add_param(32bit parameter); + */ + t->set_param(j+1, (memaddr)length2); + /** + * Set of Input Data + * add_inData(address of input data, size of input data); + */ + t->set_inData(j,data, sizeof(int)*length2); + /** + * Set of Output area + * add_outData(address of output area, size of output area); + */ + t->set_outData(j,data, sizeof(int)*length2); + data += length2; + } +#if 0 + print_ListData(data_count,t->inData(0)); + print_ListData(data_count,t->outData(0)); + printf("pos 0x%0lx size 0x%0x\n",(unsigned long)t, t->size()); +#endif } + twice_main->spawn_task_array(t->next()); + twice_main->set_cpu(SPE_ANY); - /* * set_post() で ppe task を渡せるようにしたい */ - twice->set_post(twice_result, (void*)data, 0); - // add Active Queue - twice->spawn_bulk(); + twice_main->spawn(); } int @@ -115,7 +146,8 @@ task_init(); for (int i = 0; i < task; ++i) { - twice_init(manager); + int *data = (int*)manager->allocate(sizeof(int)*length*count); + twice_init(manager, data, length); } return 0;
--- a/example/Bulk/ppe/Twice.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Bulk/ppe/Twice.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,5 +1,5 @@ #include <stdio.h> -#include "SchedTask.h" +#include "SchedTaskArray.h" #include "Twice.h" #include "Func.h" @@ -9,16 +9,21 @@ static int run(SchedTask *s,void *rbuf, void *wbuf) { + // SchedTaskArray *a = (SchedTaskArray *)s; + int *i_data; int *o_data; long length; + int count = (int)s->get_param(0); - i_data = (int*)s->get_input(rbuf, 0); - o_data = (int*)s->get_output(wbuf, 0); - length = (long)s->get_param(0); - - for (int i = 0; i < length; i++) { - o_data[i] = i_data[i] * 2; + for(int j = 0; j<count; j++) { + i_data = (int*)s->get_input(rbuf, j); + o_data = (int*)s->get_output(wbuf, j); + length = (long)s->get_param(j+1); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } } return 0;
--- a/example/Bulk/ppe/task_init.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Bulk/ppe/task_init.cc Fri Mar 05 13:12:31 2010 +0900 @@ -13,5 +13,5 @@ void task_init(void) { - SchedRegisterTask(TWICE_TASK, Twice); + SchedRegister(Twice); }
--- a/example/Bulk/spe/Twice.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Bulk/spe/Twice.cc Fri Mar 05 13:12:31 2010 +0900 @@ -1,5 +1,5 @@ #include <stdio.h> -#include "SchedTask.h" +#include "SchedTaskArray.h" #include "Twice.h" #include "Func.h" @@ -7,18 +7,23 @@ SchedDefineTask(Twice); static int -run(SchedTask *s, void *rbuf, void *wbuf) +run(SchedTask *s,void *rbuf, void *wbuf) { + // SchedTaskArray *a = (SchedTaskArray *)s; + int *i_data; int *o_data; - int length; + long length; + int count = (int)s->get_param(0); - i_data = (int*)s->get_input(rbuf, 0); - o_data = (int*)s->get_output(wbuf, 0); - length = (long)s->get_param(0); - - for (int i = 0; i < length; i++) { - o_data[i] = i_data[i] * 2; + for(int j = 0; j<count; j++) { + i_data = (int*)s->get_input(rbuf, j); + o_data = (int*)s->get_output(wbuf, j); + length = (long)s->get_param(j+1); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } } return 0;
--- a/example/Bulk/spe/spe-main.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Bulk/spe/spe-main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -10,5 +10,5 @@ void task_init(Scheduler *s) { - SchedRegisterTask(TWICE_TASK, Twice); + SchedRegister(Twice); }
--- a/example/Simple/Makefile.def Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Simple/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -5,11 +5,11 @@ # ex linux/ps3 CERIUM = ../../../Cerium -SIMPLE_TASK=-DSIMPLE_TASK -# SIMPLE_TASK= + +OPT= -g CC = g++ -CFLAGS = -g -Wall -O9 $(SIMPLE_TASK) +CFLAGS = -Wall $(OPT) INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager
--- a/example/Simple/Makefile.macosx Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Simple/Makefile.macosx Fri Mar 05 13:12:31 2010 +0900 @@ -22,7 +22,7 @@ all: $(TARGET) $(TARGET): $(OBJS) $(TASK_OBJS) - $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) $(OPT) link: $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS)
--- a/example/Simple/spe/Makefile Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Simple/spe/Makefile Fri Mar 05 13:12:31 2010 +0900 @@ -6,7 +6,7 @@ SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o) -CC = spu-g++ -DABIBIT=$(ABIBIT) $(SIMPLE_TASK) +CC = spu-g++ -DABIBIT=$(ABIBIT) $(OPT) CFLAGS = -g -Wall -fno-exceptions -fno-rtti #-DDEBUG INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I.. LIBS = -L../${CERIUM}/TaskManager -lspemanager @@ -19,7 +19,7 @@ all: $(TARGET) $(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) $(OPT) clean: rm -f $(TARGET) $(OBJS)
--- a/example/Simple/spe/Twice.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/Simple/spe/Twice.cc Fri Mar 05 13:12:31 2010 +0900 @@ -7,11 +7,11 @@ SchedDefineTask(Twice); static int -run(SchedTask *s, void *rbuf, void *wbuf) +run(SchedTask *s,void *rbuf, void *wbuf) { int *i_data; int *o_data; - int length; + long length; i_data = (int*)rbuf; o_data = (int*)wbuf;
--- a/example/basic/Makefile.def Tue Feb 16 15:09:54 2010 +0900 +++ b/example/basic/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -8,7 +8,8 @@ CERIUM = ../../../Cerium CC = g++ -CFLAGS = -g -Wall -O9 +OPT = -g +CFLAGS = $(OPT) -Wall ABIBIT = 32
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ChangeLog Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,6 @@ +2008-05-27 Wataru MIYAGUNI <gongo@cr.ie.u-ryukyu.ac.jp> + + * memo + Fifo СǤϳǧޤ + Cell СϡCerium ޤ̤ʤΤǤ줫 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Func.h Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,6 @@ +enum { +#include "SysTasks.h" + Hello, + TwiceMain, +}; +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,20 @@ +default: macosx + +macosx: FORCE + @echo "Make for Mac OS X" + @$(MAKE) -f Makefile.macosx + +linux: FORCE + @echo "Make for Linux" + @$(MAKE) -f Makefile.linux + +cell: FORCE + @echo "Make for PS3 (Cell)" + @$(MAKE) -f Makefile.cell + +FORCE: + +clean: + @$(MAKE) -f Makefile.macosx clean + @$(MAKE) -f Makefile.linux clean + @$(MAKE) -f Makefile.cell clean \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.cell Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,39 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cc) +SRCS_EXCLUDE = # ե +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +TASK_DIR = ppe +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) +TASK_SRCS_EXCLUDE = +TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cc=.o) + +LIBS += -lCellManager -lspe2 -lpthread -Wl,--gc-sections + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) speobject + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +speobject: + cd spe; $(MAKE) + +link: + $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) + +debug: $(TARGET) + sudo ppu-gdb ./$(TARGET) + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f *~ \#* + rm -f ppe/*~ ppe/\#* + cd spe; $(MAKE) clean
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,17 @@ +TARGET = hello + +# include/library path +# ex macosx +#CERIUM = /Users/gongo/Source/Cerium + +# ex linux/ps3 +CERIUM = ../../../Cerium + +CC = g++ +OPT = -g +CFLAGS = -Wall $(OPT) + +ABIBIT = 32 + +INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L${CERIUM}/TaskManager
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.linux Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,36 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cc) +SRCS_EXCLUDE = # ե +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +TASK_DIR = ppe +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) +TASK_SRCS_EXCLUDE = +TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cc=.o) + +LIBS += -lFifoManager + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +link: + $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) + +debug: $(TARGET) + sudo gdb ./$(TARGET) + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f *~ \#* + rm -f ppe/*~ ppe/\#* + rm -f spe/*~ spe/\#*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.macosx Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,37 @@ +include ./Makefile.def + +SRCS_TMP = $(wildcard *.cc) +SRCS_EXCLUDE = # ե +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +TASK_DIR = ppe +TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc) +TASK_SRCS_EXCLUDE = +TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP)) +TASK_OBJS = $(TASK_SRCS:.cc=.o) + +LIBS += -lFifoManager `sdl-config --libs` +CC += -m$(ABIBIT) + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) $(TASK_OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +link: + $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) + +debug: $(TARGET) + sudo gdb ./$(TARGET) + +clean: + rm -f $(TARGET) $(OBJS) $(TASK_OBJS) + rm -f *~ \#* + rm -f ppe/*~ ppe/\#* + rm -f spe/*~ spe/\#*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,70 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "TaskManager.h" +#include "Task.h" +#include "ListData.h" +#include "Func.h" + +extern void task_init(void); + +static int task_num = 1; +/*0 だと task_num が4つ以上の時に止まる。*/ +static int data_count = 1; + +const char *usr_help_str = "Usage: ./hello [-task task_num]\n\ + -task Number of task (default 1)\n"; + +static int +init(int argc, char **argv) +{ + for (int i = 1; argv[i]; ++i) { + + if (strcmp(argv[i], "-task") == 0) { + task_num = atoi(argv[++i]); + } + } + + return 0; +} + + +void +hello_init(TaskManager *manager) +{ + + + /** + * Create Task + * create_task(Task ID); + */ + + /*うしろ3つ param/inData/outData の数を指定する*/ + HTask *twice_main = manager->create_task_array(Hello,task_num,data_count,data_count,data_count); + Task *t = 0; + + for(int i = 0;i<task_num;i++) { + t = twice_main->next_task_array(Hello, t); + } + + twice_main->spawn_task_array(t->next()); + twice_main->set_cpu(SPE_ANY); + twice_main->spawn(); +} + +int +TMmain(TaskManager *manager,int argc, char *argv[]) +{ + + if (init(argc, argv) < 0) { + return -1; + } + + // Task Register + // ppe/task_init.cc + task_init(); + hello_init(manager); + + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/Hello.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,17 @@ +#include <stdio.h> +#include "SchedTaskArray.h" +#include "Hello.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(Hello); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + s->printf("Hello World\n"); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/Hello.h Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,16 @@ +#ifndef INCLUDED_TASK_HELLO +#define INCLUDED_TASK_HELLO + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif +/* +class Twice : public SchedTask { +public: + SchedConstructor(Hello); + + int run(void *r, void *w); +}; + */ + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/task_init.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,17 @@ +#include "Func.h" +#include "Scheduler.h" + +/* 必ずこの位置に書いて */ +SchedExternTask(Hello); + +/** + * この関数は ../spe/spe-main と違って + * 自分で呼び出せばいい関数なので + * 好きな関数名でおk (SchedRegisterTask は必須) + */ + +void +task_init(void) +{ + SchedRegister(Hello); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Hello.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,17 @@ +#include <stdio.h> +#include "SchedTaskArray.h" +#include "Hello.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask(Hello); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + s->printf("Hello World\n"); + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Hello.h Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,16 @@ +#ifndef INCLUDED_TASK_HELLO +#define INCLUDED_TASK_HELLO + +#ifndef INCLUDED_SCHED_TASK +# include "SchedTask.h" +#endif +/* +class Twice : public SchedTask { +public: + SchedConstructor(Hello); + + int run(void *r, void *w); +}; + */ + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Makefile Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,26 @@ +include ../Makefile.def + +TARGET = ../spe-main + +SRCS_TMP = $(wildcard *.cc) +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +CC = spu-g++ +CFLAGS = -g -Wall -fno-exceptions -fno-rtti #-DDEBUG +INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L../${CERIUM}/TaskManager -lspemanager + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +clean: + rm -f $(TARGET) $(OBJS) + rm -f *~ \#* \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/spe-main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -0,0 +1,14 @@ +#include "Func.h" +#include "SchedTask.h" + +SchedExternTask(Hello); + +/** + * この関数は SpeScheduler から呼ばれるので + * 必ずこの関数名でお願いします。 + */ +void +task_init(Scheduler *s) +{ + SchedRegister(Hello); +}
--- a/example/mainMem/Makefile.def Tue Feb 16 15:09:54 2010 +0900 +++ b/example/mainMem/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -6,9 +6,10 @@ # ex: linux/ps3 CERIUM = ../../../Cerium +ABIBIT = 32 CC = g++ -CFLAGS = -g -Wall -O9 +CFLAGS = -g -Wall -O9 -m$(ABIBIT) INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager
--- a/example/mainMem/Makefile.macosx Tue Feb 16 15:09:54 2010 +0900 +++ b/example/mainMem/Makefile.macosx Fri Mar 05 13:12:31 2010 +0900 @@ -1,7 +1,5 @@ include ./Makefile.def -CC += -m64 - SRCS_TMP = $(wildcard *.cc) SRCS_EXCLUDE = # ե SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) @@ -23,10 +21,8 @@ all: $(TARGET) $(TARGET): $(OBJS) $(TASK_OBJS) - $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + $(CC) -m$(ABIBIT) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) -link: - $(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS) debug: $(TARGET) sudo gdb ./$(TARGET)
--- a/example/word_count/main.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count/main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -120,33 +120,42 @@ /*渡すデータの最後が文字かどうか。(スペース、改行以外)*/ int word_flag = 0; int i; - for (i = 0; i < task_num; i++) { + int task_size = 32; + for (i = 0; i < task_num; i+=task_size) { + HTask *task_main = manager->create_task_array(TASK_EXEC,task_size,2,1,1); + int j ; + Task *t_exec = 0; + for(j = 0; j < task_size; j++) { + t_exec = task_main->next_task_array(TASK_EXEC,t_exec); + task_main->set_cpu(SPE_ANY); + t_print->wait_for(task_main); + + // t_exec = manager->create_task(TASK_EXEC); + t_exec->set_param(0,division_size); + t_exec->set_param(1,word_flag); + t_exec->set_inData(0,file_mmap + i*division_size, division_size); + t_exec->set_outData(0,o_data + i*status_num, division_out_size); + + word_flag = ((file_mmap[(i+1)*division_size-1] != 0x20) && (file_mmap[(i+1)*division_size-1] != 0x0A)); + + size -= division_size; + } + task_main->spawn_task_array(t_exec->next()); + + } + + while (size>0) { t_exec = manager->create_task(TASK_EXEC); - t_exec->add_inData(file_mmap + i*division_size, division_size); - t_exec->add_outData(o_data + i*status_num, division_out_size); - t_exec->add_param(division_size); - t_exec->add_param(word_flag); + t_exec->set_param(0,size); + t_exec->set_param(1,word_flag); + t_exec->set_inData(0,file_mmap + i*division_size, size); + t_exec->set_outData(0,o_data + i*status_num, division_out_size); t_exec->set_cpu(SPE_ANY); t_print->wait_for(t_exec); t_exec->spawn(); - - word_flag = ((file_mmap[(i+1)*division_size-1] != 0x20) && (file_mmap[(i+1)*division_size-1] != 0x0A)); - + i++; size -= division_size; - - } - - if (size) { - - t_exec = manager->create_task(TASK_EXEC); - t_exec->add_inData(file_mmap + i*division_size, size); - t_exec->add_outData(o_data + i*status_num, division_out_size); - t_exec->add_param(size); - t_exec->add_param(word_flag); - t_exec->set_cpu(SPE_ANY); - t_print->wait_for(t_exec); - t_exec->spawn(); }
--- a/example/word_count_test/Makefile.def Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/Makefile.def Fri Mar 05 13:12:31 2010 +0900 @@ -7,14 +7,12 @@ # ex linux/ps3 CERIUM = ../../../Cerium -# SIMPLE_TASK= -DSIMPLE_TASK -SIMPLE_TASK= OPT = -O9 # OPT = -g CC = g++ -CFLAGS = -Wall $(OPT) $(SIMPLE_TASK) +CFLAGS = -Wall $(OPT) INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. LIBS = -L${CERIUM}/TaskManager
--- a/example/word_count_test/main.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/main.cc Fri Mar 05 13:12:31 2010 +0900 @@ -73,19 +73,10 @@ { for (int j = 0; j < task_count && w->size>0; j++) { int i = w->task_spwaned++; -#ifdef SIMPLE_TASK // printf("div %0x\n", (w->file_mmap + i*w->division_size)); HTaskPtr t_exec = manager->create_task(TASK_EXEC, (memaddr)(w->file_mmap + i*w->division_size), size, (memaddr)(w->o_data + i*w->out_size), w->division_out_size); -#else - HTaskPtr t_exec = manager->create_task(TASK_EXEC); - if (size>w->size) size = w->size; - t_exec->add_inData(w->file_mmap + i*w->division_size, size); - t_exec->add_outData(w->o_data + i*w->status_num, w->division_out_size); - t_exec->add_outData(w->head_tail_flag + i*w->pad, w->division_out_size); - t_exec->add_param(size); -#endif t_exec->set_cpu(SPE_ANY); t_next->wait_for(t_exec); t_exec->spawn(); @@ -99,11 +90,7 @@ static int run16(SchedTask *manager, void *in, void *out) { -#ifdef SIMPLE_TASK WordCount *w = *(WordCount **)in; -#else - WordCount *w = (WordCount *)manager->get_param(0); -#endif if (w->task_num < w->task_blocks) { if (w->size >= w->division_size) @@ -112,13 +99,8 @@ run_tasks(manager,w,1, w->t_print, w->size); // printf("run16 last %d\n",w->task_num); } else { -#ifdef SIMPLE_TASK HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); -#else - HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS); - t_next->set_param(0,(void*)w); -#endif w->t_print->wait_for(t_next); run_tasks(manager,w, w->task_blocks, t_next, w->division_size); @@ -172,52 +154,24 @@ /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(8byte)を使用 */ -#ifdef SIMPLE_TASK w-> division_out_size = sizeof(unsigned long long)*4; int out_size = w->division_out_size*out_task_num; w->o_data = (unsigned long long *)manager->allocate(out_size); w-> out_size = 4; -#else - w-> division_out_size = 16; - int out_size = w->division_out_size*out_task_num; - /* out用のデータのサイズ。*/ - caddr_t p = (caddr_t) manager->allocate(out_size*2); - w->o_data = (unsigned long long*)p; - //bzero(w->o_data,out_size); - - w-> pad = 2; - w->head_tail_flag = (unsigned long long*)(p+out_size); - // bzero(w->head_tail_flag,out_size); -#endif printf("out size %d\n",out_size); /*各SPEの結果を合計して出力するタスク*/ -#ifdef SIMPLE_TASK t_print = manager->create_task(TASK_PRINT, (memaddr)&w->self,sizeof(memaddr),0,0); -#else - t_print = manager->create_task(TASK_PRINT); - t_print->add_inData(w->o_data, out_size); - t_print->add_inData(w->head_tail_flag, out_size); - t_print->add_param(out_task_num); - t_print->add_param(w->status_num); - t_print->add_param(out_task_num); - t_print->add_param(w->pad); -#endif w->t_print = t_print; for(int i = 0;i<1;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ - #ifdef SIMPLE_TASK HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS, (memaddr)&w->self,sizeof(memaddr),0,0); - #else - HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS); - t_exec->set_param(0,(void*)w); - #endif t_exec->spawn(); t_print->wait_for(t_exec); }
--- a/example/word_count_test/ppe/Exec.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/ppe/Exec.cc Fri Mar 05 13:12:31 2010 +0900 @@ -9,18 +9,11 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { -#ifdef SIMPLE_TASK char *i_data = (char *)rbuf; unsigned long long *o_data = (unsigned long long*)wbuf; unsigned long long *head_tail_flag = o_data +2; int length = s->read_size(); -#else - char *i_data = (char*)s->get_input(rbuf, 0); - unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); - /*担当範囲の先頭、末尾が「改行、スペース」か、「それ以外の文字」かのフラグ*/ - unsigned long long *head_tail_flag = (unsigned long long*)s->get_output(wbuf,1); - int length = (long)s->get_param(0); -#endif + int word_flag = 0; int word_num = 0; int line_num = 0;
--- a/example/word_count_test/ppe/Print.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/ppe/Print.cc Fri Mar 05 13:12:31 2010 +0900 @@ -10,7 +10,6 @@ static int run_print(SchedTask *s, void *rbuf, void *wbuf) { -#ifdef SIMPLE_TASK WordCount *w = *(WordCount**)rbuf; unsigned long long *idata = w->o_data; // long task_num = w->task_num; @@ -23,14 +22,6 @@ * o_data[1] * */ -#else - unsigned long long *idata = (unsigned long long*)s->get_input(rbuf, 0); - unsigned long long *head_tail_flag = (unsigned long long*)s->get_input(rbuf, 1); - // long task_num = (long)s->get_param(0); - long status_num = (long)s->get_param(1); - int out_task_num = (int)s->get_param(2); - int pad = (int)s->get_param(3); -#endif unsigned long long word_data[2]; int flag_cal_sum = 0; @@ -75,7 +66,6 @@ word_data[i] = 0; } -#ifdef SIMPLE_TASK for (int i = 0; i < out_task_num ; i++) { word_data[0] += idata[i*w->out_size+0]; word_data[1] += idata[i*w->out_size+1]; @@ -86,21 +76,6 @@ flag_cal_sum++; } } -#else - for (int i = 1; i < out_task_num * pad - pad; i += pad) { - //printf("%llu ",head_tail_flag[i]); - //printf("%llu\n",head_tail_flag[i+1]); - if((head_tail_flag[i] == 1) && (head_tail_flag[i+1] == 0)) { - flag_cal_sum++; - } - } - - for (int i = 0; i < out_task_num*status_num; i += status_num) { - for (int j = 0; j < status_num; j++) { - word_data[j] += idata[i+j]; - } - } -#endif word_data[0] += flag_cal_sum;
--- a/example/word_count_test/spe/Exec.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/spe/Exec.cc Fri Mar 05 13:12:31 2010 +0900 @@ -9,18 +9,10 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { -#ifdef SIMPLE_TASK char *i_data = (char *)rbuf; unsigned long long *o_data = (unsigned long long*)wbuf; unsigned long long *head_tail_flag = o_data +2; int length = s->read_size(); -#else - char *i_data = (char*)s->get_input(rbuf, 0); - unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); - /*担当範囲の先頭、末尾が「改行、スペース」か、「それ以外の文字」かのフラグ*/ - unsigned long long *head_tail_flag = (unsigned long long*)s->get_output(wbuf,1); - int length = (long)s->get_param(0); -#endif int word_flag = 0; int word_num = 0; int line_num = 0;
--- a/example/word_count_test/spe/Makefile Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/spe/Makefile Fri Mar 05 13:12:31 2010 +0900 @@ -7,7 +7,7 @@ OBJS = $(SRCS:.cc=.o) CC = spu-g++ -CFLAGS = -Wall -fno-exceptions -fno-rtti $(OPT) $(SIMPLE_TASK) #-DDEBUG +CFLAGS = -Wall -fno-exceptions -fno-rtti $(OPT) INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I.. LIBS = -L../${CERIUM}/TaskManager -lspemanager
--- a/example/word_count_test/spe/Print.cc Tue Feb 16 15:09:54 2010 +0900 +++ b/example/word_count_test/spe/Print.cc Fri Mar 05 13:12:31 2010 +0900 @@ -10,7 +10,6 @@ static int run_print(SchedTask *s, void *rbuf, void *wbuf) { -#ifdef SIMPLE_TASK WordCount *w = *(WordCount**)rbuf; unsigned long long *idata = w->o_data; // long task_num = w->task_num; @@ -23,14 +22,6 @@ * o_data[1] * */ -#else - unsigned long long *idata = (unsigned long long*)s->get_input(rbuf, 0); - unsigned long long *head_tail_flag = (unsigned long long*)s->get_input(rbuf, 1); - // long task_num = (long)s->get_param(0); - long status_num = (long)s->get_param(1); - int out_task_num = (int)s->get_param(2); - int pad = (int)s->get_param(3); -#endif unsigned long long word_data[2]; int flag_cal_sum = 0; @@ -75,7 +66,6 @@ word_data[i] = 0; } -#ifdef SIMPLE_TASK for (int i = 0; i < out_task_num ; i++) { word_data[0] += idata[i*w->out_size+0]; word_data[1] += idata[i*w->out_size+1]; @@ -86,21 +76,6 @@ flag_cal_sum++; } } -#else - for (int i = 1; i < out_task_num * pad - pad; i += pad) { - //printf("%llu ",head_tail_flag[i]); - //printf("%llu\n",head_tail_flag[i+1]); - if((head_tail_flag[i] == 1) && (head_tail_flag[i+1] == 0)) { - flag_cal_sum++; - } - } - - for (int i = 0; i < out_task_num*status_num; i += status_num) { - for (int j = 0; j < status_num; j++) { - word_data[j] += idata[i+j]; - } - } -#endif word_data[0] += flag_cal_sum;