changeset 192:4f5c64e713c7

add example/renew_task
author gongo@localhost.localdomain
date Tue, 13 Jan 2009 10:41:05 +0900
parents 5e3b0405a44b
children 102dad2949a0
files TaskManager/Cell/spe/SchedTask.cc TaskManager/Makefile.def TaskManager/Test/test_render/Makefile.def TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/spe/DrawSpanRenew.cpp TaskManager/Test/test_render/spe/Load_Texture.cpp TaskManager/Test/test_render/spe/Makefile TaskManager/Test/test_render/viewer.cpp example/renew_task/ChangeLog example/renew_task/Func.h example/renew_task/Makefile example/renew_task/Makefile.def example/renew_task/Makefile.linux example/renew_task/Makefile.macosx example/renew_task/Makefile.ps3 example/renew_task/README example/renew_task/main.cc example/renew_task/ppe/Renew1.cc example/renew_task/ppe/Renew1.h example/renew_task/ppe/Renew2.cc example/renew_task/ppe/Renew2.h example/renew_task/ppe/Renew3.cc example/renew_task/ppe/Renew3.h example/renew_task/ppe/Renew4.cc example/renew_task/ppe/Renew4.h example/renew_task/ppe/RenewStart.cc example/renew_task/ppe/RenewStart.h example/renew_task/ppe/task_init.cc example/renew_task/spe/Makefile example/renew_task/spe/Renew1.cc example/renew_task/spe/Renew1.h example/renew_task/spe/Renew2.cc example/renew_task/spe/Renew2.h example/renew_task/spe/Renew3.cc example/renew_task/spe/Renew3.h example/renew_task/spe/Renew4.cc example/renew_task/spe/Renew4.h example/renew_task/spe/RenewStart.cc example/renew_task/spe/RenewStart.h example/renew_task/spe/SpeProfile.cc example/renew_task/spe/SpeProfile.h example/renew_task/spe/spe-main.cc
diffstat 42 files changed, 864 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/spe/SchedTask.cc	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Cell/spe/SchedTask.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -182,7 +182,7 @@
 	// SchedTask::write(void) でも wait 掛けてるんだけど、
         // 実際にはここに wait しないとちゃんと書き込まれてない感じがする
 	// wait はされてるはずなんだがなー
-	__scheduler->dma_wait(DMA_WRITE);
+	//__scheduler->dma_wait(DMA_WRITE);
     }
 
     (this->*ex_exec)();
@@ -193,7 +193,7 @@
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
-    //__scheduler->dma_wait(DMA_WRITE);
+    __scheduler->dma_wait(DMA_WRITE);
     free(__writebuf);
 
     /**
--- a/TaskManager/Makefile.def	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Makefile.def	Tue Jan 13 10:41:05 2009 +0900
@@ -25,7 +25,7 @@
 IMPL_CELL_OBJS = $(IMPL_CELL_SRCS:.cc=.o)
 
 CC     = g++   
-CFLAGS = -O0 -Wall `sdl-config --cflags` -g
+CFLAGS = -O9 -Wall `sdl-config --cflags` -g
 LIBS   = 
 
 INCLUDE = -I../include/TaskManager
\ No newline at end of file
--- a/TaskManager/Test/test_render/Makefile.def	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Test/test_render/Makefile.def	Tue Jan 13 10:41:05 2009 +0900
@@ -3,16 +3,16 @@
 # include/library path
 # ex: macosx
 #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium
-CERIUM = /Users/gongo/Source/hg/Cerium
+#CERIUM = /Users/gongo/Source/hg/Cerium
 
 # ex: linux/ps3
-#CERIUM = /home/gongo/Cerium
+CERIUM = /home/gongo/Cerium
 #CERIUM = /Users/tkaito/hg/Game/Cerium
 
 #CERIUM = ../../..
 
 CC      = g++
-CFLAGS  = -O0 -g -Wall# -DDEBUG
+CFLAGS  = -O9 -g -Wall# -DDEBUG
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I.
 LIBS = -L$(CERIUM)/TaskManager
\ No newline at end of file
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Tue Jan 13 10:41:05 2009 +0900
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
+#include <spu_mfcio.h>
 #include "DrawSpan.h"
 #include "polygon_pack.h"
 #include "texture.h"
@@ -173,6 +174,9 @@
     renew_task->add_param((int)curr);
     renew_task->add_param(cur_span_x);
 
+    fprintf(stderr, "[%p] start %u\n",
+	    curr, spu_readch(SPU_RdDec));
+
     /**
      * 再起動したタスクを待つ
      */ 
@@ -282,12 +286,12 @@
 		     */
 		    if (!isAvailableTile(tex_addr)) {
 			spack->info.start = t;
-			//set_rgb(tex_addr);
-			set_rgbs(tex_addr,
-				 getTile(span->tex_width-1, tex_ypos,
-					 span->tex_width, span->tex_addr));
-			reboot(spack, 0);
-			goto FINISH;
+			set_rgb(tex_addr);
+			//set_rgbs(tex_addr,
+			//getTile(span->tex_width-1, tex_ypos,
+			//span->tex_width, span->tex_addr));
+			//reboot(spack, 0);
+			//goto FINISH;
 		    }
 
 		    rgb = get_rgb(tex_localx, tex_localy, tex_addr);
--- a/TaskManager/Test/test_render/spe/DrawSpanRenew.cpp	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpanRenew.cpp	Tue Jan 13 10:41:05 2009 +0900
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
+#include <spu_mfcio.h>
 #include "DrawSpanRenew.h"
 #include "polygon_pack.h"
 #include "SpanPack.h"
@@ -49,8 +50,11 @@
     // span->length_x の処理での再起動位置
     int js_cont = smanager->get_param(4);
 
+    fprintf(stderr, "[%p] end   %u\n",
+	    spack, spu_readch(SPU_RdDec));
     smanager->dma_wait(TEX_LOAD);
 
+
     do {
 	/**
 	 * SpanPack->next が存在する場合、
@@ -118,10 +122,10 @@
 		     */
 		    if (!isAvailableTile(tex_addr)) {
 			spack->info.start = t;
-			//set_rgb(tex_addr);
-			set_rgbs(tex_addr,
-				 getTile(span->tex_width-1, tex_ypos,
-					 span->tex_width, span->tex_addr));
+			set_rgb(tex_addr);
+			//set_rgbs(tex_addr,
+			//getTile(span->tex_width-1, tex_ypos,
+			//span->tex_width, span->tex_addr));
 			//reboot(spack, 0);
 			//goto FINISH;
 		    }
@@ -165,10 +169,10 @@
 			tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 			if (!isAvailableTile(tex_addr)) {
 			    spack->info.start = t;
-			    //set_rgb(tex_addr);
-			    set_rgbs(tex_addr,
-				     getTile(span->tex_width-1, tex_ypos,
-					     span->tex_width, span->tex_addr));
+			    set_rgb(tex_addr);
+			    //set_rgbs(tex_addr,
+			    //getTile(span->tex_width-1, tex_ypos,
+			    //span->tex_width, span->tex_addr));
 			    //reboot(spack, j);
 			    //goto FINISH;
 			}
--- a/TaskManager/Test/test_render/spe/Load_Texture.cpp	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Test/test_render/spe/Load_Texture.cpp	Tue Jan 13 10:41:05 2009 +0900
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <spu_mfcio.h>
 #include <string.h>
 #include "Load_Texture.h"
 #include "texture.h"
@@ -26,5 +27,7 @@
 	= smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(TileList));
     TileListPtr tileList = new(tileList_tmp) TileList;
 
+    spu_writech(SPU_WrDec, 0x7FFFFFFFU);
+
     return 0;
 }
--- a/TaskManager/Test/test_render/spe/Makefile	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Test/test_render/spe/Makefile	Tue Jan 13 10:41:05 2009 +0900
@@ -8,7 +8,7 @@
 OBJS = $(SRCS:.cpp=.o)
 
 CC      = spu-g++
-CFLAGS  = -O0 -Wall -g -fno-exceptions -fno-rtti #-DDEBUG
+CFLAGS  = -O9 -Wall -g -fno-exceptions -fno-rtti #-DDEBUG
 INCLUDE = -I$(CERIUM)/include/TaskManager -I. -I..
 LIBS    = -L$(CERIUM)/TaskManager -lspemanager
 
--- a/TaskManager/Test/test_render/viewer.cpp	Mon Jan 12 10:32:25 2009 +0900
+++ b/TaskManager/Test/test_render/viewer.cpp	Tue Jan 13 10:41:05 2009 +0900
@@ -327,6 +327,7 @@
 		task_draw = manager->create_task(TASK_DRAW_SPAN);
 		task_draw->add_inData(spack, sizeof(SpanPack));
 	    } else {
+		break;
 		// Draw Background (憜紂ゃ吟)
 		task_draw = manager->create_task(TASK_DRAW_BACK);
 		task_draw->add_param(0xffffffff);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ChangeLog	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,4 @@
+2009-01-13  Wataru MIYAGUNI  <gongo@cr.ie.u-ryukyu.ac.jp>
+
+	* add
+	追加
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/Func.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,7 @@
+enum {
+    RENEW_START = 0,
+    RENEW1,
+    RENEW2,
+    RENEW3,
+    RENEW4,
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/Makefile	Tue Jan 13 10:41:05 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
+
+ps3: FORCE
+	@echo "Make for PS3 (Cell)"
+	@$(MAKE) -f Makefile.ps3
+
+FORCE:
+
+clean:
+	@$(MAKE) -f Makefile.macosx clean
+	@$(MAKE) -f Makefile.linux clean
+	@$(MAKE) -f Makefile.ps3 clean
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/Makefile.def	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,14 @@
+TARGET = renew_task
+
+# include/library path
+# ex: macosx
+#CERIUM = /Users/gongo/Source/Cerium
+
+# ex: linux/ps3
+CERIUM = /home/gongo/Cerium
+
+CC      = g++
+CFLAGS  = -g -Wall -O9
+
+INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
+LIBS = -L${CERIUM}/TaskManager
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/Makefile.linux	Tue Jan 13 10:41:05 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/renew_task/Makefile.macosx	Tue Jan 13 10:41:05 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 `sdl-config --libs`
+
+.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/renew_task/Makefile.ps3	Tue Jan 13 10:41:05 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/renew_task/README	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,122 @@
+/*
+ * $Id: README,v 1.5 2008/10/20 10:02:01 gongo Exp $
+ */
+
+- 概要
+
+Task 内で新たに Task を生成する。
+以後、新たに生成された Task を RenewTask とする
+
+
+-------------------------------------
+RenewTask の生成
+-------------------------------------
+
+  TaskPtr create_task(int TASK_ID);
+
+これは PPE 内で使う
+
+  manager->create_task(id);
+
+と同じ使い方です。以下の関数も同様です。
+
+  add_inData(), add_outData(), add_input()
+
+Task 内部でこれらの関数にアクセスする際は、
+
+  smanager->create_task, smanager->add_inData,
+
+というように、smanager から呼び出してください。
+これは、PPE 内での TaskManager と同じ感じです。一応 STaskManager って型です。
+なお、smanager->spawn() というのはありません。そのまま実行されます。
+
+
+-------------------------------------
+RenewTask を待ちたい場合
+-------------------------------------
+
+TaskA : PPE で生成
+TaskB : TaskA で生成
+
+だったとする。
+
+このとき、TaskA が終了した時点で、PPE 側に 「TaskA が終了した」と送るのですが
+場合によっては、TaskB が終了するまで待って、初めて TaskA 終了を
+通知したい時があると思います。そういうときは
+
+  TaskPtr taskB = smanager->create_task(TASK_B);
+  smanager->wait_task(taskB);
+
+としてください。PPE での wait_for と違い、複数に設定はできません。
+
+
+-------------------------------------
+RenewTask の生成から実行までの時間
+-------------------------------------
+
+SPE 上で時間の計測を行う際、SPU Decrementer を使う方法が一般的らしい。
+./spe/SpeProfile.cc の中でそのルーチンを入れてます。
+
+  SpeProfile *profile = new SpeProfile;
+
+でオブジェクトを生成した後、測定したい範囲の最初で
+
+  profile->ProfStart();
+
+計測の最後の範囲で
+
+  profile->ProfStop();
+
+その結果を表示したい時は
+
+  profile->ProfPrint();
+
+とします。
+
+
+- 実行方法
+
+./renew_task
+
+- 実行例
+
+流れは、
+
+1. PPE で RenewStart を起動
+2. RenewStart 内で Renew1 を起動
+3. Renew1 内で Renew2 を起動
+4. Renew2 内で Renew3 を起動
+5. Renew3 内で Renew4 を起動
+6. Renew4 で終了
+
+% ./renew_task
+
+[PPE] Program Start
+
+[PPE] Create Task : RenewStart
+
+[SPE] ** running RenewStart
+[SPE] Create Task : Renew1
+[SPE] ** finish  RenewStart
+
+SPE time by SPU Decrementer: 40392.515625
+[SPE] ** running Renew1
+[SPE] Create Task : Renew2
+[SPE] ** finish  Renew1
+
+SPE time by SPU Decrementer: 13483.305664
+[SPE] ** running Renew2
+[SPE] Create Task : Renew3
+[SPE] ** finish  Renew2
+
+SPE time by SPU Decrementer: 0.005163
+[SPE] ** running Renew3
+[SPE] Create Task : Renew4
+[SPE] ** finish  Renew3
+
+SPE time by SPU Decrementer: 0.005150
+[SPE] ** running Renew4
+[SPE] ** finish  Renew4
+
+
+測定の単位は msec です
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/main.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "TaskManager.h"
+#include "Func.h"
+
+extern void task_init(void);
+
+const char *help_str = "Usage: ./renew_task";
+
+static int
+init(int argc, char **argv)
+{
+    for (int i = 1; argv[i]; ++i) {
+        if (strcmp(argv[i], "--help") == 0) {
+            printf("%s\n", help_str);
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+static void
+renew_init(void)
+{
+    HTask *renew;
+
+    printf("[PPE] Create Task : RenewStart\n\n");
+
+    renew = manager->create_task(RENEW_START);
+    renew->set_cpu(SPE_ANY);
+
+    // add Active Queue
+    renew->spawn();    
+}
+
+int
+cerium_main(int argc, char *argv[])
+{
+    if (init(argc, argv) < 0) {
+	return -1;
+    }
+
+    // Task Register
+    //   ppe/task_init.cc
+    task_init();
+
+    printf("[PPE] Program Start\n\n");
+
+    renew_init();
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew1.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include "Renew1.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew1);
+
+int
+Renew1::run(void *rbuf, void *wbuf)
+{
+    printf("[PPE] ** running Renew1\n");
+    
+    printf("[PPE] Create Task : Renew2\n");
+    TaskPtr nextTask = smanager->create_task(RENEW2);
+    smanager->wait_task(nextTask);
+    
+    printf("[PPE] ** finish  Renew1\n");
+    printf("\n");
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew1.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW1
+#define INCLUDED_TASK_RENEW1
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew1 : public SchedTask {
+public:
+    SchedConstructor(Renew1);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew2.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include "Renew2.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew2);
+
+int
+Renew2::run(void *rbuf, void *wbuf)
+{
+    printf("[PPE] ** running Renew2\n");
+
+    printf("[PPE] Create Task : Renew3\n");
+    TaskPtr nextTask = smanager->create_task(RENEW3);
+    smanager->wait_task(nextTask);
+    
+    printf("[PPE] ** finish  Renew2\n");
+    printf("\n");
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew2.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW2
+#define INCLUDED_TASK_RENEW2
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew2 : public SchedTask {
+public:
+    SchedConstructor(Renew2);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew3.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include "Renew3.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew3);
+
+int
+Renew3::run(void *rbuf, void *wbuf)
+{
+    printf("[PPE] ** running Renew3\n");
+    
+    printf("[PPE] Create Task : Renew4\n");
+    TaskPtr nextTask = smanager->create_task(RENEW4);
+    smanager->wait_task(nextTask);
+    
+    printf("[PPE] ** finish  Renew3\n");
+    printf("\n");
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew3.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW3
+#define INCLUDED_TASK_RENEW3
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew3 : public SchedTask {
+public:
+    SchedConstructor(Renew3);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew4.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include "Renew4.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew4);
+
+int
+Renew4::run(void *rbuf, void *wbuf)
+{
+    printf("[PPE] ** running Renew4\n");
+    
+    printf("[PPE] ** finish  Renew4\n");
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/Renew4.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW4
+#define INCLUDED_TASK_RENEW4
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew4 : public SchedTask {
+public:
+    SchedConstructor(Renew4);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/RenewStart.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include "RenewStart.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(RenewStart);
+
+int
+RenewStart::run(void *rbuf, void *wbuf)
+{
+    printf("[PPE] ** running RenewStart\n");
+
+    printf("[PPE] Create Task : Renew1\n");
+    TaskPtr nextTask = smanager->create_task(RENEW1);
+    smanager->wait_task(nextTask);
+    
+    printf("[PPE] ** finish  RenewStart\n");
+    printf("\n");
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/RenewStart.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEWSTART
+#define INCLUDED_TASK_RENEWSTART
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class RenewStart : public SchedTask {
+public:
+    SchedConstructor(RenewStart);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/ppe/task_init.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,25 @@
+#include "Func.h"
+#include "Scheduler.h"
+
+/* 必ずこの位置に書いて */
+SchedExternTask(RenewStart);
+SchedExternTask(Renew1);
+SchedExternTask(Renew2);
+SchedExternTask(Renew3);
+SchedExternTask(Renew4);
+
+/**
+ * この関数は ../spe/spe-main と違って
+ * 自分で呼び出せばいい関数なので
+ * 好きな関数名でおk (SchedRegisterTask は必須)
+ */
+
+void
+task_init(void)
+{
+    SchedRegisterTask(RENEW_START, RenewStart);
+    SchedRegisterTask(RENEW1, Renew1);
+    SchedRegisterTask(RENEW2, Renew2);
+    SchedRegisterTask(RENEW3, Renew3);
+    SchedRegisterTask(RENEW4, Renew4);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Makefile	Tue Jan 13 10:41:05 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 -O9 -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/renew_task/spe/Renew1.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include "Renew1.h"
+#include "SpeProfile.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew1);
+
+int
+Renew1::run(void *rbuf, void *wbuf)
+{
+    SpeProfile *profile = (SpeProfile*)smanager->global_get(0);
+    profile->ProfStop();
+    profile->ProfPrint();
+
+    printf("[SPE] ** running Renew1\n");
+    
+    printf("[SPE] Create Task : Renew2\n");
+    TaskPtr nextTask = smanager->create_task(RENEW2);
+    smanager->wait_task(nextTask);
+    
+    printf("[SPE] ** finish  Renew1\n\n");
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew1.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW1
+#define INCLUDED_TASK_RENEW1
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew1 : public SchedTask {
+public:
+    SchedConstructor(Renew1);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew2.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include "Renew2.h"
+#include "SpeProfile.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew2);
+
+int
+Renew2::run(void *rbuf, void *wbuf)
+{
+    SpeProfile *profile = (SpeProfile*)smanager->global_get(0);
+    profile->ProfStop();
+    profile->ProfPrint();
+
+    printf("[SPE] ** running Renew2\n");
+
+    printf("[SPE] Create Task : Renew3\n");
+    TaskPtr nextTask = smanager->create_task(RENEW3);
+    smanager->wait_task(nextTask);
+    
+    printf("[SPE] ** finish  Renew2\n\n");
+
+    profile->ProfStart();
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew2.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW2
+#define INCLUDED_TASK_RENEW2
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew2 : public SchedTask {
+public:
+    SchedConstructor(Renew2);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew3.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include "Renew3.h"
+#include "SpeProfile.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew3);
+
+int
+Renew3::run(void *rbuf, void *wbuf)
+{
+    SpeProfile *profile = (SpeProfile*)smanager->global_get(0);
+    profile->ProfStop();
+    profile->ProfPrint();
+
+    printf("[SPE] ** running Renew3\n");
+    
+    printf("[SPE] Create Task : Renew4\n");
+    TaskPtr nextTask = smanager->create_task(RENEW4);
+    smanager->wait_task(nextTask);
+    
+    printf("[SPE] ** finish  Renew3\n");
+    printf("\n");
+
+    profile->ProfStart();
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew3.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW3
+#define INCLUDED_TASK_RENEW3
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew3 : public SchedTask {
+public:
+    SchedConstructor(Renew3);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew4.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include "Renew4.h"
+#include "SpeProfile.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Renew4);
+
+int
+Renew4::run(void *rbuf, void *wbuf)
+{
+    SpeProfile *profile = (SpeProfile*)smanager->global_get(0);
+    profile->ProfStop();
+    profile->ProfPrint();
+
+    printf("[SPE] ** running Renew4\n");
+    
+    printf("[SPE] ** finish  Renew4\n");
+
+    smanager->global_free(0);
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/Renew4.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEW4
+#define INCLUDED_TASK_RENEW4
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class Renew4 : public SchedTask {
+public:
+    SchedConstructor(Renew4);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/RenewStart.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include "RenewStart.h"
+#include "SpeProfile.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(RenewStart);
+
+int
+RenewStart::run(void *rbuf, void *wbuf)
+{
+    printf("[SPE] ** running RenewStart\n");
+    
+    void *tmp = smanager->global_alloc(sizeof(SpeProfile), 0);
+    SpeProfile *profile = new (tmp) SpeProfile;
+
+    printf("[SPE] Create Task : Renew1\n");
+    TaskPtr nextTask = smanager->create_task(RENEW1);
+    smanager->wait_task(nextTask);
+    
+    printf("[SPE] ** finish  RenewStart\n\n");
+
+    profile->ProfStart();
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/RenewStart.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,15 @@
+#ifndef INCLUDED_TASK_RENEWSTART
+#define INCLUDED_TASK_RENEWSTART
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+class RenewStart : public SchedTask {
+public:
+    SchedConstructor(RenewStart);
+    
+    int run(void *r, void *w);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/SpeProfile.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,35 @@
+/**
+ * SPU Decrementerを用いた処理時間計測
+ */
+
+#include "SpeProfile.h"
+/* DMA転送に関する関数を使用するために必要なインクルードファイル */
+#include <spu_intrinsics.h>
+#include <stdio.h>
+
+/* SPU Decrementerの初期値 */
+#define SPU_DECREMENTER_INITIAL_VALUE 0x7FFFFFFFU
+
+SpeProfile::SpeProfile(void): profile(0) {}
+
+void SpeProfile::ProfStart(void)
+{
+    /* SPU Decrementerに初期値を設定 */
+    spu_writech(SPU_WrDec, SPU_DECREMENTER_INITIAL_VALUE);
+
+    /* 計測開始時間をSPU Decrementerから読み取る */
+    profile = spu_readch(SPU_RdDec);    
+}
+
+void SpeProfile::ProfStop(void)
+{
+    /* 計測終了時間をSPU Decrementerから読み取り, 計測開始時間との差を計算 */
+    profile -= spu_readch(SPU_RdDec);    
+}
+
+void SpeProfile::ProfPrint(void)
+{
+    /* 処理時間を出力 */
+    printf("SPE time by SPU Decrementer: %f\n",
+	   profile / 79800000.0f * 1000.0f);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/SpeProfile.h	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,12 @@
+class SpeProfile {
+public:
+    SpeProfile(void);
+
+    unsigned int profile;
+
+    void ProfStart(void);
+    void ProfStop(void);
+    void ProfPrint(void);
+    unsigned int ProfGet(void);
+    void ProfPrint(unsigned int time);
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/renew_task/spe/spe-main.cc	Tue Jan 13 10:41:05 2009 +0900
@@ -0,0 +1,22 @@
+#include "Func.h"
+#include "SchedTask.h"
+
+SchedExternTask(RenewStart);
+SchedExternTask(Renew1);
+SchedExternTask(Renew2);
+SchedExternTask(Renew3);
+SchedExternTask(Renew4);
+
+/**
+ * この関数は SpeScheduler から呼ばれるので
+ * 必ずこの関数名でお願いします。
+ */
+void
+task_init(void)
+{
+    SchedRegisterTask(RENEW_START, RenewStart);
+    SchedRegisterTask(RENEW1, Renew1);
+    SchedRegisterTask(RENEW2, Renew2);
+    SchedRegisterTask(RENEW3, Renew3);
+    SchedRegisterTask(RENEW4, Renew4);
+}