diff TaskManager/Fifo/FifoDmaManager.cc @ 1698:7673e2ad2623 draft

fix profile
author kkb
date Fri, 04 Oct 2013 19:44:09 +0900
parents bde20cca45ae
children 5d68a55d5561
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoDmaManager.cc	Fri Oct 04 16:41:23 2013 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.cc	Fri Oct 04 19:44:09 2013 +0900
@@ -13,12 +13,12 @@
     if (size == 0) return buf;
 
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     buf = s->manager->allocate(size);
     memcpy(buf, (void*)addr, size);
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_load_time += wait;
     dma_load_time += wait;
 
@@ -31,11 +31,11 @@
     if (size == 0) return buf;
 
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     memcpy(buf, (void*)addr, size);
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_load_time += wait;
     dma_load_time += wait;
     return buf;
@@ -55,11 +55,11 @@
     if (size == 0) return buf;
 
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     memcpy((void*)addr, buf, size);
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_store_time += wait;
     dma_store_time += wait;
 
@@ -79,7 +79,7 @@
 FifoDmaManager::dma_loadList(Scheduler *s, ListDataPtr list, uint32 mask)
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     int list_size = list->length;
     long bound;
@@ -93,7 +93,7 @@
         bound += elm->size;
     }
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_load_time += wait;
     dma_loadList_time += wait;
 
@@ -104,7 +104,7 @@
 FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask)
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     int list_size = list->length;
     memaddr bound;
@@ -117,7 +117,7 @@
         bound += elm->size;
     }
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_store_time += wait;
     dma_storeList_time += wait;
 }
@@ -126,11 +126,11 @@
 FifoDmaManager::mail_write(memaddr data)
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     mail_queue1->send(data);
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_mail_time += wait;
     mail_write_time += wait;
 }
@@ -139,11 +139,11 @@
 FifoDmaManager::mail_write_finish_list(memaddr data)
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     mail_queue1->send(data);
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_mail_time += wait;
     mail_write_time += wait;
 }
@@ -152,12 +152,12 @@
 FifoDmaManager::mail_read()
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     memaddr data;
     data = mail_queue2->recv();
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_mail_time += wait;
     mail_read_time += wait;
 
@@ -168,12 +168,12 @@
 FifoDmaManager::task_list_mail_read()
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     memaddr data;
     data = mail_queue2->recv();
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_mail_time += wait;
     mail_read_time += wait;
 
@@ -184,11 +184,11 @@
 FifoDmaManager::mail_write_from_host(memaddr data)
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     mail_queue2->send(data);
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_mail_time += wait;
     mail_write_from_host_time += wait;
 }
@@ -197,12 +197,12 @@
 FifoDmaManager::mail_read_from_host() 
 {
     unsigned long long wait = 0;
-    (this->*start_dmawait_profile)();
+    (*this->start_dmawait_profile)();
 
     memaddr data;
     data = mail_queue1->recv();
 
-    (this->*end_dmawait_profile)(&wait);
+    (*this->end_dmawait_profile)(&wait);
     global_mail_time += wait;
     mail_read_from_host_time += wait;
 
@@ -215,9 +215,27 @@
     return mail_queue1->count(); 
 }
 
+static unsigned long long start_time,stop_time;
+void
+do_start_dmawait_profile()
+{
+    start_time = gettime();
+}
+
+void
+do_end_dmawait_profile(unsigned long long *counter)
+{
+    stop_time = gettime();
+    *counter += stop_time - start_time;
+}
+
+void null_start_dmawait_profile() {}
+void null_end_dmawait_profile(unsigned long long *counter) {}
+
 void
 FifoDmaManager::start_profile()
 {
+    global_start_time = gettime();
     global_busy_time = 0;
     global_load_time = 0;
     global_store_time = 0;
@@ -231,8 +249,8 @@
     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 = &do_start_dmawait_profile;
+    end_dmawait_profile = &do_end_dmawait_profile;
 
     stop_time = gettime();
 }
@@ -240,35 +258,14 @@
 void
 FifoDmaManager::stop_profile()
 {
-    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 = &null_start_dmawait_profile;
+    end_dmawait_profile = &null_end_dmawait_profile;
 }
 
 void
-FifoDmaManager::do_start_dmawait_profile()
-{
-    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;
-}
-
-void FifoDmaManager::null_start_dmawait_profile() {}
-void FifoDmaManager::null_end_dmawait_profile(unsigned long long *counter) {}
-
-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 = gettime() - global_start_time;
 
     double busy = ((double)global_busy_time)/((double)all_time)*100.0;
     double load = ((double)global_load_time)/((double)all_time)*100.0;