changeset 1401:2187bd10f16d draft

remove mail_write_queue fix gettimeofday
author sugi
date Wed, 15 Feb 2012 15:00:42 +0900
parents 3152bb4429da
children 815dd5f2d150
files TaskManager/Cell/spe/CellDmaManager.cc TaskManager/Cell/spe/CellDmaManager.h TaskManager/Fifo/FifoDmaManager.cc TaskManager/Fifo/FifoDmaManager.h TaskManager/Fifo/gettime.h TaskManager/kernel/schedule/DmaManager.h TaskManager/kernel/schedule/SchedTask.cc
diffstat 7 files changed, 136 insertions(+), 155 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Wed Feb 15 15:00:42 2012 +0900
@@ -80,6 +80,8 @@
 
 }
 
+#ifndef MAIL_QUEUE
+
 void CellDmaManager::mail_write(memaddr data)
 {
     (this->*start_dmawait_profile)();
@@ -92,15 +94,13 @@
 #endif
     (this->*end_dmawait_profile)(&global_mail_time);
 }
+#else
 
 // mail を queue にしたみた。mailの書き出しの待ちあるのかわからないけど
 //TASK_LIST_MAIL は仕事が最後に溜まってしまうけど、MailQueueなら出来る時にmailを書き出す
 //ので多少は効果あるといいな。
-void CellDmaManager::mail_write_queue(memaddr data)
+void CellDmaManager::mail_write(memaddr data)
 {
-
-
-
   unsigned long long wait = 0;
 
     if (0 != spu_readchcnt(SPU_WrOutMbox)) {
@@ -129,6 +129,7 @@
     }
 
 }
+#endif
 
 // tasklist がもうない場合に、MailQueue 全部を書き出す
 void CellDmaManager::mail_write_finish_list(memaddr data)
--- a/TaskManager/Cell/spe/CellDmaManager.h	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.h	Wed Feb 15 15:00:42 2012 +0900
@@ -51,7 +51,6 @@
     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();
     memaddr task_list_mail_read();
--- a/TaskManager/Fifo/FifoDmaManager.cc	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.cc	Wed Feb 15 15:00:42 2012 +0900
@@ -11,15 +11,15 @@
 {
     if (size == 0) return buf;
 
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
     if (s) buf = s->manager->allocate(size);
     memcpy(buf, (void*)addr, size);
 
-	(this->*end_dmawait_profile)(&wait);
-	global_load_time += wait;
-	dma_load_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_load_time += wait;
+        dma_load_time += wait;
 
     return buf;
 }
@@ -36,14 +36,14 @@
 {
     if (size == 0) return buf;
 
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
     memcpy((void*)addr, buf, size);
 
-	(this->*end_dmawait_profile)(&wait);
-	global_store_time += wait;
-	dma_store_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_store_time += wait;
+        dma_store_time += wait;
 
     return buf;
 }
@@ -60,8 +60,8 @@
 void *
 FifoDmaManager::dma_loadList(Scheduler *s, ListDataPtr list, void *buff, uint32 mask)
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
     int list_size = list->length;
     long bound;
@@ -70,14 +70,14 @@
     bound = (long)(buff);
 
     for (int i = 0; i < list_size; i++) {
-	ListElementPtr elm = &list->element[i];
-	memcpy((void*)bound, (void*)elm->addr, elm->size);
-	bound += elm->size;
+        ListElementPtr elm = &list->element[i];
+        memcpy((void*)bound, (void*)elm->addr, elm->size);
+        bound += elm->size;
     }
 
-	(this->*end_dmawait_profile)(&wait);
-	global_load_time += wait;
-	dma_loadList_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_load_time += wait;
+        dma_loadList_time += wait;
 
     return buff;
 }
@@ -93,8 +93,8 @@
 void
 FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask)
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
     int list_size = list->length;
     memaddr bound;
@@ -102,166 +102,153 @@
     bound = (memaddr)(buff);
 
     for (int i = 0; i < list_size; i++) {
-	ListElementPtr elm = &list->element[i];
-	memcpy((void*)elm->addr, (void*)bound, elm->size);
-	bound += elm->size;
+        ListElementPtr elm = &list->element[i];
+        memcpy((void*)elm->addr, (void*)bound, elm->size);
+        bound += elm->size;
     }
 
-	(this->*end_dmawait_profile)(&wait);
-	global_store_time += wait;
-	dma_storeList_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_store_time += wait;
+        dma_storeList_time += wait;
 }
 
 void
 FifoDmaManager::mail_write(memaddr data)
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
     mail_queue1->send(data);
 
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_write_time += wait;
-}
-
-void
-FifoDmaManager::mail_write_queue(memaddr data)
-{
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
-
-    mail_queue1->send(data);
-
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_write_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_mail_time += wait;
+        mail_write_time += wait;
 }
 
 void
 FifoDmaManager::mail_write_finish_list(memaddr data)
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
     mail_queue1->send(data);
 
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_write_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_mail_time += wait;
+        mail_write_time += wait;
 }
 
 memaddr
 FifoDmaManager::mail_read()
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
-	memaddr data;
-	data = mail_queue2->recv();
+        memaddr data;
+        data = mail_queue2->recv();
 
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_read_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_mail_time += wait;
+        mail_read_time += wait;
 
-	return data;
+        return data;
 }
 
 memaddr
 FifoDmaManager::task_list_mail_read()
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
-	memaddr data;
-	data = mail_queue2->recv();
+        memaddr data;
+        data = mail_queue2->recv();
 
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_read_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_mail_time += wait;
+        mail_read_time += wait;
 
-	return data;
+        return data;
 }
 
 void
 FifoDmaManager::mail_write_from_host(memaddr data)
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
-	mail_queue2->send(data);
+        mail_queue2->send(data);
 
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_write_from_host_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_mail_time += wait;
+        mail_write_from_host_time += wait;
 }
 
 memaddr 
 FifoDmaManager::mail_read_from_host() 
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
+        unsigned long long wait = 0;
+        (this->*start_dmawait_profile)();
 
-	memaddr data;
-	data = mail_queue1->recv();
+        memaddr data;
+        data = mail_queue1->recv();
 
-	(this->*end_dmawait_profile)(&wait);
-	global_mail_time += wait;
-	mail_read_from_host_time += wait;
+        (this->*end_dmawait_profile)(&wait);
+        global_mail_time += wait;
+        mail_read_from_host_time += wait;
 
-	return data;
+        return data;
 }
 
 int 
 FifoDmaManager::has_mail_from_host() 
 { 
-	return mail_queue1->count(); 
+        return mail_queue1->count(); 
 }
 
 void
 FifoDmaManager::start_profile()
 {
-	global_busy_time = 0;
-	global_load_time = 0;
-	global_store_time = 0;
-	global_mail_time = 0;
-	dma_load_time = 0;
-	dma_store_time = 0;
-	dma_loadList_time = 0;
-	dma_storeList_time = 0;
-	mail_read_time = 0;
-	mail_write_time = 0;
-	mail_read_from_host_time = 0;
-	mail_write_from_host_time = 0;
+        global_busy_time = 0;
+        global_load_time = 0;
+        global_store_time = 0;
+        global_mail_time = 0;
+        dma_load_time = 0;
+        dma_store_time = 0;
+        dma_loadList_time = 0;
+        dma_storeList_time = 0;
+        mail_read_time = 0;
+        mail_write_time = 0;
+        mail_read_from_host_time = 0;
+        mail_write_from_host_time = 0;
 
-	start_dmawait_profile = &FifoDmaManager::do_start_dmawait_profile;
-	end_dmawait_profile = &FifoDmaManager::do_end_dmawait_profile;
+        start_dmawait_profile = &FifoDmaManager::do_start_dmawait_profile;
+        end_dmawait_profile = &FifoDmaManager::do_end_dmawait_profile;
 
-	stop_time = gettime();
+        stop_time = gettime();
 }
 
 void
 FifoDmaManager::stop_profile()
 {
-	start_time = gettime();
-	global_busy_time += start_time - stop_time;
+        start_time = gettime();
+        global_busy_time += start_time - stop_time;
 
-	start_dmawait_profile = &FifoDmaManager::null_start_dmawait_profile;
-	end_dmawait_profile = &FifoDmaManager::null_end_dmawait_profile;
+        start_dmawait_profile = &FifoDmaManager::null_start_dmawait_profile;
+        end_dmawait_profile = &FifoDmaManager::null_end_dmawait_profile;
 }
 
 void
 FifoDmaManager::do_start_dmawait_profile()
 {
-	start_time = gettime();
-	global_busy_time += start_time - stop_time;
+        start_time = gettime();
+        global_busy_time += start_time - stop_time;
 }
 
 void
 FifoDmaManager::do_end_dmawait_profile(unsigned long long *counter)
 {
-	stop_time = gettime();
-	*counter += stop_time - start_time;
+        stop_time = gettime();
+        *counter += stop_time - start_time;
 }
 
 void FifoDmaManager::null_start_dmawait_profile() {}
@@ -270,48 +257,48 @@
 void
 FifoDmaManager::show_dma_wait(Scheduler *s, int cpu)
 {
-	unsigned long long all_time = global_busy_time + global_load_time + 
-				global_store_time + global_mail_time;
+        unsigned long long all_time = global_busy_time + global_load_time + 
+                                global_store_time + global_mail_time;
 
-	double busy = ((double)global_busy_time)/((double)all_time)*100.0;
-	double load = ((double)global_load_time)/((double)all_time)*100.0;
-	double store = ((double)global_store_time)/((double)all_time)*100.0;
-	double mail = ((double)global_mail_time)/((double)all_time)*100.0;
-	double read = ((double)mail_read_time)/((double)all_time)*100.0;
-	double write = ((double)mail_write_time)/((double)all_time)*100.0;
-	double read_from_host = ((double)mail_read_from_host_time)/((double)all_time)*100.0;
-	double write_from_host = ((double)mail_write_from_host_time)/((double)all_time)*100.0;
+        double busy = ((double)global_busy_time)/((double)all_time)*100.0;
+        double load = ((double)global_load_time)/((double)all_time)*100.0;
+        double store = ((double)global_store_time)/((double)all_time)*100.0;
+        double mail = ((double)global_mail_time)/((double)all_time)*100.0;
+        double read = ((double)mail_read_time)/((double)all_time)*100.0;
+        double write = ((double)mail_write_time)/((double)all_time)*100.0;
+        double read_from_host = ((double)mail_read_from_host_time)/((double)all_time)*100.0;
+        double write_from_host = ((double)mail_write_from_host_time)/((double)all_time)*100.0;
 
 
-	s->printf("cpu%d:\n busy_time = %lld(%.3g%%)\n"
-			" load_time = %lld(%.3g%%), "
-			" store_time = %lld(%.3g%%), "
-			" mail_time = %lld(%.3g%%) \n"
-			" mail_read_time = %lld(%.3g%%), "
-			" mail_write_time = %lld(%.3g%%)\n"
-			" mail_read_from_host_time = %lld(%.3g%%), "
-			" mail_write_from_host_time = %lld(%.3g%%)\n"
-			,cpu, global_busy_time, busy, 
-			global_load_time, load,
-			global_store_time, store,
-			global_mail_time, mail,
-			mail_read_time, read,
-			mail_write_time, write,
-			mail_read_from_host_time, read_from_host,
-			mail_write_from_host_time, write_from_host);
+        s->printf("cpu%d:\n busy_time = %lld(%.3g%%)\n"
+                        " load_time = %lld(%.3g%%), "
+                        " store_time = %lld(%.3g%%), "
+                        " mail_time = %lld(%.3g%%) \n"
+                        " mail_read_time = %lld(%.3g%%), "
+                        " mail_write_time = %lld(%.3g%%)\n"
+                        " mail_read_from_host_time = %lld(%.3g%%), "
+                        " mail_write_from_host_time = %lld(%.3g%%)\n"
+                        ,cpu, global_busy_time, busy, 
+                        global_load_time, load,
+                        global_store_time, store,
+                        global_mail_time, mail,
+                        mail_read_time, read,
+                        mail_write_time, write,
+                        mail_read_from_host_time, read_from_host,
+                        mail_write_from_host_time, write_from_host);
 
-	global_busy_time = 0;
-	global_load_time = 0;
-	global_store_time = 0;
-	global_mail_time = 0;
-	dma_load_time = 0;
-	dma_store_time = 0;
-	dma_loadList_time = 0;
-	dma_storeList_time = 0;
-	mail_read_time = 0;
-	mail_write_time = 0;
-	mail_read_from_host_time = 0;
-	mail_write_from_host_time = 0;
+        global_busy_time = 0;
+        global_load_time = 0;
+        global_store_time = 0;
+        global_mail_time = 0;
+        dma_load_time = 0;
+        dma_store_time = 0;
+        dma_loadList_time = 0;
+        dma_storeList_time = 0;
+        mail_read_time = 0;
+        mail_write_time = 0;
+        mail_read_from_host_time = 0;
+        mail_write_from_host_time = 0;
 }
 
 uint32
--- a/TaskManager/Fifo/FifoDmaManager.h	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.h	Wed Feb 15 15:00:42 2012 +0900
@@ -59,7 +59,6 @@
     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();
     memaddr task_list_mail_read();
--- a/TaskManager/Fifo/gettime.h	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/Fifo/gettime.h	Wed Feb 15 15:00:42 2012 +0900
@@ -2,7 +2,9 @@
 #define GETTIME_H_
 
 #include <time.h>
-
+#ifdef __APPLE__
+#include <sys/time.h>
+#endif
 /**
  *  Mac OS X側には、clock_gettimeがないので、gettimeofdayを使う
  */
--- a/TaskManager/kernel/schedule/DmaManager.h	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/kernel/schedule/DmaManager.h	Wed Feb 15 15:00:42 2012 +0900
@@ -33,7 +33,6 @@
 
     // 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; }
     virtual memaddr task_list_mail_read() { return 0; }
--- a/TaskManager/kernel/schedule/SchedTask.cc	Tue Feb 14 16:22:16 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Wed Feb 15 15:00:42 2012 +0900
@@ -118,15 +118,9 @@
 #ifdef TASK_LIST_MAIL
     if (!(cur_index < list->length) )
 	connector->mail_write(waiter);
-
-#else
-
-#ifdef MAIL_QUEUE
-    connector->mail_write_queue(waiter);
 #else
     connector->mail_write(waiter);
 #endif
-#endif
 }
 
 SchedTaskBase*