changeset 1678:9ceb824e9be1 draft

fix TaskArray last().
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 04 Aug 2013 01:58:09 +0900
parents 3a57dd6e4cb5
children ff43dc274ec9
files TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/HTask.h example/word_count/main.cc
diffstat 3 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/HTask.cc	Sat Aug 03 21:17:38 2013 +0900
+++ b/TaskManager/kernel/ppe/HTask.cc	Sun Aug 04 01:58:09 2013 +0900
@@ -176,8 +176,8 @@
         return task;
     }
     Task *next=get_nextTaskArea(t,tl);
+    next->init(id, param_count, inData_count, outData_count);
     last = next->next();
-    next->init(id, param_count, inData_count, outData_count);
     return next;
 }
 
@@ -207,5 +207,24 @@
 {
 }
 
+int
+HTask::task_count()
+{
+    TaskList *tl = (TaskList*)rbuf;
+
+    int count = 0;
+    while(tl->prev) tl=tl->prev;
+    while(tl) {
+        Task *t = &tl->tasks[0];
+        for( ; t < tl->last() ; t = t->next()) {
+            count++;
+        }
+
+        TaskListPtr next = tl->next;
+        tl = next;
+    }
+    return count;
+}
+
 
 /* end */
--- a/TaskManager/kernel/ppe/HTask.h	Sat Aug 03 21:17:38 2013 +0900
+++ b/TaskManager/kernel/ppe/HTask.h	Sun Aug 04 01:58:09 2013 +0900
@@ -69,6 +69,7 @@
     Task *next_task_array(int id, Task *t, int param_count, int inData_count, int outData_count);
     Task *get_nextTaskArea(Task* t, TaskList* tl);
     void spawn_task_array(Task *t);
+    int  task_count();
 
     HTask *init(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) {
         init(cmd);
--- a/example/word_count/main.cc	Sat Aug 03 21:17:38 2013 +0900
+++ b/example/word_count/main.cc	Sun Aug 04 01:58:09 2013 +0900
@@ -198,6 +198,7 @@
     if (use_task_creater) {
         simple_task_creater(w->file_size, w->division_out_size * w->task_num, TASK_EXEC, w->division_size, w->division_out_size,
                             w->file_mmap, w->o_data, manager, w->t_print, 0);
+        return;
     }
 
     if (use_task_array) {
@@ -293,7 +294,7 @@
 
         HTask *h_exec = 0;
         for (int j = 0; j < array_task_num; j++) {
-            int i = w->task_spwaned++;
+            int a = w->task_spwaned++;
             if (w->size < size) size = w->size;
             int length = size/sizeof(char);
             if (size==0) break;
@@ -301,8 +302,8 @@
             if (use_compat) {
                 h_exec = manager->create_task(TASK_EXEC);
                 h_exec->set_param(0,(memaddr)length);
-                h_exec->set_inData(0,w->file_mmap + i*w->division_size, size);
-                h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size);
+                h_exec->set_inData(0,w->file_mmap + a*w->division_size, size);
+                h_exec->set_outData(0,w->o_data + a*w->out_size, w->division_out_size);
 
 
                 if (all) {
@@ -316,8 +317,8 @@
 
             } else {
                 h_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);
+                                              (memaddr)(w->file_mmap + a*w->division_size), size,
+                                              (memaddr)(w->o_data + a*w->out_size), w->division_out_size);
 
                 if (all) {
                     w->t_print->wait_for(h_exec);