Mercurial > hg > Members > kono > Cerium
changeset 733:71a58131b2c0
add array sample helloworld
author | yutaka@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Thu, 24 Dec 2009 05:01:12 +0900 |
parents | 74aa6649dcb6 |
children | 08d201fb1d66 |
files | example/hello_array/ChangeLog example/hello_array/Func.h example/hello_array/Makefile example/hello_array/Makefile.cell example/hello_array/Makefile.def example/hello_array/Makefile.linux example/hello_array/Makefile.macosx example/hello_array/main.cc example/hello_array/ppe/Hello.cc example/hello_array/ppe/Hello.h example/hello_array/ppe/task_init.cc example/hello_array/spe/Hello.cc example/hello_array/spe/Hello.h example/hello_array/spe/Makefile example/hello_array/spe/spe-main.cc |
diffstat | 15 files changed, 354 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 <gongo@cr.ie.u-ryukyu.ac.jp> + + * memo + Fifo バージョンでは確認しました。 + Cell バージョンは、Cerium がまだ未実装なのでそれから +
--- /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, +}; +
--- /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
--- /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
--- /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
--- /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/\#*
--- /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/\#*
--- /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 <stdio.h> +#include <stdlib.h> +#include <string.h> +#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;i<task_num;i++) { + t = twice_main->next_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; +}
--- /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 <stdio.h> +#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; +}
--- /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
--- /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); +}
--- /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 <stdio.h> +#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; +}
--- /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
--- /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
--- /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); +}