changeset 1314:a62cde2aaf7c draft

collada file reader minor changes.
author Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp>
date Thu, 15 Dec 2011 22:53:33 +0900
parents 857d3feaeb75 (current diff) d0c14093e019 (diff)
children c0a5a9abff9c
files
diffstat 7 files changed, 147 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoDmaManager.cc	Thu Dec 15 22:52:35 2011 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.cc	Thu Dec 15 22:53:33 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	Thu Dec 15 22:52:35 2011 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.h	Thu Dec 15 22:53:33 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
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc	Thu Dec 15 22:52:35 2011 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc	Thu Dec 15 22:53:33 2011 +0900
@@ -298,6 +298,21 @@
     s->mail_write_from_host(alloc_info[1]);
 }
 
+void FifoTaskManagerImpl::show_profile() {
+	for (int id = 0; id < machineNum; id++) {
+		HTaskPtr t = schedTaskManager->create_task(ShowTime, 0, 0, 0, 0);
+		t->set_cpu((CPU_TYPE) (id + 2));
+		t->spawn();
+	}
+}
+
+void FifoTaskManagerImpl::start_profile() {
+	for (int id = 0; id < machineNum; id++) {
+		HTaskPtr t = schedTaskManager->create_task(StartProfile, 0, 0, 0, 0);
+		t->set_cpu((CPU_TYPE) (id + 2));
+		t->spawn();
+	}
+}
 
 void
 FifoTaskManagerImpl::print_arch()
--- a/TaskManager/Fifo/FifoTaskManagerImpl.h	Thu Dec 15 22:52:35 2011 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.h	Thu Dec 15 22:53:33 2011 +0900
@@ -27,8 +27,8 @@
     void poll();  // called from CellTaskManagerImpl
     void poll1();  // single CPU run called from CellTaskManagerImpl
     void run();
-    void show_profile()  {};
-    void start_profile()  {};
+    void show_profile();
+    void start_profile();
     void polling();
 
 
--- a/TaskManager/Makefile.parallel	Thu Dec 15 22:52:35 2011 +0900
+++ b/TaskManager/Makefile.parallel	Thu Dec 15 22:53:33 2011 +0900
@@ -30,4 +30,4 @@
 paralleldistclean: parallelclean
 	rm -f $(TARGET)
 
-parallelclean:
\ No newline at end of file
+parallelclean:
--- a/TaskManager/kernel/ppe/CpuThreads.cc	Thu Dec 15 22:52:35 2011 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.cc	Thu Dec 15 22:53:33 2011 +0900
@@ -5,9 +5,10 @@
 #include "SysFunc.h"
 #include "SchedNop.h"
 #include "SpeTaskManagerImpl.h"
+#include "CellScheduler.h"
 
-//SchedExternTask(ShowTime);
-//SchedExternTask(StartProfile);
+SchedExternTask(ShowTime);
+SchedExternTask(StartProfile);
 
 
 CpuThreads::CpuThreads(int num, int useRefDma, int start_id) : cpu_num(num), id_offset(start_id) {
@@ -57,8 +58,8 @@
 
     manager->set_scheduler(c_scheduler);
 
-    //SchedRegister(ShowTime);
-    //SchedRegister(StartProfile);
+    SchedRegister(ShowTime);
+    SchedRegister(StartProfile);
 
     argt->wait->sem_v();	//準備完了したスレッドができるたびに+1していく
 
--- a/example/Miller_Rabin/Makefile.def	Thu Dec 15 22:52:35 2011 +0900
+++ b/example/Miller_Rabin/Makefile.def	Thu Dec 15 22:53:33 2011 +0900
@@ -8,8 +8,8 @@
 CERIUM = ../../../Cerium
 
 CC      = g++
-CFLAGS  = -O9 -Wall
-#CFLAGS  = -g -O0 -Wall
+#CFLAGS  = -O9 -Wall
+CFLAGS  = -g -O0 -Wall
 #CFLAGS  = -pg -Wall
 
 INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..