Mercurial > hg > Game > Cerium
changeset 1628:b3edf26734f5 draft
add SetCpuTest
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/ChangeLog Mon Jun 03 19:17:17 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/SetCpuTest/Func.h Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,6 @@ +enum { +#include "SysTasks.h" + TWICE_TASK, +}; + +#define DATA_NUM 12
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/Makefile Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,31 @@ +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 + +test: FORCE + @$(MAKE) -f Makefile.gpu test + +FORCE: + +clean: + @$(MAKE) -f Makefile.macosx clean + @$(MAKE) -f Makefile.linux clean + @$(MAKE) -f Makefile.cell clean
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/Makefile.cell Mon Jun 03 19:17:17 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/SetCpuTest/Makefile.def Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,15 @@ +TARGET = twice + +# include/library path +# ex macosx +#CERIUM = /Users/gongo/Source/Cerium + +# ex linux/ps3 +CERIUM = ../../../../Cerium + +CC = clang++ +OPT = -g +CFLAGS = $(OPT) -Wall + +INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L${CERIUM}/TaskManager
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/Makefile.gpu Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,53 @@ +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) + +test: + cpus=0;./$(TARGET) -cpu $$cpus + cpus=1;./$(TARGET) -cpu $$cpus + cpus=2;./$(TARGET) -cpu $$cpus + cpus=4;./$(TARGET) -cpu $$cpus + cpus=8;./$(TARGET) -cpu $$cpus + cpus=16;./$(TARGET) -cpu $$cpus + cpus=24;./$(TARGET) -cpu $$cpus + + cpus=0;./$(TARGET) -cpu $$cpus -gpu + cpus=1;./$(TARGET) -cpu $$cpus -gpu + cpus=2;./$(TARGET) -cpu $$cpus -gpu + cpus=4;./$(TARGET) -cpu $$cpus -gpu + cpus=8;./$(TARGET) -cpu $$cpus -gpu + cpus=16;./$(TARGET) -cpu $$cpus -gpu + cpus=24;./$(TARGET) -cpu $$cpus -gpu + +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/SetCpuTest/Makefile.linux Mon Jun 03 19:17:17 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/SetCpuTest/Makefile.macosx Mon Jun 03 19:17:17 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/SetCpuTest/README Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,87 @@ +/* + * $Id: README,v 1.5 2008/10/20 10:02:01 gongo Exp $ + */ + +- 网荀 + +int 帥鴻(Twice) с荀膣2菴障 + +PPE->SPE DMA 荵∫ main.cc twice_init +吾сc篆<帥鴻眼 +若帥鴻茯 + +------------------------------------- +PPE 若帥 +------------------------------------- + +void *get_input(void *p, int index) 篏帥 + +p rbuf ャ障篁腆阪с吾綽荀< +index create task add_inData 障 + +add_inData(data1, size1); +add_inData(data2, size2); + +ц菴違翫 + +data1 = get_input(rbuf, 0); +data2 = get_input(rbuf, 0); + +у障 + +------------------------------------- +PPE 吾若帥 +------------------------------------- + +void *get_output(void *p, int index) 篏帥 + +p wbuf, index input сс +get_output уcс若帥吾違 +帥鴻腟篋緇add_outData ф絎≪鴻吾莨若障障 + + +- 絎茵号 + +./twice [-cpu spe_num] [-length data_length] + + -cpu 篏睡 SPU + // 篁障潟<激с潟с + // 綏紊с翫茲違 2 c + // ャ井潟障茯違(ry + + -length 荀膣 + + +- 絎茵箴 + +% ./twice +before --- + 0 1 2 3 4 5 6 7 8 9 10 11 +after --- + 0 2 4 6 8 10 12 14 16 18 20 22 + +% ./twice -length 20 +before --- + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +after --- + 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 + +% ./twice -length 15 +before --- + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 +zsh: bus error ./twice -length 15 + +筝翫PS3筝(SPE篏帥c翫)с bus error 冴障 +宴 length c若帥ゃ違 +4ゃ(int) x 15 = 60 ゃ с +PPE <-> SPE с DMA 荵∫泣ゃ冴 +1,2,4,8ゃ, 16ゃ違羆冴障c障 +泣ゃ冴茯ゃ翫筝 bus error 冴障 +莨冴荅潟篁罕 + +Game_project/ps3/docs PDF + +Fixstars 泣ゃ +http://cell.fixstars.com/ps3linux/index.php/3.3DMA荵∫若帥羝< + +荀違障
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/gpu/task_init.cc Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,7 @@ +#include "GpuFunc.h" +#include "GpuScheduler.h" + +void +task_init(void) { + GpuSchedRegister(Twice, "gpu/twice.cl", "twice"); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/gpu/twice.cl Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,11 @@ +__kernel void +twice(__global int *data_count, + __global int *input_data, + __global int *output_data) +{ + long count = (long)data_count[0]; + for (int i = 0; i<count; i++) { + output_data[i] = input_data[i] * 2; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/main.cc Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,120 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <sys/stat.h> +#include "types.h" +#include "TaskManager.h" +#include "GpuFunc.h" + +#define DEFAULT 5 +static long int length = DEFAULT; +static int task = 1; +static CPU_TYPE cputype = SPE_ANY; + +extern void task_init(void); + +char usr_help_str[] = "GpuRun [length]\n"; + +void +print_data(int *data, int size, const char *title) +{ + printf("%s ---\n", title); + for ( int i = 0; i < size; i++) { + printf("%2d ", data[i]); + } + printf("\n"); +} + +/** + * 帥鴻腟篋緇 data1, data2 腆肴 + */ +void +twice_result(SchedTask *s, void *a, void *b) +{ + int* data = (int*)a; + long length = (long)b; + print_data(data, length, "after"); +} + + +int +init(int argc, char **argv) +{ + for (int i = 1; argv[i]; ++i) { + if (strcmp(argv[i], "-length") == 0) { + length = atoi(argv[++i]); + } else if (strcmp(argv[i], "-count") == 0) { + task = atoi(argv[++i]); + } else if (strcmp(argv[i], "-gpu") == 0) { + cputype = ANY_ANY; + } + + } + + return 0; +} + + +void +tester(int *indata, int *outdata, int num) { + + //с + int check = 0; + for (int c=0; c<num; c++) { + if(outdata[c] == indata[c]*2) { + check++; + } + } + + printf("Computed '%d/%d' correct values\n",check,num); + +} + + +void +test(TaskManager *manager) { + + int *indata = new int[length]; + int *outdata = new int[length]; + + for (int c=0; c < length ;c++) { + indata[c] = c; + } + + print_data(indata, length, "before"); + + HTaskPtr twice = manager->create_task(Twice); + twice->set_param(0, (memaddr)length); + twice->set_inData(0, indata, sizeof (int)*length); + //int *n = new int[1]; + //n[0]= 3; + //twice->set_inData(1, n, sizeof (int)); + twice->set_outData(0, outdata, sizeof (int)*length); + twice->set_cpu(cputype); + + /* + * set_post() ppe task 羝< + */ + twice->set_post(twice_result, (void*)outdata, (void*)length); + + twice->spawn(); +} + +int +TMmain(TaskManager *manager, int argc, char* argv[]) +{ + if (init(argc, argv) < 0) { + return -1; + } + + task_init(); + + for (int i = 0; i < task; ++i) { + test(manager); + } + + return 0; +} + +/* end */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/ppe/Twice.cc Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,25 @@ +#include <stdio.h> +#include "SchedTask.h" +#include "Twice.h" +#include "Func.h" + +/* 綽 */ +SchedDefineTask(Twice); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + int *i_data; + int *o_data; + long length; + + i_data = (int*)s->get_input(rbuf, 0); + o_data = (int*)s->get_output(wbuf, 0); + length = (long)s->get_param(0); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/ppe/Twice.h Mon Jun 03 19:17:17 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/SetCpuTest/ppe/task_init.cc Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,17 @@ +#include "Func.h" +#include "Scheduler.h" + +/* 綽篏臀吾 */ +SchedExternTask(Twice); + +/** + * ∽違 ../spe/spe-main c + * у若喝冴違∽違 + * 絅純∽医сk (SchedRegisterTask 綽) + */ + +void +task_init(void) +{ + SchedRegisterTask(TWICE_TASK, Twice); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/spe/Makefile Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,26 @@ +include ../Makefile.def + +TARGET = ../spe-main + +SRCS_TMP = $(wildcard *.cc) +SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) +OBJS = $(SRCS:.cc=.o) + +CC = spu-g++ +CFLAGS = -g -Wall -fno-exceptions -fno-rtti #-DDEBUG +INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L../${CERIUM}/TaskManager -lspemanager + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS) + +clean: + rm -f $(TARGET) $(OBJS) + rm -f *~ \#* \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/spe/Twice.cc Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,25 @@ +#include <stdio.h> +#include "SchedTask.h" +#include "Twice.h" +#include "Func.h" + +/* 綽 */ +SchedDefineTask(Twice); + +static int +run(SchedTask *s, void *rbuf, void *wbuf) +{ + int *i_data; + int *o_data; + int length; + + i_data = (int*)s->get_input(rbuf, 0); + o_data = (int*)s->get_output(wbuf, 0); + length = (long)s->get_param(0); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/SetCpuTest/spe/Twice.h Mon Jun 03 19:17:17 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/SetCpuTest/spe/spe-main.cc Mon Jun 03 19:17:17 2013 +0900 @@ -0,0 +1,14 @@ +#include "Func.h" +#include "SchedTask.h" + +SchedExternTask(Twice); + +/** + * ∽違 SpeScheduler 若違 + * 綽∽医с蕁障 + */ +void +task_init(Scheduler *s) +{ + SchedRegisterTask(TWICE_TASK, Twice); +}