changeset 1027:11dee6cf7116

merge
author tkaito
date Tue, 09 Nov 2010 18:14:58 +0900
parents 55f3c5976959 (current diff) cb170249c752 (diff)
children 3191cae6f7a2
files TaskManager/Cell/spe/MailQueue.h
diffstat 14 files changed, 81 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/spe/Makefile	Tue Nov 09 18:14:28 2010 +0900
+++ b/Renderer/Engine/spe/Makefile	Tue Nov 09 18:14:58 2010 +0900
@@ -5,7 +5,7 @@
 TOP = ../$(CERIUM)
 
 SRCS_TMP = $(wildcard *.cc)
-#SRCS_EXCLUDE = CreatePolygon.cc
+SRCS_EXCLUDE = CreatePolygonFromSceneGraph.cc #CreatePolygon.cc 
 SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
 OBJS = $(SRCS:.cc=.o)
 
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -5,8 +5,6 @@
 
 
 unsigned long long alloc_flag = 0;
-// singleton
-QueueInfo<MailQueue> *MailPool = new QueueInfo<MailQueue>() ;
 
 /**
  * DMA Load
@@ -90,21 +88,22 @@
 void CellDmaManager::mail_write_queue(memaddr data)
 {
     (this->*start_dmawait_profile)();
+
     if (0 != spu_readchcnt(SPU_WrOutMbox)) {
-      if (mail_queue->empty()) {
+      if (mail_queue->count()) {
           spu_write_out_mbox((uint32)data);
       } else {
-	  MailQueuePtr mail = mail_queue->poll();
-	  spu_write_out_mbox((uint32)mail->data);
-	  mail_queue->free_(mail);
-	  mail = mail_queue->create();
-	  mail->data = data;
-	  mail_queue->addLast(mail);
+
+	//mail_queue から poll する
+	spu_write_out_mbox((uint32)mail_queue->recv());
+	//mail_queue に加える
+	mail_queue->send(data);
+
       }
     } else {
-        MailQueuePtr mail = mail_queue->create();
-	mail->data = data;
-	mail_queue->addLast(mail);
+
+      mail_queue->send(data);
+
     }
     (this->*end_dmawait_profile)(&global_mail_time);
 }
@@ -115,31 +114,55 @@
 
     (this->*start_dmawait_profile)();
 
-    while (!mail_queue->empty()) {
-      MailQueuePtr mail = mail_queue->poll();
-      spu_write_out_mbox((uint32)mail->data);      
-      mail_queue->free_(mail);
+    while (mail_queue->count()) {
+
+      spu_write_out_mbox((uint32)mail_queue->recv());      
+
     }
 
     spu_write_out_mbox((uint32)data);
-    //mail_queue.freePool();
 
     (this->*end_dmawait_profile)(&global_mail_time);
+
+
 }
 
 memaddr CellDmaManager::mail_read()
 {
+
+
     (this->*start_dmawait_profile)();
     memaddr data = (memaddr)spu_read_in_mbox();
+    
 #if 0 
     if (ABIBIT>32) {
 	data += (spu_read_in_mbox()<<32);
     }
 #endif
     (this->*end_dmawait_profile)(&global_mail_time);
+
+
+
     return data;
 }
 
+memaddr CellDmaManager::task_list_mail_read()
+{
+
+    unsigned long long wait = 0;
+
+    (this->*start_dmawait_profile)();
+    memaddr data = (memaddr)spu_read_in_mbox();
+    (this->*end_dmawait_profile)(&wait);
+
+    task_list_mail_time += wait;
+    global_mail_time += wait;
+
+    return data;
+}
+
+
+
 void CellDmaManager::dma_loadList(ListDataPtr list, void *buff, uint32 mask)
 {
     mfc_getl(buff, 0, list->element, sizeof(mfc_list_element_t)*list->length,
@@ -156,7 +179,7 @@
 CellDmaManager::CellDmaManager() 
 {
 
-    mail_queue = new QueueInfo<MailQueue>(MailPool);
+    mail_queue = new MailManager();
     stop_profile();
 }
 void
@@ -166,6 +189,7 @@
     global_mail_time = 0;
     global_wait_time = 0;
     task_array_load_time = 0;
+    task_list_mail_time = 0;
     start_dmawait_profile =  &CellDmaManager::do_start_dmawait_profile;
     end_dmawait_profile =  &CellDmaManager::do_end_dmawait_profile;  
 
@@ -186,8 +210,10 @@
 void
 CellDmaManager::do_start_dmawait_profile()
 {
+
     wait_time = spu_readch(SPU_RdDec); 
     global_busy_time += busy_time - wait_time;
+
     spu_writech(SPU_WrDec, 0xffffffff);
 
     // Measurement of mainMem_alloc
@@ -225,14 +251,21 @@
 	global_busy_time+global_wait_time+global_mail_time
 	))*100.0;
 
+  double t = ((double)task_list_mail_time)/((double)(
+	global_busy_time+global_wait_time+global_mail_time
+	))*100.0;
+
+
   s->printf("spu%d: busy_time = %lld"
   " wait_time = %lld(%.3g%%), "
   " mail_time = %lld(%.3g%%), " 
-  " busy_ratio = %.3g%%"
-  " array_load_time = %lld\n"
+  " task_list_mail_time = %lld(%.3g%%), " 
+  " busy_ratio = %.3g%%, "
+  " array_load_time = %lld, "
   " mainMem_alloc_time = %lld\n"
     ,cpu, global_busy_time,
-    global_wait_time, d, global_mail_time, m, r,
+    global_wait_time, d, global_mail_time, m, 
+    task_list_mail_time, t, r,
     task_array_load_time,
     mainMemalloc_time);
 
@@ -240,6 +273,7 @@
     global_mail_time = 0;
     global_wait_time = 0;
     task_array_load_time = 0;
+    task_list_mail_time = 0;
     mainMemalloc_time = 0;
     alloc_flag = 0;
 }
--- a/TaskManager/Cell/spe/CellDmaManager.h	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.h	Tue Nov 09 18:14:58 2010 +0900
@@ -4,8 +4,7 @@
 #include "base.h"
 #include "types.h"
 #include "DmaManager.h"
-#include "QueueInfo.h"
-#include "MailQueue.h"
+#include "MailManager.h"
 
 #include <spu_mfcio.h>
 #include <spu_intrinsics.h>
@@ -23,7 +22,6 @@
 	uint32 size;
     }  __attribute__ ((aligned (DEFAULT_ALIGNMENT))) DmaList, *DmaListPtr;
 
-    QueueInfo<MailQueue> *mail_queue;
 
     CellDmaManager() ;
 
@@ -31,6 +29,7 @@
     unsigned int wait_time, busy_time, alloc_busy_time;
     unsigned long long global_busy_time, global_wait_time, global_mail_time, mainMemalloc_time;
     unsigned long long task_array_load_time;
+    unsigned long long task_list_mail_time;
 
     /* functions */
     void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask);
@@ -49,6 +48,7 @@
     void mail_write_queue(memaddr data);
     void mail_write_finish_list(memaddr data);
     memaddr mail_read();
+    memaddr task_list_mail_read();
     void dma_loadList(ListDataPtr list, void *buff, uint32 mask);
     void dma_storeList(ListDataPtr, void *buff, uint32 mask);
 
@@ -59,6 +59,8 @@
     void null_start_dmawait_profile();
     void null_end_dmawait_profile(unsigned long long *counter);
 
+    MailManagerPtr mail_queue;
+
 
 /* end */
 }  ;
--- a/TaskManager/Cell/spe/MailQueue.h	Tue Nov 09 18:14:28 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#ifndef INCLUDED_MAILQUEUE
-#define INCLUDED_MAILQUEUE
-
-class MailQueue {
-public:
-    memaddr data;
-    MailQueue *next; // 4 byte
-    MailQueue *prev; // 4 byte
-    MailQueue *waiter; // 4 byte
-
-    void init() { data = 0; }
-    void initOnce() {}
-    void freeOnce() {}
-
-} ;
-
-typedef MailQueue* MailQueuePtr;
-
-#endif
--- a/TaskManager/Fifo/FifoDmaManager.h	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.h	Tue Nov 09 18:14:58 2010 +0900
@@ -34,6 +34,7 @@
     void mail_write_queue(memaddr data) { mail_queue1->send(data); }
     void mail_write_finish_list(memaddr data) { mail_queue1->send(data); }
     memaddr mail_read() { return mail_queue2->recv(); }
+    memaddr task_list_mail_read() { return mail_queue2->recv(); }
 
     void mail_write_from_host(memaddr data) { mail_queue2->send(data); }
     memaddr mail_read_from_host() { return mail_queue1->recv(); }
--- a/TaskManager/Makefile.cell	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/Makefile.cell	Tue Nov 09 18:14:58 2010 +0900
@@ -17,7 +17,8 @@
     $(CELL_SPE_DIR)/Scheduler.cc\
     $(CELL_SPE_DIR)/SchedNop.cc        \
     $(CELL_SPE_DIR)/MemList.cc        \
-    $(CELL_SPE_DIR)/MemHash.cc        
+    $(CELL_SPE_DIR)/MemHash.cc    \
+    $(CELL_SPE_DIR)/MailManager.cc        
 CELL_SPE_SCHEDULE_OBJ = $(CELL_SPE_SCHEDULE_SRC:.cc=.o)
 
 CELL_SPE_SRCS =  \
@@ -60,7 +61,7 @@
 $(CELL_SPE_SCHEDULE_SRC): kernel/schedule/*.cc kernel/memory/*.cc kernel/ppe/*.cc
 	cp kernel/schedule/*.cc $(CELL_SPE_DIR)/
 	cp kernel/memory/*.cc $(CELL_SPE_DIR)/
-	cp kernel/ppe/{TaskQueue.cc,Task.cc} $(CELL_SPE_DIR)/
+	cp kernel/ppe/{TaskQueue.cc,Task.cc,MailManager.cc} $(CELL_SPE_DIR)/
 
 $(CELL_SPE_OBJS): %.o : %.cc
 	$(SPUCC)  $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
--- a/TaskManager/kernel/schedule/DmaManager.h	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/kernel/schedule/DmaManager.h	Tue Nov 09 18:14:58 2010 +0900
@@ -35,6 +35,7 @@
     virtual void mail_write_queue(memaddr data) {}
     virtual void mail_write_finish_list(memaddr data) {}
     virtual memaddr mail_read() { return 0; }
+    virtual memaddr task_list_mail_read() { return 0; }
     
     // API for MFC list DMA transfer
     virtual void dma_loadList(ListDataPtr list, void *,uint32 mask) {}
--- a/TaskManager/kernel/schedule/SchedMail.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/kernel/schedule/SchedMail.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -7,7 +7,7 @@
 SchedMail::next(Scheduler *scheduler, SchedTaskBase *p)
 {
     
-    params_addr = scheduler->mail_read();
+   params_addr = scheduler->task_list_mail_read();
 
     __debug("[SchedMail:%s]\n", __FUNCTION__);
 
--- a/TaskManager/kernel/schedule/Scheduler.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -174,6 +174,12 @@
     return connector->mail_read();
 }
 
+memaddr
+Scheduler::task_list_mail_read()
+{
+    return connector->task_list_mail_read();
+}
+
 
 
 /*
--- a/TaskManager/kernel/schedule/Scheduler.h	Tue Nov 09 18:14:28 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.h	Tue Nov 09 18:14:58 2010 +0900
@@ -126,6 +126,7 @@
     void mail_write_queue(memaddr data);
     void mail_write_finish_list(memaddr data);
     memaddr mail_read();
+    memaddr task_list_mail_read();
     void dma_loadList(ListDataPtr list, void *, uint32 mask);
     void dma_storeList(ListDataPtr list, void *, uint32 mask);
 
--- a/example/HelloWorld/spe/Hello.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/example/HelloWorld/spe/Hello.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -3,10 +3,10 @@
 #include "Func.h"
 
 /* これは必須 */
-SchedDefineTask(Hello);
+SchedDefineTask1(Hello,hello);
 
 static int
-run(SchedTask *smanager, void *rbuf, void *wbuf)
+hello(SchedTask *smanager, void *rbuf, void *wbuf)
 {
     long task_id = (long)smanager->get_param(0);
 
--- a/example/HelloWorld/spe/spe-main.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/example/HelloWorld/spe/spe-main.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -10,5 +10,5 @@
 void
 task_init(Scheduler *s)
 {
-    SchedRegisterTask(HELLO_TASK, Hello);
+    SchedRegister(Hello);
 }
--- a/example/word_count/main.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/example/word_count/main.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -77,7 +77,7 @@
 static void
 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_next, int size) 
 {
-  
+ 
   if (task_count < array_task_num) {
     array_task_num = task_count;
     if (task_count<=0) return;
@@ -172,7 +172,7 @@
   
   for (int i = 0; i < task_count; i += array_task_num) {
 
-  HTask *h_exec = 0;
+    HTask *h_exec = 0;
     for (int j = 0; j < array_task_num; j++) {
 	int i = w->task_spwaned++;
 	if (w->size < size) size = w->size;
@@ -183,6 +183,7 @@
 	    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);
 
+
 	    if (all) {
 	      w->t_print->wait_for(h_exec);
 	    } else {
--- a/example/word_count/spe/Exec.cc	Tue Nov 09 18:14:28 2010 +0900
+++ b/example/word_count/spe/Exec.cc	Tue Nov 09 18:14:58 2010 +0900
@@ -17,7 +17,7 @@
     int word_num = 0;
     int line_num = 0;
     int i = 0;
-    
+
     head_tail_flag[0] = (i_data[0] != 0x20) && (i_data[0] != 0x0A);
     word_num -= 1-head_tail_flag[0];