changeset 948:6a8941ee8294

fix word count
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 02 Aug 2010 09:36:02 +0900
parents a468a9784e87
children 86aea6affe6c
files example/word_count/Func.h example/word_count/main.cc example/word_count/ppe/task_init.cc
diffstat 3 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/example/word_count/Func.h	Sun Aug 01 21:06:49 2010 +0900
+++ b/example/word_count/Func.h	Mon Aug 02 09:36:02 2010 +0900
@@ -3,7 +3,6 @@
     TASK_EXEC,
     RUN_TASK_BLOCKS,
     TASK_PRINT,
-    RUN_FINISH,
 };
 
 #define DATA_NUM 12
--- a/example/word_count/main.cc	Sun Aug 01 21:06:49 2010 +0900
+++ b/example/word_count/main.cc	Mon Aug 02 09:36:02 2010 +0900
@@ -79,6 +79,7 @@
   int array_task_num = 8;
   if (task_count < array_task_num) {
     array_task_num = task_count;
+    if (task_count<=0) return;
   }
   
   for (int i = 0; i < task_count; i += array_task_num) {
@@ -90,7 +91,7 @@
     }
     
     Task *t_exec = 0;
-    HTask *h_exec;
+    HTask *h_exec = 0;
     for (int j = 0; j < array_task_num; j++) {
 	int i = w->task_spwaned++;
 	if (use_task_array) {
@@ -113,7 +114,7 @@
 	w->size -= size;
 	w->task_num--;
     }
-    if (!use_task_array) {
+    if (use_task_array) {
 	task_array->spawn_task_array(t_exec->next());
 	task_array->set_cpu(SPE_ANY);
 	task_array->spawn();
@@ -141,7 +142,7 @@
 	while (w->size>0) 
 	    run_tasks(manager,w,1, w->t_print, w->size);
 	// printf("run16 last %d\n",w->task_num);
-    } else {
+    } else if (w->task_num > 0 ) {
 	HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS,
 	    (memaddr)&w->self,sizeof(memaddr),0,0);
 	w->t_print->wait_for(t_next);
--- a/example/word_count/ppe/task_init.cc	Sun Aug 01 21:06:49 2010 +0900
+++ b/example/word_count/ppe/task_init.cc	Mon Aug 02 09:36:02 2010 +0900
@@ -5,7 +5,6 @@
 SchedExternTask(Print);
 SchedExternTask(Exec);
 SchedExternTask(RUN_TASK_BLOCKS);
-SchedExternTask(RunFinish);
 
 /**
  * この関数は ../spe/spe-main と違って
@@ -18,5 +17,4 @@
     SchedRegisterTask(TASK_PRINT, Print);
     SchedRegisterTask(TASK_EXEC, Exec);
     SchedRegister(RUN_TASK_BLOCKS);
-    SchedRegisterTask(RUN_FINISH, RunFinish);
 }