Mercurial > hg > Game > Cerium
changeset 786:043c98537bc5 draft
fix early free of TaskArray, add SchedTaskArrayNop stage.
author | yutaka@localhost.localdomain |
---|---|
date | Sat, 24 Apr 2010 15:24:33 +0900 |
parents | 083c4a270809 |
children | 64f1d80dc650 |
files | TaskManager/ChangeLog TaskManager/Doxyfile TaskManager/Makefile.cell TaskManager/kernel/schedule/SchedTaskArray.cc TaskManager/kernel/schedule/SchedTaskArrayNop.cc TaskManager/kernel/schedule/SchedTaskArrayNop.h TaskManager/kernel/schedule/Scheduler.cc example/HelloWorld/main.cc example/word_count/main.cc example/word_count/ppe/Exec.cc example/word_count/ppe/Print.cc example/word_count/spe/Exec.cc |
diffstat | 12 files changed, 191 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/ChangeLog Tue Apr 20 15:54:06 2010 +0900 +++ b/TaskManager/ChangeLog Sat Apr 24 15:24:33 2010 +0900 @@ -1,3 +1,21 @@ +2010-4-24 Shinji KONO <kono@ie.u-ryukyu.ac.jp> + + write T3 T2 T1 TL TA0 TA1 + exec T2 T1 TL TA0 TA1 TA2 + read T1 TL TA TA1 TA2 T2 + next T1 TL TA TA1 TA2* T2 + + *のところで終了mailが出てTaskArrayのデータがfreeされてしまうので、よくない + そうならないように、一段TAN(SchedTaskArrayNop)を挟む。 + + write T3 T2 T1 TL TA0 TA1 TA2 TAN% + exec T2 T1 TL TA0 TA1 TA2 TAN T2 + read T1 TL TA TA1 TA2 TAN T2 T3 + next T1 TL TA TA1 TA2 TAN T2 T3 + + %のところで終了mailを送る。T2のreadのところで、TaskArrayのデータはreadbuff上にあるので + 破壊されてしまう。なので、savedTask->task->self の値はTANにコピーして持っていく必要がある + 2009-12-19 Shinji KONO <kono@ie.u-ryukyu.ac.jp> そうか、TaskList->next は、SPE 側で自分で呼び出しているわけね。
--- a/TaskManager/Doxyfile Tue Apr 20 15:54:06 2010 +0900 +++ b/TaskManager/Doxyfile Sat Apr 24 15:24:33 2010 +0900 @@ -25,20 +25,20 @@ # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = "Cerium" +PROJECT_NAME = Cerium # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.1 +PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ../Document/document +OUTPUT_DIRECTORY = ../Document/document # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -60,7 +60,7 @@ # Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, # Spanish, Swedish, and Ukrainian. -OUTPUT_LANGUAGE = Japanese-en +OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in @@ -105,7 +105,7 @@ # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. -FULL_PATH_NAMES = NO +FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is @@ -552,7 +552,7 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = "./" "../include/TaskManager" "./kernel" "./kernel/schedule" "./kernel/ppe" "./kernel/sys_task" "./Fifo" "./Test" "./Test/Sum" "./Test/test_render" "./Test/test_render/xml_file" "./Test/test_render/xml_file/blend" "./Test/test_render/xml_file/blend/images" "./Test/test_render/task" "./Test/test_render/spe" "./Test/test_render/tools" "./Test/simple_render" "./Test/simple_render/task" "./Test/simple_render/test" "./Test/simple_render/test/LoadTexture" "./Test/simple_render/test/LoadTexture/spe" "./Test/simple_render/spe" "./Test/simple_render/trash" "./Test/simple_pack" "./Test/simple_pack/task" "./Test/simple_pack/trash" "./Cell" "./Cell/spe" +INPUT = # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -569,7 +569,7 @@ # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 -FILE_PATTERNS = "*.cc" "*.h" "*.py" +FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -623,7 +623,7 @@ # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. -EXAMPLE_RECURSIVE = YES +EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see @@ -665,7 +665,7 @@ # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. -SOURCE_BROWSER = YES +SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation.
--- a/TaskManager/Makefile.cell Tue Apr 20 15:54:06 2010 +0900 +++ b/TaskManager/Makefile.cell Sat Apr 24 15:24:33 2010 +0900 @@ -12,6 +12,7 @@ $(CELL_SPE_DIR)/SchedMail.cc \ $(CELL_SPE_DIR)/SchedTask.cc \ $(CELL_SPE_DIR)/SchedTaskArray.cc \ + $(CELL_SPE_DIR)/SchedTaskArrayNop.cc \ $(CELL_SPE_DIR)/SchedTaskArrayLoad.cc \ $(CELL_SPE_DIR)/Scheduler.cc\ $(CELL_SPE_DIR)/SchedNop.cc \
--- a/TaskManager/kernel/schedule/SchedTaskArray.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskArray.cc Sat Apr 24 15:24:33 2010 +0900 @@ -1,4 +1,5 @@ #include "SchedTaskArray.h" +#include "SchedTaskArrayNop.h" #include "Scheduler.h" @@ -154,6 +155,12 @@ // Task List が残っているので、次を準備 return new SchedTaskArray(scheduler, savedTask, next, array); } else { + + //このTaskArrayは終わったが、Pipeline 上にread の TaskArray が残っているので + //1ステージを稼ぐ必要がある + + return new SchedTaskArrayNop(scheduler, savedTask, next, array); +#if 0 // このTaskArrayは終り。save していた Task の次を返す。 // savedTask の read/exec は実行されない (command = TaskArray) SchedTaskBase *n = savedTask->next(scheduler, savedTask); @@ -161,6 +168,8 @@ free(array); delete savedTask; return n; +#endif + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskArrayNop.cc Sat Apr 24 15:24:33 2010 +0900 @@ -0,0 +1,77 @@ +#include "SchedTaskArrayNop.h" +#include "Scheduler.h" + + +SchedTaskArrayNop::SchedTaskArrayNop(Scheduler *s, SchedTaskBase *savedTask_, Task *curTask_, Task *_array) +{ + savedTask = savedTask_; + atask = (memaddr)savedTask->task->self; + 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; +} + + + +/** + */ +SchedTaskArrayNop::~SchedTaskArrayNop() +{ +} + + +/** + * Task data / code read + */ +void +SchedTaskArrayNop::read() +{ + +} + +/** + * Wait read data and execute task + * Start write DMA + */ +void +SchedTaskArrayNop::exec() +{ + +} + +/** + * Wait write DMA + * send finish mail + */ +void +SchedTaskArrayNop::write() +{ + + scheduler->mail_write((memaddr)atask); + free(array); + +} + +SchedTaskBase* +SchedTaskArrayNop::next(Scheduler *scheduler, SchedTaskBase *p) +{ + + // 最後のTask が exec されて、次の Task を実行してかまわない。 + + SchedTaskBase *n = savedTask->next(scheduler, savedTask); + + delete savedTask; + return n; + +} + + +/* end */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/kernel/schedule/SchedTaskArrayNop.h Sat Apr 24 15:24:33 2010 +0900 @@ -0,0 +1,39 @@ +#ifndef INCLUDED_SCHED_TASK_ARRAY_NOP +#define INCLUDED_SCHED_TASK_ARRAY_NOP + +#include "base.h" +#include "Scheduler.h" +#include "SchedTask.h" + + +class SchedTaskArrayNop : public SchedTask { +public: + BASE_NEW_DELETE(SchedTaskArrayNop); + + /* constructor */ + SchedTaskArrayNop(Scheduler *s, SchedTaskBase *savedTask_, Task *task_, Task *array_); + + virtual ~SchedTaskArrayNop(); + + + SchedTaskBase *savedTask; + Task *array; + +private: + /* variables */ + + memaddr atask; + + /* functions */ + + // override + void read(); + void exec(); + void write(); + SchedTaskBase* next(Scheduler *, SchedTaskBase *); + +}; + + +#endif +
--- a/TaskManager/kernel/schedule/Scheduler.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Sat Apr 24 15:24:33 2010 +0900 @@ -437,7 +437,7 @@ int Scheduler::printf(const char * format, ...) { -#if !defined(__SPU__) +#if !defined(__SPU__) || 1 va_list ap; va_start(ap,format); int ret= vprintf0(format, ap); @@ -452,7 +452,7 @@ int Scheduler::vprintf0(const char * format, va_list ap) { -#if !defined(__SPU__) +#if !defined(__SPU__) || 1 int ret= vprintf(format, ap); return ret; #else
--- a/example/HelloWorld/main.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/example/HelloWorld/main.cc Sat Apr 24 15:24:33 2010 +0900 @@ -30,14 +30,15 @@ void hello_init(TaskManager *manager) { - HTask *hello; + for (int i = 0; i < count; i++) { /** * Create Task * create_task(Task ID); */ - hello = manager->create_task(HELLO_TASK); + + HTask *hello = manager->create_task(HELLO_TASK); /** * Select CPU @@ -50,7 +51,7 @@ * Set 32bits parameter * add_param(32bit parameter); */ - hello->add_param((memaddr)i); + hello->set_param(0,(memaddr)i); hello->spawn(); }
--- a/example/word_count/main.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/example/word_count/main.cc Sat Apr 24 15:24:33 2010 +0900 @@ -111,9 +111,9 @@ /*各SPEの結果を合計して出力するタスク*/ t_print = manager->create_task(TASK_PRINT); - t_print->add_inData(o_data, out_size); - t_print->add_param(out_task_num); - t_print->add_param(status_num); + t_print->set_inData(0,o_data, out_size); + t_print->set_param(0,out_task_num); + t_print->set_param(1,status_num); /*各SPEに処理するデータを割り振る。*/ @@ -123,19 +123,16 @@ int array_task_num = 32; for (int i = 0; i < task_num; i += array_task_num) { HTask *task_main = manager->create_task_array(TASK_EXEC,array_task_num,2,1,1); + t_print->wait_for(task_main); int j ; Task *t_exec = 0; for(j = 0; j < array_task_num; j++) { t_exec = task_main->next_task_array(TASK_EXEC,t_exec); - 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 + index*division_size, division_size); - //t_exec->set_outData(0,o_data + index*status_num, division_out_size); - //printf("%c",file_mmap[index*division_size]); t_exec->set_inData(0,&file_mmap[index*division_size], division_size); @@ -154,8 +151,8 @@ } - - + //printf("size %d\n",size); + while (size>0) { t_exec = manager->create_task(TASK_EXEC); @@ -170,6 +167,8 @@ size -= division_size; } + //printf("size %d\n", st_mmap.size - index*division_size); + t_print->spawn(); }
--- a/example/word_count/ppe/Exec.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/example/word_count/ppe/Exec.cc Sat Apr 24 15:24:33 2010 +0900 @@ -19,29 +19,26 @@ word_num -= word_flag; + for (i=0; i < length; i++) { //s->printf("[SPE%d]%c",id,i_data[i]); - - if((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { - //s->printf("文字 数 = %d\n", word_num + word_flag); - word_num += word_flag; - word_flag = 0; - } - - if (i_data[i] == 0x20) { - //printf("スペース\n"); - word_flag = 1; - } - - if (i_data[i] == 0x0A) { - //printf("改行\n"); - line_num += 1; - word_flag = 1; - } - + + if((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { + //s->printf("文字 数 = %d\n", word_num + word_flag); + word_num += word_flag; + word_flag = 0; + } else if (i_data[i] == 0x20) { + //printf("スペース\n"); + word_flag = 1; + } else if (i_data[i] == 0x0A) { + //printf("改行\n"); + line_num += 1; + word_flag = 1; + } + } - + word_num += word_flag; // printf("PPE word %d line %d\n",word_num,line_num);
--- a/example/word_count/ppe/Print.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/example/word_count/ppe/Print.cc Sat Apr 24 15:24:33 2010 +0900 @@ -26,8 +26,8 @@ } } - for (int i = status_num; i > 0; i--) { - s->printf("%llu ",word_data[i-1]); + for (int i = 0; i < status_num; i++) { + s->printf("%llu ",word_data[status_num - i - 1]); } s->printf("\n");
--- a/example/word_count/spe/Exec.cc Tue Apr 20 15:54:06 2010 +0900 +++ b/example/word_count/spe/Exec.cc Sat Apr 24 15:24:33 2010 +0900 @@ -11,8 +11,9 @@ { char *i_data = (char*)s->get_input(rbuf, 0); unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); - long length = (long)s->get_param(0); - long word_flag = 1-(long)s->get_param(1); + int length = (int)s->get_param(0); + int word_flag = 1-(int)s->get_param(1); + //int word_flag = (int)s->get_param(1); int word_num = 0; int line_num = 0; int i ; @@ -23,18 +24,14 @@ //s->printf("[SPE%d]%c",id,i_data[i]); - if((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { + if ((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { //s->printf("文字 数 = %d\n", word_num + word_flag); word_num += word_flag; word_flag = 0; - } - - if (i_data[i] == 0x20) { + } else if (i_data[i] == 0x20) { //printf("スペース\n"); word_flag = 1; - } - - if (i_data[i] == 0x0A) { + } else if (i_data[i] == 0x0A) { //printf("改行\n"); line_num += 1; word_flag = 1;