changeset 1762:b53d197ec03d draft

copy task list for multi dimention
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 23 Nov 2013 00:18:59 +0900
parents 141174033f1a
children be15a4d33605
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/CellTaskManagerImpl.h TaskManager/ChangeLog TaskManager/kernel/ppe/CpuThreads.cc TaskManager/kernel/ppe/TaskList.cc TaskManager/test/UtilizationTest/multiply
diffstat 6 files changed, 54 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Fri Nov 22 13:56:37 2013 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Sat Nov 23 00:18:59 2013 +0900
@@ -94,13 +94,14 @@
             htask = activeTaskQueue->getNext(htask);
         }  else {
             if (htask->cpu_type == SPE_ANY) {
-                speid = cur_anySpeid++ % machineNum;
-                // cpu があれば cpu に割り振る
-                if (machineNum != gpuNum && speid < gpuNum) speid = gpuNum;
+                if (cpu_num!=0) 
+                    speid = (cur_anySpeid++ % cpu_num) + id_offset;
+                else
+                    speid = (cur_anySpeid++ % gpuNum) ; // gpu があれば gpu に割り振る
 #ifdef __CERIUM_GPU__
             } else if (gpuNum == 0 && htask->cpu_type < (int)SPE_0) {
                 // gpu = 0 で gpu を指定されたときには cpu で実行する
-                speid = cur_anySpeid++ % machineNum;
+                speid = cur_anySpeid++ % machineNum + id_offset ;
             } else if (htask->cpu_type < GPU_0+gpuNum) {
                 speid = htask->cpu_type - (int)(GPU_0);
 #endif
@@ -113,18 +114,32 @@
                 // 配列的 (SPE0 = arr[0], SPE1 = arr[1]) にするため
                 speid = htask->cpu_type - CPU_SPE - 1 + gpuNum;
                 if (speid >= gpuNum && machineNum == gpuNum) {
-                    speid = cur_anySpeid++ % machineNum;
+                    // SPE specified but no CPU
+                    speid = (cur_anySpeid++ % gpuNum) ; 
                 } else if (speid < gpuNum && gpuNum == 0) {
-                    speid = cur_anySpeid++ % machineNum;
+                    // GPU specified but no GPU
+                    speid = cur_anySpeid++ % machineNum + id_offset ;
                 }
             }
-            
-            set_taskList(htask, taskListInfo[speid]);
+            int dim ; 
+            if ( (dim = ((TaskList*)(htask->rbuf))->ismultidim() ) && speid >= id_offset )  {
+                // multi dimenstion task on CPU will be copied to all CPU
+                for(int i=1; i < dim && i < cpu_num ; i++ ) {
+                    TaskList *tl =  (TaskList*)(htask->rbuf);
+                    while(tl) {
+                        TaskListPtr dm = createTaskList();
+                        memcpy(tl,dm, ((memaddr)dm->last()) - (memaddr(dm)));
+                        taskListInfo[i+id_offset]->addLast(dm);
+                        tl = tl->next;
+                    }
+                }
+                set_taskList(htask, taskListInfo[0+id_offset]);
+            } else
+                set_taskList(htask, taskListInfo[speid]);
             
             HTaskPtr next = activeTaskQueue->getNext(htask);
             activeTaskQueue->remove(htask);
             htask = next;
-            
         }
     }
 }
@@ -237,17 +252,12 @@
     memaddr data;
 
     // SPE Scheduler からの mail check
-     mail:while (speThreads->has_mail(id,1,&data)) {
+     while (speThreads->has_mail(id,1,&data)) {
         if (data == (memaddr) MY_SPE_STATUS_READY) {
             //  MY_SPE_STATUS_READY: SPE が持ってた Task 全て終了
             // freeAll する前に循環リストに戻す
             spe_running--;
             if (!speTaskList[id]->empty()) {
-                // multi_dimension がすべて終わるまで speTaskList をフリーすることはできない
-                for(TaskListPtr list = speTaskList[id]->getFirst();list;list=list->next) {
-                    if (list->self->flag.dim_count>0)
-                        goto mail;
-                }
                 speTaskList[id]->getLast()->next = speTaskList[id];
                 speTaskList[id]->freeAll();
             }
@@ -259,7 +269,7 @@
             continue;
         } else {
 #ifdef TASK_LIST_MAIL
-            // multi dimensionだったらカウントする 
+            // multi dimensionだったらcount downする 
             TaskListPtr list = (TaskListPtr)data;
             if (--list->self->flag.dim_count == 0)
                 check_task_list_finish(schedTaskManager, list, waitTaskQueue);
--- a/TaskManager/Cell/CellTaskManagerImpl.h	Fri Nov 22 13:56:37 2013 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.h	Sat Nov 23 00:18:59 2013 +0900
@@ -12,10 +12,15 @@
 class CellTaskManagerImpl : public TaskManagerImpl {
 public:
     /* constructor */
- CellTaskManagerImpl(int num, int gpu, Threads *cpus) : TaskManagerImpl(num) {gpuNum = gpu; speThreads = cpus;}
+    CellTaskManagerImpl(int num, int gpu, Threads *cpus) : TaskManagerImpl(num) {
+         gpuNum = gpu; speThreads = cpus; cpu_num = num; id_offset = gpu ;
+    }
     ~CellTaskManagerImpl();
 
     /* variables */
+    int cpu_num;
+    int id_offset;
+
     QueueInfo<TaskList> **taskListInfo;
     QueueInfo<TaskList> **speTaskList;  // running task
 
--- a/TaskManager/ChangeLog	Fri Nov 22 13:56:37 2013 +0900
+++ b/TaskManager/ChangeLog	Sat Nov 23 00:18:59 2013 +0900
@@ -1,3 +1,21 @@
+2013-11-22 Shinji kONO <kono@ie.u-ryukyu.ac.jp>
+
+	Multi Dimention の実装がよろしくない。複雑過ぎる。
+
+	    Cpu tasklist を無視して全員に送る
+	    Cpu 側では自分以外のtaskは無視する ( tasklist 上に cpu が書いてある)
+	    終わったら tasklist 上で count down する
+	    count down が 0 になったら、waiting queue から削除する
+	    それまでは、他のCPUも止まる 
+	    MD と非MDが同じ tasklist に混じってしまうと動作がおかしい
+
+	新しい実装?
+	    MDtask はcopy して、すべてのCpu tasklist に入れる
+	    spawn task でのすべてのCPUへの送信は廃止
+	    終わったら HTask 上で count down する
+	    count down が 0 になったら、waiting queue から削除する
+
+
 2012-9-5 Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
 
 	set_cpu(SPE_ANY)
--- a/TaskManager/kernel/ppe/CpuThreads.cc	Fri Nov 22 13:56:37 2013 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.cc	Sat Nov 23 00:18:59 2013 +0900
@@ -104,27 +104,9 @@
 
 int
 CpuThreads::spawn_task(int id, TaskListPtr p) {
-    p->self->flag.dim_count = 1; // always dim_count set min cpu. min cpu is 1.
     p->cpu = id - id_offset;
-    int dim_count = 0;
-    if ((dim_count = p->ismultidim()) && id >= id_offset) { 
-        // emulate ND_range in cpu
-        if (cpu_num < dim_count) {
-            dim_count = cpu_num;
-        }
-
-
-        // p may contains non multi_dimensional tasks,
-        // SchedTask skip these using p->cpu
-        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;
-    }
+    send_mail(id, 1, (memaddr*)&p);
+    return 1;
 }
 
 /**
--- a/TaskManager/kernel/ppe/TaskList.cc	Fri Nov 22 13:56:37 2013 +0900
+++ b/TaskManager/kernel/ppe/TaskList.cc	Sat Nov 23 00:18:59 2013 +0900
@@ -13,7 +13,8 @@
             dim_count = (p->x)*(p->y)*(p->z);
             if (dim_count_max < dim_count) dim_count_max = dim_count;
             p->self->flag.dim_count = dim_count;
-        }
+        } else 
+            p->self->flag.dim_count = 1;
         p = p->next;
     } 
     return dim_count_max;
Binary file TaskManager/test/UtilizationTest/multiply has changed