# HG changeset patch # User tkaito # Date 1276539271 -32400 # Node ID e66ea5014aa1e1548e354418a4fc9ee8127f07ba first commit. But It move "Bulk". diff -r 000000000000 -r e66ea5014aa1 Func.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Func.h Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,7 @@ +enum { +#include "SysTasks.h" + Twice, + TwiceMain, +}; + +#define DATA_NUM 12 diff -r 000000000000 -r e66ea5014aa1 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,24 @@ +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 + +FORCE: + +clean: + @$(MAKE) -f Makefile.macosx clean + @$(MAKE) -f Makefile.linux clean + @$(MAKE) -f Makefile.cell clean \ No newline at end of file diff -r 000000000000 -r e66ea5014aa1 Makefile.cell --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.cell Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,49 @@ +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) + +CFLAGS += `sdl-config --cflags` `xml2-config --cflags` + +LIBS += -lCerium -lCellManager -lspe2 -lpthread -Wl,--gc-sections +LIBS += `sdl-config --libs` -lSDL_image -lGL `xml2-config --libs` + +.SUFFIXES: .cc .o .xml + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +TARGET = dandy + +all: $(TARGET) speobject + +spe-main: + ln -s ../Engine/spe-main . + +$(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 + +-include depend.inc \ No newline at end of file diff -r 000000000000 -r e66ea5014aa1 Makefile.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.def Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,15 @@ +# include/library path +# ex macosx + +# ex linux/ps3 +CERIUM = ../Cerium + +CC = g++ +OPT = -g +CFLAGS = -Wall $(OPT) + +ABIBIT = 32 + +INCLUDE = -I. -I.. -I${CERIUM}/include/TaskManager -I$(CERIUM)/Renderer/Engine -I$(CERIUM)/include/Cerium +LIBS = -L${CERIUM}/TaskManager -L$(CERIUM)/Renderer/Engine +TOOL = $(CERIUM)/bin diff -r 000000000000 -r e66ea5014aa1 Makefile.linux --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.linux Tue Jun 15 03:14:31 2010 +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 + +.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 000000000000 -r e66ea5014aa1 Makefile.macosx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile.macosx Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,41 @@ +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) + +CFLAGS += `sdl-config --cflags` `xml2-config --cflags` +LIBS += -lCerium -lFifoManager +LIBS += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL +CC += -m$(ABIBIT) + +.SUFFIXES: .cc .o + +.cc.o: + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +TARGET = dandy + +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 000000000000 -r e66ea5014aa1 README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README Tue Jun 15 03:14:31 2010 +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荵∫若帥羝< + +荀違障 diff -r 000000000000 -r e66ea5014aa1 main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cc Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,158 @@ +#include +#include +#include +#include "TaskManager.h" +#include "Task.h" +#include "ListData.h" +#include "Func.h" + +extern void task_init(void); + +static int length = DATA_NUM; +static int task = 3; +static int task_array_num = 3; +static int block_num = 3; + +const char *usr_help_str = "Usage: ./twice [-length data_length] [-task_array_num task_num]\n\ + -task_array_num Number of data in a block (default 16)\n\ + -block_num Number of block\n\ + -task Number of task\n\ + -block_size Size of a block\n"; + + +static 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 腆肴 + */ +static void +twice_result(SchedTask *s, void *a, void *b) +{ + int* data = (int*)a; + int* task_buf = (int*)b; + print_data(data, length*task_array_num, "after"); + free(data); + free(task_buf); +} + +static int +init(int argc, char **argv) +{ + int block_size = 16; + for (int i = 1; argv[i]; ++i) { + if (strcmp(argv[i], "-task") == 0) { + task = atoi(argv[++i]); + } else if (strcmp(argv[i], "-task_array_num") == 0) { + task_array_num = atoi(argv[++i]); + } else if (strcmp(argv[i], "-block_num") == 0) { + block_num = atoi(argv[++i]); + } else if (strcmp(argv[i], "-block_size") == 0) { + block_size = atoi(argv[++i]); + } + } + length = task_array_num * block_num * block_size; + + return 0; +} + +#if 0 +static void print_ListData(int size, ListElement *t) +{ + for(int i = 0;icreate_task_array(Twice,task_array_num,block_num+1,block_num,block_num); + Task *t = twice_main->next_task_array(Twice, 0); +#if 0 + printf("allocate task size 0x%0x\n",t->size()); + printf("allocate task total size 0x%0x = 0x%0x * %d\n",twice_main->r_size, + t->size(), task_array_num); +#endif + void *task_buf = twice_main->rbuf; + twice_main->set_post(twice_result, (void*)data, task_buf); + + t = 0; + for(int i = 0;inext_task_array(Twice, t); + int block_size = length/block_num; + t->set_param(0, (memaddr)block_num); + + for(int j = 0;jset_param(j+1, (memaddr)block_size); + /** + * Set of Input Data + * add_inData(address of input data, size of input data); + */ + t->set_inData(j,data, sizeof(int)*block_size); + /** + * Set of Output area + * add_outData(address of output area, size of output area); + */ + t->set_outData(j,data, sizeof(int)*block_size); + data += block_size; + } +#if 0 + print_ListData(block_num,t->inData(0)); + print_ListData(block_num,t->outData(0)); + printf("pos 0x%0lx size 0x%0x\n",(unsigned long)t, t->size()); +#endif + } + twice_main->spawn_task_array(t->next()); + + twice_main->set_cpu(SPE_ANY); + /* + * set_post() ppe task 羝< + */ + // add Active Queue + twice_main->spawn(); +} + +int +TMmain(TaskManager *manager,int argc, char *argv[]) +{ + if (init(argc, argv) < 0) { + return -1; + } + + // Task Register + // ppe/task_init.cc + task_init(); + + for (int i = 0; i < task; ++i) { + int *data = (int*)manager->allocate(sizeof(int)*length*task_array_num); + twice_init(manager, data, length); + } + + return 0; +} diff -r 000000000000 -r e66ea5014aa1 ppe/Twice.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ppe/Twice.cc Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,30 @@ +#include +#include "SchedTaskArray.h" +#include "Twice.h" +#include "Func.h" + +/* 綽 */ +SchedDefineTask1(Twice,twice_run); + +static int +twice_run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + int *i_data; + int *o_data; + long length; + long count = (long)s->get_param(0); + + for(int j = 0; jget_input(rbuf, j); + o_data = (int*)s->get_output(wbuf, j); + length = (long)s->get_param(j+1); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } + } + + return 0; +} diff -r 000000000000 -r e66ea5014aa1 ppe/Twice.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ppe/Twice.h Tue Jun 15 03:14:31 2010 +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 diff -r 000000000000 -r e66ea5014aa1 ppe/task_init.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ppe/task_init.cc Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,17 @@ +#include "Func.h" +#include "Scheduler.h" + +/* 綽篏臀吾 */ +SchedExternTask(Twice); + +/** + * ∽違 ../spe/spe-main c + * у若喝冴違∽違 + * 絅純∽医сk (SchedRegisterTask 綽) + */ + +void +task_init(void) +{ + SchedRegister(Twice); +} diff -r 000000000000 -r e66ea5014aa1 spe/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spe/Makefile Tue Jun 15 03:14:31 2010 +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 diff -r 000000000000 -r e66ea5014aa1 spe/Twice.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spe/Twice.cc Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,30 @@ +#include +#include "SchedTaskArray.h" +#include "Twice.h" +#include "Func.h" + +/* 綽 */ +SchedDefineTask(Twice); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + int *i_data; + int *o_data; + long length; + int data_count = (int)s->get_param(0); + + for(int j = 0; jget_input(rbuf, j); + o_data = (int*)s->get_output(wbuf, j); + length = (long)s->get_param(j+1); + + for (int i = 0; i < length; i++) { + o_data[i] = i_data[i] * 2; + } + } + + return 0; +} diff -r 000000000000 -r e66ea5014aa1 spe/Twice.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spe/Twice.h Tue Jun 15 03:14:31 2010 +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 diff -r 000000000000 -r e66ea5014aa1 spe/spe-main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spe/spe-main.cc Tue Jun 15 03:14:31 2010 +0900 @@ -0,0 +1,14 @@ +#include "Func.h" +#include "SchedTask.h" + +SchedExternTask(Twice); + +/** + * ∽違 SpeScheduler 若違 + * 綽∽医с蕁障 + */ +void +task_init(Scheduler *s) +{ + SchedRegister(Twice); +}