Mercurial > hg > Game > Cerium
changeset 1309:6941385ba022 draft
add -p option
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Dec 2011 17:56:30 +0900 |
parents | 2fa31362ead0 |
children | 26c155523861 |
files | TaskManager/Fifo/FifoDmaManager.cc TaskManager/Fifo/FifoDmaManager.h |
diffstat | 2 files changed, 122 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoDmaManager.cc Tue Dec 13 16:10:57 2011 +0900 +++ b/TaskManager/Fifo/FifoDmaManager.cc Tue Dec 13 17:56:30 2011 +0900 @@ -4,13 +4,23 @@ #include "FifoDmaManager.h" #include "Scheduler.h" #include "TaskManagerImpl.h" +#include "rdtsc.h" void * FifoDmaManager::dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask) { if (size == 0) return buf; + + 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; + return buf; } @@ -25,7 +35,16 @@ FifoDmaManager::dma_store(void *buf, memaddr addr, uint32 size, uint32 mask) { if (size == 0) return buf; + + 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; + return buf; } @@ -41,6 +60,9 @@ void * FifoDmaManager::dma_loadList(Scheduler *s, ListDataPtr list, void *buff, uint32 mask) { + unsigned long long wait = 0; + (this->*start_dmawait_profile)(); + int list_size = list->length; long bound; @@ -52,6 +74,11 @@ memcpy((void*)bound, (void*)elm->addr, elm->size); bound += elm->size; } + + (this->*end_dmawait_profile)(&wait); + global_load_time += wait; + dma_loadList_time += wait; + return buff; } @@ -66,6 +93,9 @@ void FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) { + unsigned long long wait = 0; + (this->*start_dmawait_profile)(); + int list_size = list->length; memaddr bound; @@ -76,6 +106,78 @@ memcpy((void*)elm->addr, (void*)bound, elm->size); bound += elm->size; } + + (this->*end_dmawait_profile)(&wait); + global_store_time += wait; + dma_storeList_time += wait; +} + +void +FifoDmaManager::start_profile() +{ + global_busy_time = 0; + global_load_time = 0; + global_store_time = 0; + dma_load_time = 0; + dma_store_time = 0; + dma_loadList_time = 0; + dma_storeList_time = 0; + + start_dmawait_profile = &FifoDmaManager::do_start_dmawait_profile; + end_dmawait_profile = &FifoDmaManager::do_end_dmawait_profile; + + stop_time = rdtsc(); +} + +void +FifoDmaManager::stop_profile() +{ + start_time = rdtsc(); + global_busy_time = stop_time - start_time; + + start_dmawait_profile = &FifoDmaManager::null_start_dmawait_profile; + end_dmawait_profile = &FifoDmaManager::null_end_dmawait_profile; +} + +void +FifoDmaManager::do_start_dmawait_profile() +{ + start_time = rdtsc(); + global_busy_time += stop_time - start_time; +} + +void +FifoDmaManager::do_end_dmawait_profile(unsigned long long *counter) +{ + stop_time = rdtsc(); + *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; + + 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; + + + s->printf("cpu%d:\n busy_time = %.3g%%" + " load_time = %.3g%%, " + " store_time = %.3g%% " + ,cpu, busy, load, store); + + global_busy_time = 0; + global_load_time = 0; + global_store_time = 0; + dma_load_time = 0; + dma_store_time = 0; + dma_loadList_time = 0; + dma_storeList_time = 0; } uint32 @@ -102,15 +204,4 @@ } } -void -FifoDmaManager::start_profile() -{ - -} - -void -FifoDmaManager::stop_profile() -{ - -} /* end */
--- a/TaskManager/Fifo/FifoDmaManager.h Tue Dec 13 16:10:57 2011 +0900 +++ b/TaskManager/Fifo/FifoDmaManager.h Tue Dec 13 17:56:30 2011 +0900 @@ -3,6 +3,7 @@ #include "base.h" #include "DmaManager.h" + #ifdef __CERIUM_PARALLEL__ #include "SynchronizedMailManager.h" #else @@ -34,12 +35,24 @@ delete mail_queue2; } + /* variables */ +protected: + unsigned long long start_time, stop_time; + unsigned long long global_busy_time, global_load_time, global_store_time; + unsigned long long dma_load_time, dma_store_time, dma_loadList_time, dma_storeList_time; + /* functions */ +public: virtual void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask); void *dma_store(void *buf, memaddr addr, uint32 size, uint32 mask); void dma_wait(uint32 mask) ; void *get_writebuf(Scheduler *s, memaddr addr, uint32 size) ; + void (FifoDmaManager::*start_dmawait_profile)(); + void (FifoDmaManager::*end_dmawait_profile)(unsigned long long *counter); + void start_profile(); + void stop_profile(); + void show_dma_wait(Scheduler *s, int cpu); void mail_write(memaddr data) { mail_queue1->send(data); } void mail_write_queue(memaddr data) { mail_queue1->send(data); } @@ -51,13 +64,19 @@ memaddr mail_read_from_host() { return mail_queue1->recv(); } int has_mail_from_host() { return mail_queue1->count(); } - void *dma_loadList(Scheduler *s, ListDataPtr list, void *buff, uint32 mask); + virtual void *dma_loadList(Scheduler *s, ListDataPtr list, void *buff, uint32 mask); void dma_storeList(ListDataPtr, void *buff, uint32 mask); void *get_writebuf(Scheduler *s, ListDataPtr, uint32 size) ; uint32 get_tag(); void bound(ListData *); +private: + void do_start_dmawait_profile(); + void do_end_dmawait_profile(unsigned long long *counter); + void null_start_dmawait_profile(); + void null_end_dmawait_profile(unsigned long long *counter); + }; #endif