changeset 664:7405d92733a8

word count
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 03 Dec 2009 00:20:28 +0900
parents 8a807e2f64f8
children 4470ff271c5a
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/spe/SpeTaskManagerImpl.h TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/Makefile.cell TaskManager/Makefile.def TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/schedule/Scheduler.cc example/word_count/ppe/Exec.cc example/word_count_test/Makefile.def example/word_count_test/main.cc example/word_count_test/ppe/Exec.cc example/word_count_test/ppe/task_init.cc example/word_count_test/spe/Exec.cc
diffstat 13 files changed, 46 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -30,7 +30,7 @@
 {
     spe_running = 0;
     taskListImpl = new CellTaskListInfo;
-    taskListImpl->init(machineNum*2);
+    taskListImpl->init(16);
 
     activeTaskQueue = new HTaskInfo();
 
--- a/TaskManager/Cell/spe/SpeTaskManagerImpl.h	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/Cell/spe/SpeTaskManagerImpl.h	Thu Dec 03 00:20:28 2009 +0900
@@ -8,6 +8,8 @@
 class SpeTaskManagerImpl : public TaskManagerImpl {
 public:
     /* constructor */
+    BASE_NEW_DELETE(SpeTaskManagerImpl);
+
     SpeTaskManagerImpl() ;
     ~SpeTaskManagerImpl();
 
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -78,9 +78,9 @@
 {
     TaskListPtr list, list_top;
 #ifdef SIMPLE_TASK
-    TaskPtr task; // Task (SPE に送る Task)
+    SimpleTaskPtr task; // Task (SPE に送る Task)
 #else
-    SimpleTaskPtr task; // Task (SPE に送る Task)
+    TaskPtr task; // Task (SPE に送る Task)
 #endif
 
     if (activeTaskQueue->empty()) {
--- a/TaskManager/Makefile.cell	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/Makefile.cell	Thu Dec 03 00:20:28 2009 +0900
@@ -35,7 +35,7 @@
 
 EXTRA_CFLAGS = -D__CERIUM_CELL__ -DHAS_POSIX_MEMALIGN -fno-strict-aliasing
 
-SPE_CFLAGS = -g $(SIMPLE_TASK) -D__CERIUM_CELL__ -fno-exceptions -fno-rtti -Wall  -O9
+SPE_CFLAGS =  $(SIMPLE_TASK) -D__CERIUM_CELL__ -fno-exceptions -fno-rtti -Wall $(OPT) 
 
 all: default
 
--- a/TaskManager/Makefile.def	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/Makefile.def	Thu Dec 03 00:20:28 2009 +0900
@@ -32,8 +32,11 @@
 # SIMPLE_TASK=-DSIMPLE_TASK
 SIMPLE_TASK=
 
+# OPT = -O9
+OPT =  -g
+
 CC     = g++   
-CFLAGS = $(SIMPLE_TASK) -Wall `sdl-config --cflags` -g -m$(ABIBIT)   -O9 
+CFLAGS = $(SIMPLE_TASK) -Wall `sdl-config --cflags` -m$(ABIBIT)   $(OPT)
 LIBS   =  -m$(ABIBIT)
 
 INCLUDE = -I../include/TaskManager
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -126,7 +126,10 @@
 void
 TaskManagerImpl::set_task_cpu(HTaskPtr task, CPU_TYPE type)
 {
-    task->cpu_type = type;
+    if (machineNum==0)
+	task->cpu_type = CPU_PPE ;
+    else
+	task->cpu_type = type;
 }
 
 /**
--- a/TaskManager/kernel/schedule/Scheduler.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -18,6 +18,13 @@
     delete connector;
 }
 
+static int 
+null_run(SchedTask* smanager, void* r, void *w)
+{
+    printf("Calling Undefined Task\n");
+    return 0;
+}
+
 /*! @brief speTaskの入出力のパイプラインバッファを確保する
  */
 
@@ -25,6 +32,11 @@
 Scheduler::init(TaskManagerImpl *m)
 {
     hash = 0;
+
+    for (int i = 0; i< MAX_TASK_OBJECT; i++) {
+	task_list[0].run = null_run;
+    }
+
     set_manager(m);
     init_impl();
 
--- a/example/word_count/ppe/Exec.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/example/word_count/ppe/Exec.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -56,7 +56,7 @@
 
     word_num += word_flag;
 
-    //printf("%d %d\n",word_num,line_num);
+    // printf("PPE word %d line %d\n",word_num,line_num);
 
     o_data[0] = (unsigned long long)word_num;
     o_data[1] = (unsigned long long)line_num;
--- a/example/word_count_test/Makefile.def	Wed Dec 02 22:20:32 2009 +0900
+++ b/example/word_count_test/Makefile.def	Thu Dec 03 00:20:28 2009 +0900
@@ -8,7 +8,7 @@
 CERIUM = ../../../Cerium
 
 CC      = g++
-CFLAGS  = -g -Wall -O9
+CFLAGS  = -g -Wall # -O9
 
 INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
 LIBS = -L${CERIUM}/TaskManager
--- a/example/word_count_test/main.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/example/word_count_test/main.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -26,6 +26,7 @@
     int task_num;         // remaining task count
     int task_blocks;      // spawn task one at a time
     int status_num; 
+    int task_spwaned;
     unsigned long long *o_data;
     unsigned long long *head_tail_flag;
     int pad; 
@@ -83,8 +84,10 @@
 static void
 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) 
 {
-    for (int i = 0; i < task_count && w->size >= w->division_size; i++) {
+    for (int j = 0; j < task_count && w->size>0; j++) {
+	int i = w->task_spwaned++;
 	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);
@@ -97,18 +100,19 @@
     }
 }
 
-SchedDefineTask1(RUN_TASK_16,run16);
+SchedDefineTask1(RUN_TASK_BLOCKS,run16);
 
 static int
 run16(SchedTask *manager, void *in, void *out)
 {
-    WordCount *w = (WordCount *)manager->get_param(1);
+    WordCount *w = (WordCount *)manager->get_param(0);
    
     if (w->task_num < w->task_blocks) {
-	if (w->size > w->division_size) 
+	if (w->size >= w->division_size) 
 	    run_tasks(manager,w,w->task_blocks, w->t_print, w->division_size);
-	if (w->size>0 && w->size < w->division_size) 
+	while (w->size>0) 
 	    run_tasks(manager,w,1, w->t_print, w->size);
+	// printf("run16 last %d\n",w->task_num);
     } else {
 
 	HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS);
@@ -118,6 +122,7 @@
 	run_tasks(manager,w, w->task_blocks, t_next, w->division_size);
 
 	t_next->spawn();
+	// printf("run16 next %d\n",w->task_num);
     }
     return 0;
 }
@@ -133,8 +138,10 @@
     st_mmap_t st_mmap;
     st_mmap = my_mmap(filename);
     WordCount *w = (WordCount*)manager->allocate(sizeof(WordCount));
+    // bzero(w,sizeof(WordCount));
 
     w->task_blocks = blocks;
+    w->task_spwaned = 0;
 
     /*sizeはdivision_sizeの倍数にしている。*/
     w->size = st_mmap.size;
@@ -163,9 +170,11 @@
     /* out用のデータのサイズ。*/
     int out_size = w->division_out_size*out_task_num;
     w->o_data = (unsigned long long*)manager->allocate(out_size);
+    //bzero(w->o_data,out_size);
 
     w-> pad = 2;
     w->head_tail_flag = (unsigned long long*)manager->allocate(out_size);
+    // bzero(w->head_tail_flag,out_size);
 
     printf("out size %d\n",out_size);
 
--- a/example/word_count_test/ppe/Exec.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/example/word_count_test/ppe/Exec.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -62,7 +62,7 @@
     //printf("last word %c",i_data[i-1]);
     head_tail_flag[1] = (i_data[i-1] != 0x20) && (i_data[i-1] != 0x0A);
 
-    //s->printf("%d %d\n",word_num,line_num);
+    // s->printf("PPE word %d line %d\n",word_num,line_num);
 
     o_data[0] = (unsigned long long)word_num;
     o_data[1] = (unsigned long long)line_num;
--- a/example/word_count_test/ppe/task_init.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/example/word_count_test/ppe/task_init.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -4,6 +4,7 @@
 /* 必ずこの位置に書いて */
 SchedExternTask(Print);
 SchedExternTask(Exec);
+SchedExternTask(RUN_TASK_BLOCKS);
 SchedExternTask(RunFinish);
 
 /**
@@ -16,5 +17,6 @@
 {
     SchedRegisterTask(TASK_PRINT, Print);
     SchedRegisterTask(TASK_EXEC, Exec);
+    SchedRegister(RUN_TASK_BLOCKS);
     SchedRegisterTask(RUN_FINISH, RunFinish);
 }
--- a/example/word_count_test/spe/Exec.cc	Wed Dec 02 22:20:32 2009 +0900
+++ b/example/word_count_test/spe/Exec.cc	Thu Dec 03 00:20:28 2009 +0900
@@ -71,7 +71,7 @@
     //printf("last word %c",i_data[i-1]);
     head_tail_flag[1] = (i_data[i-1] != space[i%4]) && (i_data[i-1] != newline[i%4]);
 
-    //s->printf("%d %d\n",word_num,line_num);
+    s->printf("SPU word %d line %d\n",word_num,line_num);
 
     o_data[0] = (unsigned long long)word_num;
     o_data[1] = (unsigned long long)line_num;