changeset 1703:eab9b8205b85 draft

merge
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 08 Oct 2013 01:39:05 +0900
parents f52904f8f03e (current diff) 4a3b3ec582f2 (diff)
children 8e0305989829
files TaskManager/test/UtilizationTest/multiply
diffstat 27 files changed, 621 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -362,6 +362,13 @@
 }
 
 void CellTaskManagerImpl::show_profile() {
+#ifdef __CERIUM_GPU__
+    for (int id = 0; i < gpuNum; id++) {
+        HTaskPtr t = schedTaskManager->create_task(ShowTime, 0, 0, 0, 0);
+        t->set_cpu((CPU_TYPE) (id + GPU_0));
+        t->spawn();
+    }
+#endif
     for (int id = 0; id < machineNum; id++) {
         HTaskPtr t = schedTaskManager->create_task(ShowTime, 0, 0, 0, 0);
         t->set_cpu((CPU_TYPE) (id + SPE_0));
@@ -370,6 +377,13 @@
 }
 
 void CellTaskManagerImpl::start_profile() {
+#ifdef __CERIUM_GPU__
+    for (int id = 0; i < gpuNum; id++) {
+        HTaskPtr t = schedTaskManager->create_task(StartProfile, 0, 0, 0, 0);
+        t->set_cpu((CPU_TYPE) (id + GPU_0));
+        t->spawn();
+    }
+#endif
     for (int id = 0; id < machineNum; id++) {
         HTaskPtr t = schedTaskManager->create_task(StartProfile, 0, 0, 0, 0);
         t->set_cpu((CPU_TYPE) (id + SPE_0));
--- a/TaskManager/Fifo/FifoDmaManager.cc	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.cc	Tue Oct 08 01:39:05 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;
--- a/TaskManager/Fifo/FifoDmaManager.h	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.h	Tue Oct 08 01:39:05 2013 +0900
@@ -10,8 +10,14 @@
 #include "MailManager.h"
 #endif
 
+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);
+
 class FifoDmaManager : public DmaManager {
 
+
 protected:
     /* variables */
     MailManagerPtr mail_queue1;
@@ -28,8 +34,8 @@
         mail_queue1 = new MailManager();
         mail_queue2 = new MailManager();
 #endif
-        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;
     }
 
     ~FifoDmaManager() {
@@ -39,8 +45,8 @@
 
 	/* variables */
 protected:
-    unsigned long long start_time, stop_time;
-    unsigned long long global_busy_time, global_load_time, global_store_time, global_mail_time;
+    unsigned long long global_start_time;  
+    unsigned long long global_load_time, global_store_time, global_mail_time;
     unsigned long long dma_load_time, dma_store_time, dma_loadList_time, dma_storeList_time;
     unsigned long long mail_read_time, mail_write_time;
     unsigned long long mail_read_from_host_time, mail_write_from_host_time;
@@ -52,8 +58,8 @@
     virtual void *dma_store(void *buf, memaddr addr, uint32 size, uint32 mask);
     virtual void dma_wait(uint32 mask) ;
     virtual void *get_writebuf(Scheduler *s, memaddr addr, uint32 size) ;
-    void (FifoDmaManager::*start_dmawait_profile)();
-    void (FifoDmaManager::*end_dmawait_profile)(unsigned long long *counter);
+    //    void (FifoDmaManager::*start_dmawait_profile)();
+    //    void (FifoDmaManager::*end_dmawait_profile)(unsigned long long *counter);
     void start_profile();
     void stop_profile();
 
@@ -74,11 +80,6 @@
     uint32 get_tag();
     virtual 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);
 
 };
 
--- a/TaskManager/Fifo/PreRefDmaManager.cc	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Fifo/PreRefDmaManager.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -5,16 +5,11 @@
 void *
 PreRefDmaManager::dma_load(Scheduler *s, memaddr addr, uint32 size, uint32 mask)
 {
-	unsigned long long wait = 0;
-	(this->*start_dmawait_profile)();
 
 #ifdef __CERIUM_FIFO__
 	asm("prefetcht0 %0"::"m"(addr):"memory");
 #endif // __CERIUM_FIFO__
 
-	(this->*end_dmawait_profile)(&wait);
-	global_load_time += wait;
-	dma_load_time += wait;
 
 	return (void*)addr;
 }
--- a/TaskManager/Fifo/gettime.h	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Fifo/gettime.h	Tue Oct 08 01:39:05 2013 +0900
@@ -3,27 +3,23 @@
 
 #include <time.h>
 #ifdef __APPLE__
-#include <sys/time.h>
+#include "rdtsc.h"
 #endif
-/**
- *  Mac OS X側には、clock_gettimeがないので、gettimeofdayを使う
- */
+
 inline unsigned long long gettime() {
 
 	unsigned long long time = 0;
 #ifdef __CERIUM_FIFO__  // ??
-	struct timespec ts;
 
 #ifndef __APPLE__
+	struct timespec ts;
 	clock_gettime(CLOCK_REALTIME, &ts);
+	time = ((ts.tv_sec << 32) | ts.tv_nsec );
 #else
-	struct timeval tv;
-	gettimeofday(&tv, NULL);
-	ts.tv_sec = tv.tv_sec;
-	ts.tv_nsec = tv.tv_usec * 1000;
+    time = rdtsc();
 #endif
 
-	time = ((ts.tv_sec << 32) | ts.tv_nsec );
+
 #endif // __CERIUM_FIFO__
 	return time;
 
--- a/TaskManager/Fifo/rdtsc.h	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Fifo/rdtsc.h	Tue Oct 08 01:39:05 2013 +0900
@@ -5,12 +5,18 @@
  *  rdtsc is Read Time Stamp Counter
  */
 
-inline unsigned long long rdtsc() {
-	unsigned long long ret = 0;
-#ifdef __CERIUM_FIFO__ // ??
-	__asm__ volatile ("rdtsc" : "=A" (ret));
-#endif // __CERIUM_FIFO__
-	return ret;
+/* define this somewhere */
+#ifdef __i386
+__inline__ uint64_t rdtsc() {
+    uint64_t x;
+    __asm__ volatile ("rdtsc" : "=A" (x));
+    return x;
 }
-
-#endif /* RDTSC_H_ */
+#elif __amd64
+__inline__ uint64_t rdtsc() {
+    uint64_t a, d;
+    __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
+    return (d<<32) | a;
+}
+#endif
+#endif
--- a/TaskManager/Gpu/GpuScheduler.cc	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/Gpu/GpuScheduler.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -117,6 +117,7 @@
             return ;
         }
 
+        (*connector->start_dmawait_profile)();
         while (params_addr) {
             // since we are on the same memory space, we don't has to use dma_load here
             TaskListPtr tasklist = (TaskListPtr)connector->dma_load(this, params_addr,
@@ -131,7 +132,14 @@
             }
             
             for (TaskPtr nextTask = tasklist->tasks;nextTask < tasklist->last(); nextTask = nextTask->next()) {
-                
+                if(nextTask->command==ShowTime) {
+                    connector->show_profile();
+                    continue;
+                }
+                if(nextTask->command==StartProfile) {
+                    connector->start_profile();
+                    continue;
+                }
                 load_kernel(nextTask->command);
                 cl_program& program = *gpu_task_list[nextTask->command].gputask->program;
                 const char *function = gpu_task_list[nextTask->command].name;
@@ -281,6 +289,7 @@
         wait_for_event(event,reply,cur);
         //clFlush(command_queue); // waiting for queued task
         //clFinish(command_queue); // waiting for queued task
+        (*connector->end_dmawait_profile)();
         connector->mail_write((memaddr)MY_SPE_STATUS_READY);
     }
     // TaskArrayの処理
--- a/TaskManager/kernel/ppe/TaskList.h	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/kernel/ppe/TaskList.h	Tue Oct 08 01:39:05 2013 +0900
@@ -20,7 +20,7 @@
     int dim;
     size_t x,y,z;
     Task tasks[TASK_MAX_SIZE]; // 32*TASK_MAX_SIZE
-    
+    unsigned long long start_time,stop_time;
 
     TaskPtr last() { return (TaskPtr)(((memaddr)tasks)+lastTask); }
     void set_last(Task *t) { lastTask = ((memaddr)t) - ((memaddr)tasks); }
--- a/TaskManager/kernel/schedule/DmaManager.h	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/kernel/schedule/DmaManager.h	Tue Oct 08 01:39:05 2013 +0900
@@ -31,7 +31,9 @@
     virtual void dma_wait(uint32 mask) {}
     virtual void show_dma_wait(Scheduler *s, int cpu) {}
     virtual void start_profile() {}
-
+    void (*start_dmawait_profile)();
+    void (*end_dmawait_profile)(unsigned long long* global_busy_time);
+    unsigned long long global_busy_time;
     // API for SPU inbound/outbound mailbox
     virtual void mail_write(memaddr data) {}
     virtual void mail_write_finish_list(memaddr data) {}
--- a/TaskManager/kernel/schedule/SchedTask.cc	Tue Oct 08 01:38:29 2013 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -9,7 +9,7 @@
 #include "error.h"
 #include "TaskManager.h"
 #include <stdarg.h>
-
+#include "gettime.h"
 
 extern TaskObject task_list[MAX_TASK_OBJECT];
 
@@ -114,11 +114,16 @@
     connector->dma_wait((DMA_READ + this->tag));
     void *read = get_input(readbuf, 0); void *write =  get_output(writebuf, 0);
     // set param (if exist dim )
+    list->start_time = gettime();
+    (*connector->start_dmawait_profile)();
     if (list->dim) {
         multi_dimension(list, read, write,run);
     } else {
         run(this, read,write);
     }
+    (*connector->end_dmawait_profile)(&connector->global_busy_time);
+    list->stop_time = gettime();
+    this->printf("%s\t%lld\n",(char *)(task_list[atask->command].name),list->stop_time-list->start_time);
     connector->free_(readbuf);
     // User 側で作る方法が必要...
     // 書き込む領域がなければ無視
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/ChangeLog	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,6 @@
+2008-05-27  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* memo
+	Fifo СǤϳǧޤ
+	Cell СϡCerium ޤ̤ʤΤǤ줫
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Func.h	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,7 @@
+enum {
+#include "SysTasks.h"
+    MULTIPLY_TASK,
+    MULTIPLY_TASK1,
+};
+
+#define DATA_NUM 10000000
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Makefile	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,28 @@
+default: macosx
+
+macosx: FORCE
+	@echo "Make for Mac OS X"
+	@$(MAKE) -f Makefile.macosx
+
+fifo64: FORCE
+	@echo "Make for Mac OS X 64bit mode"
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
+
+linux: FORCE
+	@echo "Make for Linux"
+	@$(MAKE) -f Makefile.linux
+
+cell: FORCE
+	@echo "Make for PS3 (Cell)"
+	@$(MAKE) -f Makefile.cell
+
+gpu: FORCE
+	@echo "Make for GPU (open cl)"
+	@$(MAKE) -f Makefile.gpu
+
+FORCE:
+
+clean:
+	@$(MAKE) -f Makefile.macosx clean
+	@$(MAKE) -f Makefile.linux clean
+	@$(MAKE) -f Makefile.gpu clean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Makefile.cell	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,39 @@
+include ./Makefile.def
+
+SRCS_TMP = $(wildcard *.cc)
+SRCS_EXCLUDE =  # 除外するファイルを書く
+SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
+OBJS = $(SRCS:.cc=.o)
+
+TASK_DIR  = ppe
+TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
+TASK_SRCS_EXCLUDE = 
+TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
+TASK_OBJS = $(TASK_SRCS:.cc=.o)
+
+LIBS += -lCellManager -lspe2 -lpthread -Wl,--gc-sections 
+
+.SUFFIXES: .cc .o
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: $(TARGET) speobject
+
+$(TARGET): $(OBJS) $(TASK_OBJS)
+	$(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
+
+speobject:
+	cd spe; $(MAKE)
+
+link:
+	$(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS)
+
+debug: $(TARGET)
+	sudo ppu-gdb ./$(TARGET) 
+
+clean:
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
+	rm -f *~ \#*
+	rm -f ppe/*~ ppe/\#*
+	cd spe; $(MAKE) clean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Makefile.def	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,15 @@
+TARGET = multiply
+
+# include/library path
+# ex  macosx
+#CERIUM = /Users/gongo/Source/Cerium
+
+# ex  linux/ps3
+CERIUM = ../../../../Cerium
+
+CC      = clang++
+OPT = -g
+CFLAGS  = $(OPT) -Wall 
+
+INCLUDE = -I. -I.. -I${CERIUM}/include/TaskManager
+LIBS = -L${CERIUM}/TaskManager
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Makefile.gpu	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,35 @@
+include ./Makefile.def
+
+SRCS_TMP = $(wildcard *.cc)
+SRCS_EXCLUDE =  # 除外するファイルを書く
+SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
+OBJS = $(SRCS:.cc=.o)
+
+TASK_DIR  = gpu
+TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
+TASK_SRCS_EXCLUDE = 
+TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
+TASK_OBJS = $(TASK_SRCS:.cc=.o)
+
+LIBS += `sdl-config --libs` -lGpuManager -framework opencl
+
+.SUFFIXES: .cc .o
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: $(TARGET) 
+
+$(TARGET): $(OBJS) $(TASK_OBJS)
+	$(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
+
+link:
+	$(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS)
+
+debug: $(TARGET)
+	sudo ppu-gdb ./$(TARGET) 
+
+clean:
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
+	rm -f *~ \#*
+	rm -f gpu/*~ gpu/\#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Makefile.linux	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,36 @@
+include ./Makefile.def
+
+SRCS_TMP = $(wildcard *.cc)
+SRCS_EXCLUDE =  # 除外するファイルを書く
+SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
+OBJS = $(SRCS:.cc=.o)
+
+TASK_DIR  = ppe
+TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
+TASK_SRCS_EXCLUDE = 
+TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
+TASK_OBJS = $(TASK_SRCS:.cc=.o)
+
+LIBS += -lFifoManager -lrt
+
+.SUFFIXES: .cc .o
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS) $(TASK_OBJS)
+	$(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
+
+link:
+	$(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS)
+
+debug: $(TARGET)
+	sudo gdb ./$(TARGET) 
+
+clean:
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
+	rm -f *~ \#*
+	rm -f ppe/*~ ppe/\#*
+	rm -f spe/*~ spe/\#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/Makefile.macosx	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,38 @@
+include ./Makefile.def
+
+SRCS_TMP = $(wildcard *.cc)
+SRCS_EXCLUDE =  # 除外するファイルを書く
+SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
+OBJS = $(SRCS:.cc=.o)
+ABIBIT=64
+
+TASK_DIR  = ppe
+TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
+TASK_SRCS_EXCLUDE = 
+TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
+TASK_OBJS = $(TASK_SRCS:.cc=.o)
+
+LIBS += -lFifoManager `sdl-config --libs`
+CC += -m$(ABIBIT)
+
+.SUFFIXES: .cc .o
+
+.cc.o:
+	$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
+
+all: $(TARGET)
+
+$(TARGET): $(OBJS) $(TASK_OBJS)
+	$(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
+
+link:
+	$(CC) -o $(TARGET) $(OBJS) $(TASK_OBJS) $(LIBS)
+
+debug: $(TARGET)
+	sudo gdb ./$(TARGET) 
+
+clean:
+	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
+	rm -f *~ \#*
+	rm -f ppe/*~ ppe/\#*
+	rm -f spe/*~ spe/\#*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/gpu/Multi.cl	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,7 @@
+__kernel void
+multi(__global const void *params,__global const float *A, __global const float*B, __global float *C)
+{
+    int i=get_global_id(0);
+
+    C[i]=A[i]*B[i];
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/gpu/gpu_task_init.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,16 @@
+#include "Func.h"
+#include "GpuScheduler.h"
+
+/* 必ずこの位置に書いて */
+
+/**
+ * この関数は ../spe/spe-main と違って
+ * 自分で呼び出せばいい関数なので
+ * 好きな関数名でおk (SchedRegisterTask は必須)
+ */
+
+void
+gpu_task_init(void)
+{
+    GpuSchedRegister(MULTIPLY_TASK, "gpu/Multi.cl","multi");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/gpu/task_init.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,16 @@
+#include "Func.h"
+#include "GpuScheduler.h"
+
+/* 必ずこの位置に書いて */
+
+/**
+ * この関数は ../spe/spe-main と違って
+ * 自分で呼び出せばいい関数なので
+ * 好きな関数名でおk (SchedRegisterTask は必須)
+ */
+
+void
+task_init(void)
+{
+    GpuSchedRegister(MULTIPLY_TASK, "gpu/Multi.cl","multi");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/main.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,170 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include "TaskManager.h"
+#include "Func.h"
+
+extern void task_init(void);
+static int task = 1;
+static int length = DATA_NUM;
+const char *usr_help_str = "Usage: ./multiply \n";
+static int print_flag = 0;
+void TMend(TaskManager *);
+
+float *A,*B,*C;
+
+static double st_time = 0 ;
+static double ed_time = 0;
+
+static double
+getTime() {
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    return tv.tv_sec + (double)tv.tv_usec*1e-6;
+}
+
+static void
+check_data() {
+    for(int i=0; i<length;i++) {
+        if (A[i]*B[i]!=C[i]) {
+            printf("Multiplication went wrong.\n");
+            return;
+        }
+    }
+    printf("Multiplication was succeeded.\n");
+    return;
+}
+        
+static void
+print_result() {
+    printf("---\n");
+    if(print_flag == 1) {
+        for (int i =0;i<length;i++) {
+            printf("%f * %f = %f \n",A[i],B[i],C[i]);
+        }
+    }
+    printf("---\n");
+}
+
+
+void
+init(int args, char *argv[]) {
+    for (int i = 1; argv[i]; ++i) {
+        if (strcmp(argv[i], "--length") == 0 || strcmp(argv[i], "-l") == 0) {
+            length = atoi(argv[++i]);
+        } else if (strcmp(argv[i], "-t") == 0) {
+            task = atoi(argv[++i]);
+        } else if (strcmp(argv[i], "-print") == 0) {
+            print_flag = 1;
+        }
+    }
+}
+
+void
+multi_init(TaskManager *manager)
+{
+    
+    A = new float[length];
+    B = new float[length];
+    C = new float[length];
+    for(int i=0; i<length; i++) {
+        A[i]=(float)(i+1000);
+        B[i]=(float)(i+1)/10.f;
+    }
+
+    long task_id = 0;
+    HTask *multiply = manager->create_task(MULTIPLY_TASK1);
+    multiply->set_cpu((CPU_TYPE)((int)SPE_0));
+
+    multiply->set_inData(0,(memaddr)A, sizeof(float)*length);
+    multiply->set_inData(1,(memaddr)B, sizeof(float)*length);
+    multiply->set_param(0,task_id++);
+    multiply->set_outData(0,(memaddr)C, sizeof(float)*length);
+    
+    multiply->spawn();
+
+    HTask* previous = multiply;
+
+    for(int i=1;i<4;i++) {
+        multiply = manager->create_task(MULTIPLY_TASK);
+        multiply->set_cpu((CPU_TYPE)((int)SPE_0+i));
+
+        multiply->set_inData(0,(memaddr)A, sizeof(float)*length);
+        multiply->set_inData(1,(memaddr)B, sizeof(float)*length);
+        multiply->set_param(0,task_id++);        
+        multiply->set_outData(0,(memaddr)C, sizeof(float)*length);
+        
+        multiply->wait_for(previous);
+        
+        multiply->spawn();
+
+        previous = multiply;
+    }
+
+    for(int i=1;i<4;i++) {
+        multiply = manager->create_task(MULTIPLY_TASK);
+        multiply->set_cpu((CPU_TYPE)((int)SPE_0+i+4));
+
+        multiply->set_inData(0,(memaddr)A, sizeof(float)*length);
+        multiply->set_inData(1,(memaddr)B, sizeof(float)*length);
+        multiply->set_param(0,task_id++);        
+        multiply->set_outData(0,(memaddr)C, sizeof(float)*length);
+        
+        multiply->wait_for(previous);
+        
+        multiply->spawn();
+
+        previous = multiply;
+    }
+    // // HTask* second_multiply = manager->create_task(MULTIPLY_TASK);
+    // // second_multiply->set_cpu(SPE_1);
+
+    // // second_multiply->set_inData(0,(memaddr)A, sizeof(float)*length);
+    // // second_multiply->set_inData(1,(memaddr)B, sizeof(float)*length);
+    
+    // // second_multiply->set_outData(0,(memaddr)C, sizeof(float)*length);
+    
+    // // second_multiply->wait_for(multiply);
+
+
+    // second_multiply->spawn();
+
+    // multiply = manager->create_task(MULTIPLY_TASK);
+    // multiply->set_cpu(SPE_2);
+
+    // multiply->set_inData(0,(memaddr)A, sizeof(float)*length);
+    // multiply->set_inData(1,(memaddr)B, sizeof(float)*length);
+    
+    // multiply->set_outData(0,(memaddr)C, sizeof(float)*length);
+
+    // multiply->spawn();
+}
+
+
+int
+TMmain(TaskManager *manager,int argc, char *argv[])
+{
+    init(argc, argv);
+    // Task Register
+    task_init();
+    for (int i = 0; i < task; ++i) {
+        multi_init(manager);
+    }
+    st_time = getTime();
+    manager->set_TMend(TMend);
+    return 0;
+}
+
+void
+TMend(TaskManager *manager)
+{
+    ed_time = getTime();
+    print_result();
+    printf("Time: %0.6f\n",ed_time-st_time);
+    check_data();
+
+    delete A;
+    delete B;
+    delete C;
+}
Binary file TaskManager/test/UtilizationTest/multiply has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/ppe/Multi.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include "SchedTask.h"
+#include "Multi.h"
+#include "Func.h"
+#include "GpuScheduler.h"
+
+/* これは必須 */
+SchedDefineTask(Multiply);
+
+long current_task_id = -1;
+
+static int
+run(SchedTask *s,void *rbuf, void *wbuf)
+{
+    float *A,*B,*C;
+
+    A = (float*)s->get_input(rbuf, 0);
+    B = (float*)s->get_input(rbuf, 1);
+    C = (float*)s->get_output(wbuf, 0);
+    
+    long task_id = (long)s->get_param(0);
+    current_task_id = task_id;
+    //    long i = s->x;
+    for(int i=0; i<DATA_NUM; i++) {
+        C[i]=A[i]*B[i];
+    }
+    if(current_task_id != task_id)
+        fprintf(stderr,"duplicate task %ld %ld\n",current_task_id,task_id);
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/ppe/Multi.h	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,16 @@
+#ifndef INCLUDED_TASK_HELLO
+#define INCLUDED_TASK_HELLO
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+/*
+class Twice : public SchedTask {
+public:
+    SchedConstructor(Twice);
+    
+    int run(void *r, void *w);
+};
+ */
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/ppe/Multi1.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include "SchedTask.h"
+#include "Multi.h"
+#include "Func.h"
+#include "GpuScheduler.h"
+
+/* これは必須 */
+SchedDefineTask(Multiply1);
+
+extern long current_task_id;
+
+static int
+run(SchedTask *s,void *rbuf, void *wbuf)
+{
+    float *A,*B,*C;
+
+    A = (float*)s->get_input(rbuf, 0);
+    B = (float*)s->get_input(rbuf, 1);
+    C = (float*)s->get_output(wbuf, 0);
+    //    sleep(30);
+    
+    long task_id = (long)s->get_param(0);
+    current_task_id = task_id;
+    //    long i = s->x;
+    for(int i=0; i<DATA_NUM; i++) {
+        C[i]=A[i]*B[i];
+    }
+    if(current_task_id != task_id)
+        fprintf(stderr,"duplicate task %ld %ld\n",current_task_id,task_id);
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/test/UtilizationTest/ppe/task_init.cc	Tue Oct 08 01:39:05 2013 +0900
@@ -0,0 +1,18 @@
+#include "Func.h"
+#include "Scheduler.h"
+
+/* 必ずこの位置に書いて */
+SchedExternTask(Multiply);
+SchedExternTask(Multiply1);
+/**
+ * この関数は ../spe/spe-main と違って
+ * 自分で呼び出せばいい関数なので
+ * 好きな関数名でおk (SchedRegisterTask は必須)
+ */
+
+void
+task_init(void)
+{
+  SchedRegisterTask(MULTIPLY_TASK, Multiply);
+  SchedRegisterTask(MULTIPLY_TASK1, Multiply1);
+}