Mercurial > hg > Game > Cerium
changeset 1007:00c01f416e3a draft
add mail_queue
author | yutaka@localhost.localdomain |
---|---|
date | Thu, 28 Oct 2010 08:39:19 +0900 |
parents | 66f1d3d328a7 |
children | 1842a8bfb481 |
files | TaskManager/Cell/spe/CellDmaManager.cc TaskManager/Cell/spe/CellDmaManager.h TaskManager/Fifo/FifoDmaManager.h TaskManager/Makefile.def TaskManager/kernel/schedule/DmaManager.h TaskManager/kernel/schedule/SchedNop2Ready.cc TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/Scheduler.cc TaskManager/kernel/schedule/Scheduler.h example/word_count/main.cc |
diffstat | 10 files changed, 78 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellDmaManager.cc Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Thu Oct 28 08:39:19 2010 +0900 @@ -82,6 +82,48 @@ (this->*end_dmawait_profile)(&global_mail_time); } +// mail を queue にしたみた。mailの書き出しの待ちあるのかわからないけど +//TASK_LIST_MAIL は仕事が最後に溜まってしまうけど、MailQueueなら出来る時にmailを書き出す +//ので多少は効果あるといいな。 +void CellDmaManager::mail_write_queue(memaddr data) +{ + (this->*start_dmawait_profile)(); + if (0 == spu_readchcnt(SPU_WrOutMbox)) { + if (mail_queue.empty()) { + spu_write_out_mbox((uint32)data); + } else { + MailQueuePtr mail = mail_queue.getFirst(); + spu_write_out_mbox((uint32)mail->data); + mail_queue.free_(mail); + mail = mail_queue.create(); + mail->data = data; + mail_queue.addLast(mail); + } + } else { + MailQueuePtr mail = mail_queue.create(); + mail->data = data; + mail_queue.addLast(mail); + } + (this->*end_dmawait_profile)(&global_mail_time); +} + +// tasklist おわりに、MailQueue 全部を書き出す +void CellDmaManager::mail_write_finish_list(memaddr data) +{ + + (this->*start_dmawait_profile)(); + + while (!mail_queue.empty()) { + MailQueuePtr mail = mail_queue.getFirst(); + spu_write_out_mbox((uint32)mail->data); + mail_queue.free_(mail); + } + + spu_write_out_mbox((uint32)data); + + (this->*end_dmawait_profile)(&global_mail_time); +} + memaddr CellDmaManager::mail_read() { (this->*start_dmawait_profile)();
--- a/TaskManager/Cell/spe/CellDmaManager.h Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.h Thu Oct 28 08:39:19 2010 +0900 @@ -4,8 +4,11 @@ #include "base.h" #include "types.h" #include "DmaManager.h" +#include "QueueInfo.h" +#include "MailQueue.h" #include <spu_mfcio.h> +#include <spu_intrinsics.h> #define SPU_PROFILE 1 @@ -20,6 +23,7 @@ uint32 size; } __attribute__ ((aligned (DEFAULT_ALIGNMENT))) DmaList, *DmaListPtr; + QueueInfo<MailQueue> mail_queue; CellDmaManager() ; @@ -42,6 +46,8 @@ void show_dma_wait(Scheduler *s, int cpu); void mail_write(memaddr data); + void mail_write_queue(memaddr data); + void mail_write_finish_list(memaddr data); memaddr mail_read(); void dma_loadList(ListDataPtr list, void *buff, uint32 mask); void dma_storeList(ListDataPtr, void *buff, uint32 mask);
--- a/TaskManager/Fifo/FifoDmaManager.h Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/Fifo/FifoDmaManager.h Thu Oct 28 08:39:19 2010 +0900 @@ -31,6 +31,8 @@ void dma_wait(uint32 mask) ; void mail_write(memaddr data) { mail_queue1->send(data); } + 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(); } void mail_write_from_host(memaddr data) { mail_queue2->send(data); }
--- a/TaskManager/Makefile.def Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/Makefile.def Thu Oct 28 08:39:19 2010 +0900 @@ -29,7 +29,7 @@ ABIBIT = 32 -OPT = -g #-O9 +OPT = -g -O9 -DMAIL_QUEUE # -DEARLY_TOUCH # -g -DTASK_LIST_MAIL -O9
--- a/TaskManager/kernel/schedule/DmaManager.h Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/kernel/schedule/DmaManager.h Thu Oct 28 08:39:19 2010 +0900 @@ -32,6 +32,8 @@ // API for SPU inbound/outbound mailbox virtual void mail_write(memaddr data) {} + virtual void mail_write_queue(memaddr data) {} + virtual void mail_write_finish_list(memaddr data) {} virtual memaddr mail_read() { return 0; } // API for MFC list DMA transfer
--- a/TaskManager/kernel/schedule/SchedNop2Ready.cc Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedNop2Ready.cc Thu Oct 28 08:39:19 2010 +0900 @@ -20,7 +20,11 @@ SchedNop2Ready::next(Scheduler *scheduler,SchedTaskBase *p) { __debug("[SchedNop2Ready:%s]\n", __FUNCTION__); - + +#if MAIL_QUEUE + scheduler->mail_write_finish_list((memaddr)MY_SPE_STATUS_READY); +#else scheduler->mail_write((memaddr)MY_SPE_STATUS_READY); +#endif return new SchedMail(); }
--- a/TaskManager/kernel/schedule/SchedTask.cc Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Thu Oct 28 08:39:19 2010 +0900 @@ -109,6 +109,11 @@ #ifdef TASK_LIST_MAIL if (!(cur_index < list->length) ) scheduler->mail_write(waiter); + +#elseif MAIL_QUEUE + + scheduler->mail_write_queue(waiter); + #else scheduler->mail_write(waiter); #endif
--- a/TaskManager/kernel/schedule/Scheduler.cc Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Thu Oct 28 08:39:19 2010 +0900 @@ -155,6 +155,18 @@ connector->mail_write(data); } +void +Scheduler::mail_write_queue(memaddr data) +{ + connector->mail_write_queue(data); +} + +void +Scheduler::mail_write_finish_list(memaddr data) +{ + connector->mail_write(data); +} + memaddr Scheduler::mail_read() {
--- a/TaskManager/kernel/schedule/Scheduler.h Tue Oct 26 17:41:41 2010 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Thu Oct 28 08:39:19 2010 +0900 @@ -123,6 +123,8 @@ void show_dma_wait() { connector->show_dma_wait(this, id); }; void start_profile() { connector->start_profile(); }; void mail_write(memaddr data); + void mail_write_queue(memaddr data); + void mail_write_finish_list(memaddr data); memaddr mail_read(); void dma_loadList(ListDataPtr list, void *, uint32 mask); void dma_storeList(ListDataPtr list, void *, uint32 mask);
--- a/example/word_count/main.cc Tue Oct 26 17:41:41 2010 +0900 +++ b/example/word_count/main.cc Thu Oct 28 08:39:19 2010 +0900 @@ -296,7 +296,7 @@ printf("task_num %d\n",w->task_num); printf("out_task_num %d\n",w->out_task_num); - /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(8byte)を使用 */ + /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ w->division_out_size = sizeof(unsigned long long)*4; int out_size = w->division_out_size*out_task_num;