changeset 1581:8ee897303cd0 draft

fix multi_dimention
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Sat, 30 Mar 2013 18:29:54 +0900
parents 806b4658ced6
children 046695c73cb0
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/SpeThreads.h TaskManager/kernel/ppe/CpuThreads.cc TaskManager/kernel/ppe/CpuThreads.h TaskManager/kernel/ppe/HTask.cc TaskManager/kernel/ppe/HTask.h TaskManager/kernel/ppe/Threads.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h example/fft/main.cc
diffstat 10 files changed, 38 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Sat Mar 30 18:29:54 2013 +0900
@@ -239,7 +239,7 @@
 #ifdef TASK_LIST_MAIL
   	    // multi dimensionだったらカウントする 
             TaskListPtr list = (TaskListPtr)data;
-	    if (list->tasks[0].self->flag.dim_count-- == 0)
+	    if (list->self->flag.dim_count-- == 0)
 	        check_task_list_finish(schedTaskManager, list, waitTaskQueue);
 #else
             // 終了したタスク(PPEにあるのでアドレス)
--- a/TaskManager/Cell/SpeThreads.h	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/Cell/SpeThreads.h	Sat Mar 30 18:29:54 2013 +0900
@@ -27,6 +27,7 @@
     static void *spe_thread_run(void *arg);
     static void *frontend_thread_run(void *arg);
     void add_output_tasklist(int command, memaddr buff, int alloc_size);
+    void spawn_task(int cpu_num, TaskListPtr p);
 
 private:
     /* variables */
--- a/TaskManager/kernel/ppe/CpuThreads.cc	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.cc	Sat Mar 30 18:29:54 2013 +0900
@@ -104,14 +104,14 @@
 void
 CpuThreads::spawn_task(int cpu_num, TaskListPtr p) {
     if (p->dim>0) {
-      int dim_count = (x+1)*(y+1)*(z+1);
-      if (cpu_num > dim_count)
-        p->tasks[0].self->dim_count = cpu_num;
+        int dim_count = (p->x+1)*(p->y+1)*(p->z+1);
+        if (cpu_num > dim_count)
+            p->self->flag.dim_count = cpu_num;
         for (int i = 0; i < cpu_num; i++) {
-	  send_mail(i+1,1,(memaddr)&p);
+            send_mail(i+1,1,(memaddr*)p);
 	}
     } else {
-        send_mail(cpu_num,1,(memaddr)&p);
+        send_mail(cpu_num,1,(memaddr*)p);
     }
 }
 
--- a/TaskManager/kernel/ppe/CpuThreads.h	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.h	Sat Mar 30 18:29:54 2013 +0900
@@ -35,6 +35,7 @@
     virtual void add_output_tasklist(int command, memaddr buff, int alloc_size);
     virtual int is_gpu(int cpuid);
     virtual void set_NDRange(void *ndr);
+    virtual void spawn_task(int cpu_num,TaskListPtr p);
 private:
     /* variables */
     pthread_t *threads;
--- a/TaskManager/kernel/ppe/HTask.cc	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/ppe/HTask.cc	Sat Mar 30 18:29:54 2013 +0900
@@ -3,7 +3,6 @@
 #include "TaskManagerImpl.h"
 #include "strings.h"
 #include "rdtsc.h"
-#include "Dim.h"
 
 /*!
   manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ
@@ -164,7 +163,8 @@
     return next;
 }
 
-Task *get_nextTaskArea(Task *t, TaskList *tl) {
+Task *
+HTask::get_nextTaskArea(Task *t, TaskList *tl) {
     Task *next = t->next();
     if (next >= tl->last()) {
         tl->set_last(t);
--- a/TaskManager/kernel/ppe/HTask.h	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/ppe/HTask.h	Sat Mar 30 18:29:54 2013 +0900
@@ -59,12 +59,15 @@
 
     void spawn();
     void iterate(long x); // spawn x tasks with paramtor0 as index
+    void iterate(long x, long y); // spawn y tasks with paramtor1 as index
+    void iterate(long x, long y, long z); // spawn z tasks with paramtor2 as index
     void wait_for(HTask *);
     void set_cpu(CPU_TYPE type);
     void set_post(PostFunction func, void *read, void *write);
     Task *create_task_array(int task_id, int num_task, int num_param, int num_inData, int num_outData);
     Task *next_task_array(int task_id, Task *t);
     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);
 
     HTask *init(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) {
--- a/TaskManager/kernel/ppe/Threads.h	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/ppe/Threads.h	Sat Mar 30 18:29:54 2013 +0900
@@ -4,6 +4,7 @@
 #include <pthread.h>
 #include "base.h"
 #include "types.h"
+#include "TaskList.h"
 
 
 class Threads {
@@ -22,6 +23,7 @@
     virtual void add_output_tasklist(int command, memaddr buff, int alloc_size) = 0;
     virtual int is_gpu(int cpuid) { return 0; }
     virtual void set_NDRange(void* ndr)=0;
+    virtual void spawn_task(int cpu_num, TaskListPtr p) = 0;
     /* variables */
     pthread_t *threads;
     int cpu_num;
--- a/TaskManager/kernel/schedule/SchedTask.cc	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Sat Mar 30 18:29:54 2013 +0900
@@ -115,7 +115,7 @@
     void *read = get_input(readbuf, 0); void *write =  get_output(writebuf, 0);
     // set param (if exit dim )
     if (list->dim) {
-        multi_dimension(list, read, write);
+        multi_dimension(list, read, write,run);
     } else {
         run(this, read,write);
     }
@@ -129,25 +129,27 @@
 }
 
 void
-SchedTask::multi_dimension(TaskListPtr list, void* read, void* write,run) {
+SchedTask::multi_dimension(TaskListPtr list, void* read, void* write,TaskObjectRun run) {
     // 自分のidはSchedulerがわかる
     int x=0,y=0,z=0;
+    int cpu=0;
     for (;;) {
-      if (cpu==scheduler->cpu) {
-	if (list->dim>0) set_param(0,(memaddr)x);
-	if (list->dim>1) set_param(1,(memaddr)y);
-	if (list->dim>2) set_param(2,(memaddr)z);
-	  run(this, read,write);
-      }
-      if (++x>list->x) {
-	  x=0;
-  	  if (++y>list->y) {
-	    y=0;
-	      if (++z>list->z) {
-		break;		
-	      }
-	  }
-	  cpu++;
+        if (cpu==scheduler->id) {
+            if (list->dim>0) atask->set_param(1,(memaddr)x);
+            if (list->dim>1) atask->set_param(1,(memaddr)y);
+            if (list->dim>2) atask->set_param(2,(memaddr)z);
+            run(this, read,write);
+        }
+        if (++x>list->x) {
+            x=0;
+            if (++y>list->y) {
+                y=0;
+                if (++z>list->z) {
+                    break;		
+                }
+            }
+            cpu++;
+        }
     }
 }
 
--- a/TaskManager/kernel/schedule/SchedTask.h	Fri Mar 29 19:32:58 2013 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.h	Sat Mar 30 18:29:54 2013 +0900
@@ -73,7 +73,6 @@
     void wait_segment(MemorySegment *s);
 
 
-
     void *allocate(int size);
     void free_(void *p) ;
     void free_htask(HTask *p) ;
@@ -128,8 +127,8 @@
 
     int printf(const char * format, ...);
 
-
-
+    void multi_dimension(TaskListPtr list, void* read, void* write, TaskObjectRun run);
+    
 } ;
 
 
--- a/example/fft/main.cc	Fri Mar 29 19:32:58 2013 +0900
+++ b/example/fft/main.cc	Sat Mar 30 18:29:54 2013 +0900
@@ -103,7 +103,7 @@
             brev->spawn();
         }
     }
-    
+    exit(0);
     HTask* bfly;
     setWorkSize(gws,lws,n[0]/2,n[0]);
 
@@ -219,7 +219,7 @@
         sfac->nd_range();
         sfac->spawn();
     }
-    // Butterfly Operation 
+    // Butterfly Operation
     fftCore(manager, rm, xm, wm, m[0], forward);
     
     HTaskPtr *trns = (HTask**)manager->allocate(sizeof(HTask*)*2);