# HG changeset patch # User yutaka@henri.cr.ie.u-ryukyu.ac.jp # Date 1261598472 -32400 # Node ID 71a58131b2c070cc5f2a5992828de44432987d7d # Parent 74aa6649dcb67480152471ab4008cf415db1b65e add array sample helloworld diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/ChangeLog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ChangeLog Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,6 @@ +2008-05-27 Wataru MIYAGUNI + + * memo + Fifo バージョンでは確認しました。 + Cell バージョンは、Cerium がまだ未実装なのでそれから + diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/Func.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Func.h Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,6 @@ +enum { +#include "SysTasks.h" + Hello, + TwiceMain, +}; + diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,20 @@ +default: macosx + +macosx: FORCE + @echo "Make for Mac OS X" + @$(MAKE) -f Makefile.macosx + +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 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/Makefile.cell --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.cell Thu Dec 24 05:01:12 2009 +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 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/Makefile.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.def Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,17 @@ +TARGET = hello + +# include/library path +# ex macosx +#CERIUM = /Users/gongo/Source/Cerium + +# ex linux/ps3 +CERIUM = ../../../Cerium + +CC = g++ +OPT = -g +CFLAGS = -Wall $(OPT) + +ABIBIT = 32 + +INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. +LIBS = -L${CERIUM}/TaskManager diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/Makefile.linux --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.linux Thu Dec 24 05:01:12 2009 +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 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/Makefile.macosx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/Makefile.macosx Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,37 @@ +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 `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 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/main.cc Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,70 @@ +#include +#include +#include +#include "TaskManager.h" +#include "Task.h" +#include "ListData.h" +#include "Func.h" + +extern void task_init(void); + +static int task_num = 1; +/*0 task_num 4や札筝罩≪障*/ +static int data_count = 1; + +const char *usr_help_str = "Usage: ./hello [-task task_num]\n\ + -task Number of task (default 1)\n"; + +static int +init(int argc, char **argv) +{ + for (int i = 1; argv[i]; ++i) { + + if (strcmp(argv[i], "-task") == 0) { + task_num = atoi(argv[++i]); + } + } + + return 0; +} + + +void +twice_init(TaskManager *manager) +{ + + + /** + * Create Task + * create_task(Task ID); + */ + + /*3 param/inData/outData 違絎*/ + HTask *twice_main = manager->create_task_array(Hello,task_num,data_count,data_count,data_count); + Task *t = 0; + + for(int i = 0;inext_task_array(Hello, t); + } + + twice_main->spawn_task_array(t->next()); + twice_main->set_cpu(SPE_ANY); + 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(); + twice_init(manager); + + + return 0; +} diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/ppe/Hello.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/Hello.cc Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,17 @@ +#include +#include "SchedTaskArray.h" +#include "Hello.h" +#include "Func.h" + +/* 綽 */ +SchedDefineTask(Hello); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + s->printf("Hello World\n"); + + return 0; +} diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/ppe/Hello.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/Hello.h Thu Dec 24 05:01:12 2009 +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(Hello); + + int run(void *r, void *w); +}; + */ + +#endif diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/ppe/task_init.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/ppe/task_init.cc Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,17 @@ +#include "Func.h" +#include "Scheduler.h" + +/* 綽篏臀吾 */ +SchedExternTask(Hello); + +/** + * ∽違 ../spe/spe-main c + * у若喝冴違∽違 + * 絅純∽医сk (SchedRegisterTask 綽) + */ + +void +task_init(void) +{ + SchedRegister(Hello); +} diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/spe/Hello.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Hello.cc Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,17 @@ +#include +#include "SchedTaskArray.h" +#include "Hello.h" +#include "Func.h" + +/* 綽 */ +SchedDefineTask(Hello); + +static int +run(SchedTask *s,void *rbuf, void *wbuf) +{ + // SchedTaskArray *a = (SchedTaskArray *)s; + + s->printf("Hello World\n"); + + return 0; +} diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/spe/Hello.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Hello.h Thu Dec 24 05:01:12 2009 +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(Hello); + + int run(void *r, void *w); +}; + */ + +#endif diff -r 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/spe/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/Makefile Thu Dec 24 05:01:12 2009 +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 74aa6649dcb6 -r 71a58131b2c0 example/hello_array/spe/spe-main.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/hello_array/spe/spe-main.cc Thu Dec 24 05:01:12 2009 +0900 @@ -0,0 +1,14 @@ +#include "Func.h" +#include "SchedTask.h" + +SchedExternTask(Hello); + +/** + * ∽違 SpeScheduler 若違 + * 綽∽医с蕁障 + */ +void +task_init(Scheduler *s) +{ + SchedRegister(Hello); +}