# HG changeset patch # User yutaka@localhost.localdomain # Date 1289135464 -32400 # Node ID 43808a098020897dd0eba3c7b433ef3810d823d5 # Parent f8e9c985e2a8c537cc3681cc478b20d6cf311332# Parent 360f8eba78f105b52ed3d198e321317f56ca5e98 merge diff -r 360f8eba78f1 -r 43808a098020 TaskManager/Cell/spe/CellDmaManager.cc --- a/TaskManager/Cell/spe/CellDmaManager.cc Sun Nov 07 04:24:24 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Sun Nov 07 22:11:04 2010 +0900 @@ -5,8 +5,6 @@ unsigned long long alloc_flag = 0; -// singleton -QueueInfo *MailPool = new QueueInfo() ; /** * DMA Load @@ -91,20 +89,34 @@ { (this->*start_dmawait_profile)(); if (0 != spu_readchcnt(SPU_WrOutMbox)) { - if (mail_queue->empty()) { + //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,10 +127,16 @@ (this->*start_dmawait_profile)(); - while (!mail_queue->empty()) { + //while (!mail_queue->empty()) { + while (mail_queue->count()) { + /* MailQueuePtr mail = mail_queue->poll(); spu_write_out_mbox((uint32)mail->data); mail_queue->free_(mail); + */ + + spu_write_out_mbox((uint32)mail_queue->recv()); + } spu_write_out_mbox((uint32)data); @@ -156,7 +174,7 @@ CellDmaManager::CellDmaManager() { - mail_queue = new QueueInfo(MailPool); + mail_queue = new MailManager(); stop_profile(); } void diff -r 360f8eba78f1 -r 43808a098020 TaskManager/Cell/spe/CellDmaManager.h --- a/TaskManager/Cell/spe/CellDmaManager.h Sun Nov 07 04:24:24 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.h Sun Nov 07 22:11:04 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 #include @@ -23,7 +22,6 @@ uint32 size; } __attribute__ ((aligned (DEFAULT_ALIGNMENT))) DmaList, *DmaListPtr; - QueueInfo *mail_queue; CellDmaManager() ; @@ -59,6 +57,8 @@ void null_start_dmawait_profile(); void null_end_dmawait_profile(unsigned long long *counter); + MailManagerPtr mail_queue; + /* end */ } ; diff -r 360f8eba78f1 -r 43808a098020 TaskManager/Cell/spe/MailQueue.h --- a/TaskManager/Cell/spe/MailQueue.h Sun Nov 07 04:24:24 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 diff -r 360f8eba78f1 -r 43808a098020 TaskManager/Makefile.cell --- a/TaskManager/Makefile.cell Sun Nov 07 04:24:24 2010 +0900 +++ b/TaskManager/Makefile.cell Sun Nov 07 22:11:04 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 $@ diff -r 360f8eba78f1 -r 43808a098020 example/HelloWorld/spe/Hello.cc --- a/example/HelloWorld/spe/Hello.cc Sun Nov 07 04:24:24 2010 +0900 +++ b/example/HelloWorld/spe/Hello.cc Sun Nov 07 22:11:04 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); diff -r 360f8eba78f1 -r 43808a098020 example/HelloWorld/spe/spe-main.cc --- a/example/HelloWorld/spe/spe-main.cc Sun Nov 07 04:24:24 2010 +0900 +++ b/example/HelloWorld/spe/spe-main.cc Sun Nov 07 22:11:04 2010 +0900 @@ -10,5 +10,5 @@ void task_init(Scheduler *s) { - SchedRegisterTask(HELLO_TASK, Hello); + SchedRegister(Hello); } diff -r 360f8eba78f1 -r 43808a098020 example/word_count/main.cc --- a/example/word_count/main.cc Sun Nov 07 04:24:24 2010 +0900 +++ b/example/word_count/main.cc Sun Nov 07 22:11:04 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 { diff -r 360f8eba78f1 -r 43808a098020 example/word_count/spe/Exec.cc --- a/example/word_count/spe/Exec.cc Sun Nov 07 04:24:24 2010 +0900 +++ b/example/word_count/spe/Exec.cc Sun Nov 07 22:11:04 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];