changeset 496:58240647b23b

PS3 double linked TaskQueue worked.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 10 Oct 2009 20:32:55 +0900
parents 17319af4ee39
children 9d225ba0c34f
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/CellTaskManagerImpl.h TaskManager/Cell/spe/CellScheduler.cc TaskManager/Test/test_render/Makefile TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/ppe/TaskManagerImpl.h TaskManager/kernel/ppe/TaskQueueInfo.h example/task_queue/main.cc example/task_queue/main.h example/task_queue/spe/Hello.cc example/task_queue/spe/spe-main.cc
diffstat 11 files changed, 72 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Sat Oct 10 20:32:55 2009 +0900
@@ -27,8 +27,7 @@
 void
 CellTaskManagerImpl::init(void)
 {
-    taskQueueImpl = new TaskQueueInfo;
-    taskQueueImpl->init(TASK_MAX_SIZE*4);
+    taskQueueImpl = new TaskQueueInfo();
 
     taskListImpl = new CellTaskListInfo;
     taskListImpl->init(machineNum*2);
@@ -60,12 +59,12 @@
 }
 
 void
-CellTaskManagerImpl::append_activeTask(HTaskPtr task)
+CellTaskManagerImpl::append_activeTask(TaskQueuePtr q)
 {
+    HTask *task = (HTask *) q->task;
     if (task->cpu_type == CPU_PPE) {
-        ppeManager->append_activeTask(task);
+        ppeManager->append_activeTask(q);
     } else {
-	TaskQueuePtr q = taskQueueImpl->create(task);
         activeTaskQueue->addLast(q);
     }
 }
--- a/TaskManager/Cell/CellTaskManagerImpl.h	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.h	Sat Oct 10 20:32:55 2009 +0900
@@ -25,7 +25,7 @@
     void run(void);
     TaskListPtr mail_check(MailQueuePtr mail_list);
     void set_runTaskList(void);
-    void append_activeTask(HTaskPtr);
+    void append_activeTask(TaskQueuePtr);
 
     // user
     int add_data(ListDataPtr, uint32, int);
--- a/TaskManager/Cell/spe/CellScheduler.cc	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/Cell/spe/CellScheduler.cc	Sat Oct 10 20:32:55 2009 +0900
@@ -77,7 +77,7 @@
     // int i = (count++ % 2);
     // return TEX_LOAD1*i + TEX_LOAD2*(1-i);
     //     0,1,2,3
-    return TEX_LOAD1+(count++ % 4);
+    return TEX_LOAD1+(count++ % 2);
 }
 
 
--- a/TaskManager/Test/test_render/Makefile	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile	Sat Oct 10 20:32:55 2009 +0900
@@ -33,7 +33,7 @@
 	perl tools/create_sglist.pl xml_file/*.xml 
 
 run-ps3:
-	/usr/sbin/ps3-video-mode -v 133
+	/usr/*bin/ps3-video-mode -v 133
 	./test_nogl -video fb -width 1920 -height 1080 $(CPU) $(SG)
 
 run-ps3tv:
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc	Sat Oct 10 20:32:55 2009 +0900
@@ -38,7 +38,8 @@
     //   systask_finish->wait_for(systask_finish);
     // とかなって無限ループになるので、
     // これだけは明示的に append_waitTask() で
-    append_waitTask(systask_finish);
+    TaskQueuePtr q = taskQueueImpl->create(systask_finish);
+    append_waitTask(q);
 }
 
 HTaskPtr
@@ -81,10 +82,11 @@
 {
     // waiter // master
     // waitee // slave
+    TaskQueuePtr q = taskQueueImpl->create(task);
     if (task->wait_i->empty()) {
-        append_activeTask(task);
+        append_activeTask(q);
     } else {
-        append_waitTask(task);
+        append_waitTask(q);
     }
 
     systask_finish->wait_for(task);
@@ -94,9 +96,8 @@
  * Task を実行可能キューに追加する
  */
 void
-TaskManagerImpl::append_activeTask(HTaskPtr task)
+TaskManagerImpl::append_activeTask(TaskQueuePtr q)
 {
-    TaskQueuePtr q = taskQueueImpl->create(task);
     activeTaskQueue->addLast(q);
 }
 
@@ -138,9 +139,8 @@
 
 
 void
-TaskManagerImpl::append_waitTask(HTaskPtr task)
+TaskManagerImpl::append_waitTask(TaskQueuePtr q)
 {
-    TaskQueuePtr q = taskQueueImpl->create(task);
     waitTaskQueue ->addLast(q);
 }
 
@@ -157,7 +157,7 @@
         if (task->wait_i->empty()) {
 	    TaskQueuePtr next = waitTaskQueue->getNext(p);
 	    waitTaskQueue->remove(p);
-	    activeTaskQueue->addLast(p);
+	    append_activeTask(p);
 	    p = next;
         } else {
 	    p = waitTaskQueue->getNext(p);
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskManagerImpl.h	Sat Oct 10 20:32:55 2009 +0900
@@ -31,8 +31,8 @@
     // system
     virtual void init() = 0;
     virtual void run() = 0;
-    virtual void append_activeTask(HTaskPtr);
-    virtual void append_waitTask(HTaskPtr);
+    virtual void append_activeTask(TaskQueuePtr);
+    virtual void append_waitTask(TaskQueuePtr);
 
     void check_task_finish(HTaskPtr task);
     void wakeup_waitTask();
--- a/TaskManager/kernel/ppe/TaskQueueInfo.h	Sat Oct 10 19:16:09 2009 +0900
+++ b/TaskManager/kernel/ppe/TaskQueueInfo.h	Sat Oct 10 20:32:55 2009 +0900
@@ -27,7 +27,7 @@
     TaskQueue* get(int index);
     TaskQueue* find(Task *task);
     int empty();
-    void TaskQueueInfo::freePool() ;
+    void freePool() ;
 
     // Iterator
     TaskQueue* getNext(TaskQueue* q) ;
--- a/example/task_queue/main.cc	Sat Oct 10 19:16:09 2009 +0900
+++ b/example/task_queue/main.cc	Sat Oct 10 20:32:55 2009 +0900
@@ -75,7 +75,7 @@
 	 *   SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY
 	 *   if you do not call this, execute PPE.
 	 */
-	// hello->set_cpu(SPE_ANY);
+	hello->set_cpu(SPE_ANY);
 
 	/**
 	 * Set 32bits parameter
--- a/example/task_queue/main.h	Sat Oct 10 19:16:09 2009 +0900
+++ b/example/task_queue/main.h	Sat Oct 10 20:32:55 2009 +0900
@@ -5,6 +5,7 @@
 
 typedef struct queues {
     int i;
+    int j;
     TaskManager *m;
     TaskQueueInfo *q[MAX_QUEUE];
 } Queues, *QueuePtr;
--- a/example/task_queue/spe/Hello.cc	Sat Oct 10 19:16:09 2009 +0900
+++ b/example/task_queue/spe/Hello.cc	Sat Oct 10 20:32:55 2009 +0900
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include "Hello.h"
 #include "Func.h"
+#include "main.h"
 
 /* これは必須 */
 SchedDefineTask(Hello);
@@ -12,5 +13,43 @@
 
     smanager->printf("[%d] Hello, World!!\n", task_id);
 
+    QueuePtr q = (QueuePtr )smanager->global_get(0);
+
+    for(int i=0;i<100;i++) {
+        TaskQueueInfo *i0 = q->q[i%MAX_QUEUE];
+        TaskQueueInfo *i1 = q->q[(i+1)%MAX_QUEUE];
+        TaskQueue *q0;
+        TaskQueue *q1;
+
+        // switch(smanager->get_random() % 4) {
+        switch(q->j++ % 4 ) {
+        case 0:
+            q0 = i0->create(0);
+            q1 = i1->create(0);
+            i1->addLast(q0);
+            i0->addLast(q1);
+            break;
+        case 1:
+            if (TaskQueue *p = i0->poll()) {
+                i1->addLast(p);
+            }
+            break;
+        case 2:
+            if (TaskQueue *p = i1->poll()) {
+                i0->addLast(p);
+            }
+            break;
+        case 3:
+            if (TaskQueue *p = i0->poll()) {
+                i0->free_(p);
+            }
+            if (TaskQueue *p = i1->poll()) {
+                i1->free_(p);
+            }
+            break;
+        }
+    }
+
+
     return 0;
 }
--- a/example/task_queue/spe/spe-main.cc	Sat Oct 10 19:16:09 2009 +0900
+++ b/example/task_queue/spe/spe-main.cc	Sat Oct 10 20:32:55 2009 +0900
@@ -1,5 +1,6 @@
 #include "Func.h"
 #include "Scheduler.h"
+#include "main.h"
 
 SchedExternTask(Hello);
 
@@ -11,4 +12,16 @@
 task_init(Scheduler *s)
 {
     SchedRegisterTask(HELLO_TASK, Hello);
+
+    QueuePtr q = (QueuePtr) s->allocate(sizeof(Queues));
+    
+    s->global_set(0, (void *)q);
+
+    q->i = 0;
+    q->j = 0;
+
+    for (int i = 0; i < MAX_QUEUE; i++) {
+        q->q[i] = new TaskQueueInfo() ;
+    }
+
 }