changeset 1639:9126622f75df draft

fix spe_running
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 18 Jun 2013 18:43:24 +0900
parents a0014faececa
children 30c1f43493db
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/kernel/ppe/CpuThreads.cc TaskManager/kernel/ppe/CpuThreads.h TaskManager/kernel/ppe/Threads.h example/multiply/main.cc
diffstat 5 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Jun 18 13:18:37 2013 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Jun 18 18:43:24 2013 +0900
@@ -138,7 +138,6 @@
         if (!taskListInfo[id]->empty()) {
             // SPE に送る TaskList の準備
             send_taskList(id);
-            spe_running++;
         }
     }
 }
@@ -242,8 +241,10 @@
         if (data == (memaddr) MY_SPE_STATUS_READY) {
             //  MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
             // freeAll する前に循環リストに戻す
-            speTaskList[id]->getLast()->next = speTaskList[id];
-            speTaskList[id]->freeAll();
+            if (!speTaskList[id]->empty()) {
+                speTaskList[id]->getLast()->next = speTaskList[id];
+                speTaskList[id]->freeAll();
+            }
             spe_running--;
             // printf("SPE %d status ready, %d running\n",id, spe_running);
         } else if (data == (memaddr) MY_SPE_COMMAND_MALLOC) {
@@ -350,8 +351,8 @@
     // printf("SPE %d task list sending\n",id);
 
     // speThreads->send_mail(id, 1, p);
-    speThreads->spawn_task(id, p);
-
+    int run = speThreads->spawn_task(id, p);
+    spe_running += run;
     // printf("SPE %d task list sent\n",id);
 }
 
--- a/TaskManager/kernel/ppe/CpuThreads.cc	Tue Jun 18 13:18:37 2013 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.cc	Tue Jun 18 18:43:24 2013 +0900
@@ -102,7 +102,7 @@
     }
 }
 
-void
+int
 CpuThreads::spawn_task(int id, TaskListPtr p) {
     p->self->flag.dim_count = 1; // always dim_count set min cpu. min cpu is 1.
 
@@ -114,13 +114,14 @@
         }
 
         p->self->flag.dim_count = dim_count;
-
-        for (int i = 0; i < dim_count; i++) {
+        int i;
+        for (i = 0; i < dim_count; i++) {
             send_mail(i+id_offset,1,(memaddr*)&p);
         }
-
+        return i;
     } else {
         send_mail(id, 1, (memaddr*)&p);
+        return 1;
     }
 }
 
--- a/TaskManager/kernel/ppe/CpuThreads.h	Tue Jun 18 13:18:37 2013 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.h	Tue Jun 18 18:43:24 2013 +0900
@@ -36,7 +36,7 @@
     virtual void send_mail(int speid, int num, memaddr *data); // BLOCKING
     virtual void add_output_tasklist(int command, memaddr buff, int alloc_size);
     virtual int is_gpu(int cpuid);
-    virtual void spawn_task(int cpu_num,TaskListPtr p);
+    virtual int spawn_task(int cpu_num,TaskListPtr p);
 
 private:
     /* variables */
--- a/TaskManager/kernel/ppe/Threads.h	Tue Jun 18 13:18:37 2013 +0900
+++ b/TaskManager/kernel/ppe/Threads.h	Tue Jun 18 18:43:24 2013 +0900
@@ -22,7 +22,7 @@
     virtual void send_mail(int speid, int num, memaddr *data) = 0; // BLOCKING
     virtual void add_output_tasklist(int command, memaddr buff, int alloc_size) = 0;
     virtual int is_gpu(int cpuid) { return 0; }
-    virtual void spawn_task(int cpu_num, TaskListPtr p) = 0;
+    virtual int spawn_task(int cpu_num, TaskListPtr p) = 0;
     /* variables */
     pthread_t *threads;
     int cpu_num;
--- a/example/multiply/main.cc	Tue Jun 18 13:18:37 2013 +0900
+++ b/example/multiply/main.cc	Tue Jun 18 18:43:24 2013 +0900
@@ -8,8 +8,9 @@
 extern void task_init(void);
 static int task = 1;
 static int length = DATA_NUM;
-CPU_TYPE spe_cpu = SPE_ANY;
+static CPU_TYPE spe_cpu = SPE_ANY;
 const char *usr_help_str = "Usage: ./multiply \n";
+static int print_flag = 0;
 void TMend(TaskManager *);
 
 float *A,*B,*C;
@@ -39,9 +40,11 @@
 static void
 print_result() {
     printf("---\n");
+
     for (int i =0;i<length;i++) {
         printf("%f * %f = %f \n",A[i],B[i],C[i]);
     }
+        
     printf("---\n");
 }
 
@@ -53,6 +56,8 @@
             length = atoi(argv[++i]);
         } else if (strcmp(argv[i], "-t") == 0) {
             task = atoi(argv[++i]);
+        } else if (strcmp(argv[i], "-p") == 0) {
+            print_flag = 1;
         }
     }
 }