# HG changeset patch # User Shohei KOKUBO # Date 1380872483 -32400 # Node ID ef1099c41449bc247453a7a92cf2ebbc6cce495b # Parent e8ded21ac9a2cddfa1bc4bdebd97ed64dcb4b524 UtilizationTest diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/ChangeLog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/ChangeLog Fri Oct 04 16:41:23 2013 +0900 @@ -0,0 +1,6 @@ +2008-05-27 Wataru MIYAGUNI + + * memo + Fifo バージョンでは確認しました。 + Cell バージョンは、Cerium がまだ未実装なのでそれから + diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Func.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Func.h Fri Oct 04 16:41:23 2013 +0900 @@ -0,0 +1,6 @@ +enum { +#include "SysTasks.h" + MULTIPLY_TASK, +}; + +#define DATA_NUM 10000000 diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Makefile Fri Oct 04 16:41:23 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 diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Makefile.cell --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Makefile.cell Fri Oct 04 16:41:23 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 diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Makefile.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Makefile.def Fri Oct 04 16:41:23 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 diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Makefile.gpu --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Makefile.gpu Fri Oct 04 16:41:23 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/\#* diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Makefile.linux --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Makefile.linux Fri Oct 04 16:41:23 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/\#* diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/Makefile.macosx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/Makefile.macosx Fri Oct 04 16:41:23 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/\#* diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/gpu/Multi.cl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/gpu/Multi.cl Fri Oct 04 16:41:23 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]; +} diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/gpu/gpu_task_init.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/gpu/gpu_task_init.cc Fri Oct 04 16:41:23 2013 +0900 @@ -0,0 +1,16 @@ +#include "Func.h" +#include "GpuScheduler.h" + +/* 綽篏臀吾 */ + +/** + * ∽違 ../spe/spe-main c + * у若喝冴違∽違 + * 絅純∽医сk (SchedRegisterTask 綽) + */ + +void +gpu_task_init(void) +{ + GpuSchedRegister(MULTIPLY_TASK, "gpu/Multi.cl","multi"); +} diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/gpu/task_init.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/gpu/task_init.cc Fri Oct 04 16:41:23 2013 +0900 @@ -0,0 +1,16 @@ +#include "Func.h" +#include "GpuScheduler.h" + +/* 綽篏臀吾 */ + +/** + * ∽違 ../spe/spe-main c + * у若喝冴違∽違 + * 絅純∽医сk (SchedRegisterTask 綽) + */ + +void +task_init(void) +{ + GpuSchedRegister(MULTIPLY_TASK, "gpu/Multi.cl","multi"); +} diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/main.cc Fri Oct 04 16:41:23 2013 +0900 @@ -0,0 +1,153 @@ +#include +#include +#include +#include +#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; icreate_task(MULTIPLY_TASK); + 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_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_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; +} diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/main.o Binary file TaskManager/test/UtilizationTest/main.o has changed diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/multiply Binary file TaskManager/test/UtilizationTest/multiply has changed diff -r e8ded21ac9a2 -r ef1099c41449 TaskManager/test/UtilizationTest/ppe/Multi.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/UtilizationTest/ppe/Multi.cc Fri Oct 04 16:41:23 2013 +0900 @@ -0,0 +1,24 @@ +#include +#include "SchedTask.h" +#include "Multi.h" +#include "Func.h" +#include "GpuScheduler.h" + +/* 綽 */ +SchedDefineTask(Multiply); + +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 i = s->x; + for(int i=0; i