changeset 256:465a871f4c07

fix examples
author tkaito@localhost.localdomain
date Wed, 03 Jun 2009 16:14:06 +0900
parents 6bb8725e60ae
children e0e20d7227cc
files example/basic/Makefile example/basic/Makefile.cell example/basic/Makefile.def example/basic/Makefile.ps3 example/basic/main.cc example/basic/spe/Makefile example/dependency_task/Makefile example/dependency_task/Makefile.def example/many_task/Makefile example/many_task/Makefile.cell example/many_task/Makefile.def example/many_task/Makefile.ps3 example/many_task/main.cc example/many_task/spe/Makefile example/share_task/Makefile example/share_task/Makefile.cell example/share_task/Makefile.def example/share_task/Makefile.ps3 example/share_task/main.cc example/share_task/spe/Makefile
diffstat 20 files changed, 167 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/example/basic/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/basic/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -8,13 +8,13 @@
 	@echo "Make for Linux"
 	@$(MAKE) -f Makefile.linux
 
-ps3: FORCE
+cell: FORCE
 	@echo "Make for PS3 (Cell)"
-	@$(MAKE) -f Makefile.ps3
+	@$(MAKE) -f Makefile.cell
 
 FORCE:
 
 clean:
 	@$(MAKE) -f Makefile.macosx clean
 	@$(MAKE) -f Makefile.linux clean
-	@$(MAKE) -f Makefile.ps3 clean
\ No newline at end of file
+	@$(MAKE) -f Makefile.cell clean
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/basic/Makefile.cell	Wed Jun 03 16:14:06 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
--- a/example/basic/Makefile.def	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/basic/Makefile.def	Wed Jun 03 16:14:06 2009 +0900
@@ -5,7 +5,7 @@
 #CERIUM = /Users/gongo/Source/Cerium
 
 # ex: linux/ps3
-CERIUM = /home/gongo/Cerium
+CERIUM = ../../../Cerium
 
 CC      = g++
 CFLAGS  = -g -Wall -O9
--- a/example/basic/Makefile.ps3	Wed Jun 03 15:46:07 2009 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-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
--- a/example/basic/main.cc	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/basic/main.cc	Wed Jun 03 16:14:06 2009 +0900
@@ -6,15 +6,16 @@
 
 extern void task_init(void);
 
-static int *data;
 static int length = DATA_NUM;
+static int task = 1;
 
-char *help_str = "Usage: ./twice [-length data_length]\n \
-  -length  Number of data (default DATA_NUM (Func.h))";
+const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\
+  -length  Number of data (default DATA_NUM (Func.h))\n\
+  -count   Number of task (default 1)\n";
 
 
 void
-print_data(int *data, int size, char *title)
+print_data(int *data, int size, const char *title)
 {
     printf("%s ---\n", title);
     for (int i = 0; i < size; i++) {
@@ -29,6 +30,7 @@
 void
 twice_result(void *a)
 {
+    int* data = (int*)a;
     print_data(data, length, "after");
     free(data);
 }
@@ -39,10 +41,8 @@
     for (int i = 1; argv[i]; ++i) {
         if (strcmp(argv[i], "-length") == 0) {
             length = atoi(argv[++i]);
-        }
-        if (strcmp(argv[i], "--help") == 0) {
-            printf("%s\n", help_str);
-            return -1;
+        } else if (strcmp(argv[i], "-count") == 0) {
+            task = atoi(argv[++i]);
         }
     }
 
@@ -54,7 +54,7 @@
 {
     HTask *twice;
 
-    data = (int*)manager->malloc(sizeof(int)*length);
+    int *data = (int*)manager->allocate(sizeof(int)*length);
 
     for (int i = 0; i < length; i++) {
 	data[i] = i;
@@ -87,14 +87,14 @@
      */
     twice->add_param(length);
 
-    twice->set_post(twice_result, NULL);
+    twice->set_post(twice_result, (void*)data);
 
     // add Active Queue
     twice->spawn();    
 }
 
 int
-cerium_main(int argc, char *argv[])
+TMmain(int argc, char *argv[])
 {
     if (init(argc, argv) < 0) {
 	return -1;
@@ -104,7 +104,9 @@
     //   ppe/task_init.cc
     task_init();
 
-    twice_init();
+    for (int i = 0; i < task; ++i) {
+	twice_init();
+    }
 
     return 0;
 }
--- a/example/basic/spe/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/basic/spe/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -8,8 +8,8 @@
 
 CC      = spu-g++
 CFLAGS  = -g -Wall -fno-exceptions -fno-rtti #-DDEBUG
-INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L${CERIUM}/TaskManager -lspemanager
+INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I..
+LIBS = -L../${CERIUM}/TaskManager -lspemanager
 
 .SUFFIXES: .cc .o
 
--- a/example/dependency_task/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/dependency_task/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -10,11 +10,11 @@
 
 ps3: FORCE
 	@echo "Make for PS3 (Cell)"
-	@$(MAKE) -f Makefile.ps3
+	@$(MAKE) -f Makefile.cell
 
 FORCE:
 
 clean:
 	@$(MAKE) -f Makefile.macosx clean
 	@$(MAKE) -f Makefile.linux clean
-	@$(MAKE) -f Makefile.ps3 clean
\ No newline at end of file
+	@$(MAKE) -f Makefile.cell clean
\ No newline at end of file
--- a/example/dependency_task/Makefile.def	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/dependency_task/Makefile.def	Wed Jun 03 16:14:06 2009 +0900
@@ -5,7 +5,7 @@
 #CERIUM = /Users/gongo/Source/Cerium
 
 # ex: linux/ps3
-CERIUM = /home/gongo/Cerium
+CERIUM = ../../Cerium
 
 CC      = g++
 CFLAGS  = -g -Wall -O9
--- a/example/many_task/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/many_task/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -8,13 +8,13 @@
 	@echo "Make for Linux"
 	@$(MAKE) -f Makefile.linux
 
-ps3: FORCE
+cell: FORCE
 	@echo "Make for PS3 (Cell)"
-	@$(MAKE) -f Makefile.ps3
+	@$(MAKE) -f Makefile.cell
 
 FORCE:
 
 clean:
 	@$(MAKE) -f Makefile.macosx clean
 	@$(MAKE) -f Makefile.linux clean
-	@$(MAKE) -f Makefile.ps3 clean
\ No newline at end of file
+	@$(MAKE) -f Makefile.cell clean
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/many_task/Makefile.cell	Wed Jun 03 16:14:06 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
--- a/example/many_task/Makefile.def	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/many_task/Makefile.def	Wed Jun 03 16:14:06 2009 +0900
@@ -5,4 +5,10 @@
 #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium
 
 # ex: linux/ps3
-CERIUM = /home/gongo/Cerium
\ No newline at end of file
+CERIUM = ../../../Cerium
+
+CC      = g++
+CFLAGS  = -g -Wall -O9
+
+INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
+LIBS = -L${CERIUM}/TaskManager
--- a/example/many_task/Makefile.ps3	Wed Jun 03 15:46:07 2009 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-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)
-
-CC      = g++
-CFLAGS  = -g -Wall -O9 #-DDEBUG
-
-INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L${CERIUM}/TaskManager -lCellManager -lspe2 -lpthread
-
-.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
--- a/example/many_task/main.cc	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/many_task/main.cc	Wed Jun 03 16:14:06 2009 +0900
@@ -28,7 +28,7 @@
     gettimeofday(&tv, NULL);
     return tv.tv_sec + (double)tv.tv_usec*1e-6;
 }
-
+/*
 static void
 show_data(void)
 {
@@ -38,8 +38,9 @@
     }
     puts("-----------------------------------------------");
 }
+*/
 
-const char *help_str = "Usage: ./sort [option]\n \
+const char *usr_help_str = "Usage: ./sort [option]\n \
 options\n\
   -cpu     Number of SPE used (default 1)\n\
   -l, --length  Sorted number of data (default 1200)\n\
@@ -52,10 +53,7 @@
         if (strcmp(argv[i], "--length") == 0 || strcmp(argv[i], "-l") == 0) {
             length = atoi(argv[++i]);
         }
-	if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
-	    printf("%s\n", help_str);
-	    return -1;
-	}
+
     }
 
     return 0;
--- a/example/many_task/spe/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/many_task/spe/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -8,8 +8,8 @@
 
 CC      = spu-g++
 CFLAGS  = -O9 -g -Wall -fno-exceptions -fno-rtti #-DDEBUG
-INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L${CERIUM}/TaskManager -lspemanager
+INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I..
+LIBS = -L../${CERIUM}/TaskManager -lspemanager
 
 .SUFFIXES: .cc .o
 
--- a/example/share_task/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/share_task/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -8,13 +8,13 @@
 	@echo "Make for Linux"
 	@$(MAKE) -f Makefile.linux
 
-ps3: FORCE
-	@echo "Make for PS3 (Cell)"
-	@$(MAKE) -f Makefile.ps3
+cell: FORCE
+	@echo "Make for CELL (Cell)"
+	@$(MAKE) -f Makefile.cell
 
 FORCE:
 
 clean:
 	@$(MAKE) -f Makefile.macosx clean
 	@$(MAKE) -f Makefile.linux clean
-	@$(MAKE) -f Makefile.ps3 clean
\ No newline at end of file
+	@$(MAKE) -f Makefile.cell clean
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/share_task/Makefile.cell	Wed Jun 03 16:14:06 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
--- a/example/share_task/Makefile.def	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/share_task/Makefile.def	Wed Jun 03 16:14:06 2009 +0900
@@ -2,10 +2,10 @@
 
 # include/library path
 # ex: macosx
-CERIUM = /Users/gongo/Source/Cerium
+CERIUM = ../../../Cerium
 
 # ex: linux/ps3
-#CERIUM = /home/gongo/Cerium
+#CERIUM = gongo/Cerium
 
 CC      = g++
 CFLAGS  = -g -Wall -O9
--- a/example/share_task/Makefile.ps3	Wed Jun 03 15:46:07 2009 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-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
--- a/example/share_task/main.cc	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/share_task/main.cc	Wed Jun 03 16:14:06 2009 +0900
@@ -10,7 +10,7 @@
 int numtask = 1;
 int length = DATA_NUM;
 
-char *help_str = "Usage: ./share [-task numtask] [-length data_length]\n \
+const char *usr_help_str = "Usage: ./share [-task numtask] [-length data_length]\n \
   -task   Number of task (default 1)                           \n  \
   -length    Number of data (default DATA_NUM (Func.h))";
 
@@ -20,7 +20,7 @@
     HTaskPtr task_load;
     HTaskPtr task_exec;
 
-    idata = (int*)manager->malloc(sizeof(int)*length);
+    idata = (int*)manager->allocate(sizeof(int)*length);
     for (int i = 0; i < length; i++) {
 		idata[i] = i;
     }
@@ -58,10 +58,6 @@
 	if (strcmp(argv[i], "-length") == 0) {
 	    length = atoi(argv[++i]);
 	}
-	if (strcmp(argv[i], "--help") == 0) {
-            printf("%s\n", help_str);
-            return -1;
-	}
     }
 
     return 0;
@@ -69,7 +65,7 @@
 
 //---------main関数-----------
 int
-cerium_main(int argc, char *argv[])
+TMmain(int argc, char *argv[])
 {
 
     if (init(argc, argv) < 0) {
--- a/example/share_task/spe/Makefile	Wed Jun 03 15:46:07 2009 +0900
+++ b/example/share_task/spe/Makefile	Wed Jun 03 16:14:06 2009 +0900
@@ -8,8 +8,8 @@
 
 CC      = spu-g++
 CFLAGS  = -g -Wall -fno-exceptions -fno-rtti #-DDEBUG
-INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L${CERIUM}/TaskManager -lspemanager
+INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I..
+LIBS = -L../${CERIUM}/TaskManager -lspemanager
 
 .SUFFIXES: .cc .o