changeset 1277:4ba9b622073d draft

merge
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Nov 2011 19:40:47 +0900
parents e92f00ed2fc0 (current diff) 08d81be1c6e4 (diff)
children de51d55ea403
files Renderer/Engine/Camera.cc Renderer/Engine/SceneGraph.cc Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/matrix_calc.cc Renderer/Engine/task/DrawSpan.cc example/Eratosthenes/Func.h example/Eratosthenes/Makefile example/Eratosthenes/Makefile.cell example/Eratosthenes/Makefile.def example/Eratosthenes/Makefile.linux example/Eratosthenes/Makefile.macosx example/Eratosthenes/README example/Eratosthenes/bitmap.h example/Eratosthenes/main.cc example/Eratosthenes/ppe/.#Hello.cc example/Eratosthenes/ppe/Prime.cc example/Eratosthenes/ppe/Prime.h example/Eratosthenes/ppe/PrintTask.cc example/Eratosthenes/ppe/PrintTask.h example/Eratosthenes/ppe/SaveTask.cc example/Eratosthenes/ppe/SaveTask.h example/Eratosthenes/ppe/task_init.cc example/Eratosthenes/spe/Makefile example/Eratosthenes/spe/Prime.cc example/Eratosthenes/spe/Prime.h example/Eratosthenes/spe/PrintTask.cc example/Eratosthenes/spe/PrintTask.h example/Eratosthenes/spe/spe-main.cc example/Miller_Rabin/run.sh example/Miller_Rabin/time.sh
diffstat 48 files changed, 265 insertions(+), 745 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Camera.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/Camera.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -177,9 +177,9 @@
     float cx[4], cy[4], cz[4], p[4];
     float tm[16];
 
-    radx = angle[0]*3.14/180;
-    rady = angle[1]*3.14/180;
-    radz = angle[2]*3.14/180;
+    radx = angle[0]*M_PI/180;
+    rady = angle[1]*M_PI/180;
+    radz = angle[2]*M_PI/180;
 
     float sinx = sin(radx);
     float cosx = cos(radx);
--- a/Renderer/Engine/ChangeLog	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/ChangeLog	Tue Nov 22 19:40:47 2011 +0900
@@ -1,3 +1,14 @@
+2011-9-7  Shinji Kono  <kono@ie.u-ryukyu.ac.jp>
+
+	allExecute 使わない方の Camera の処理をしないとだめ。
+
+	    Camera のbrother ===> sprite
+	    Camera のchildren ===> sceneGraph
+
+	じゃないの? Camera に座標と行列をcopyする必要があると思われる。
+
+	matrix/real_matrix は重複っぽい。そもそも、なんで別なんだ? 普通は同じ値?
+
 2011-2-14 Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
 
 	CreatePolygonFromScenenGraph を SPEで動くようにTask化。もうできるのはわかっているけど
@@ -25,16 +36,16 @@
 2009-12-19  Shinji Kono  <kono@ie.u-ryukyu.ac.jp>
 
 	SgChange/viewer は大域変数使いすぎ。禁止って言ったのに。
-        linda api は、federated linda 対応でないものが使われている。
-        対応したものは、どこにあるんだろう?
+	linda api は、federated linda 対応でないものが使われている。
+	対応したものは、どこにあるんだろう?
 
-        他の例題いじるのは、自分の例題を動かしてからにして欲しい。
+	他の例題いじるのは、自分の例題を動かしてからにして欲しい。
 
-        まぁねぇ。Pipeline execution するのに、sgpack とかも Pipeline buffer
-        にするのは気づかないものなんだろうな... なくても、動かないことは
-        ないのか。
+	まぁねぇ。Pipeline execution するのに、sgpack とかも Pipeline buffer
+	にするのは気づかないものなんだろうな... なくても、動かないことは
+	ないのか。
 
-        viewer.cc の大域変数を落すところから始めるべきか?
+	viewer.cc の大域変数を落すところから始めるべきか?
 
 2009-11-15  Shinji Kono  <kono@ie.u-ryukyu.ac.jp>
 
@@ -80,7 +91,7 @@
 	       ---------------------------------------
 	data = |   vertex   |   normal   |  texture  | sizeof(data) = size*3
 	       ---------------------------------------
-                \  size    / \   size   / \  size   /
+		\  size    / \   size   / \  size   /
 
 	てな感じで、SceneGraph->data の中に 3 つ入ってたわけです。
 	これだと、アクセスする時にどれがどれかわからんくなるし、
--- a/Renderer/Engine/Makefile	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/Makefile	Tue Nov 22 19:40:47 2011 +0900
@@ -26,7 +26,7 @@
 
 FORCE:
 	-mkdir -p ../../include/Cerium
-	rsync `find . -name Test -prune -or -name spe -prune -or -name task -prune -or -name '*.h' -print` ../../include/Cerium
+	rsync `find . -name Test -prune -or -name spe -prune -or -name task -prune -or -name '*.h' -print|sed -e 's-^./--'` ../../include/Cerium
 
 
 clean:
--- a/Renderer/Engine/SceneGraph.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -135,6 +135,10 @@
       matrix[i]      = 0;
       real_matrix[i] = 0;
     }
+    for (int i = 0; i < 4; i++) {
+      matrix[i*4+i]      = 1;
+      real_matrix[i*4+i] = 1;
+    }
 
 
     finalize = &SceneGraph::finalize_copy;
@@ -210,8 +214,13 @@
     if (size % 3 != 0) {
       printf("vertex size is error. size %% 3 = %lld\n", size % 3);
     }
-
+    /*
+     * MAX_SIZE_TRIANGLE:128
+     */
     if (size > 0) {
+      /* size/3 : 三角形の数?
+       * MAX_SIZE_TRIANGLE : 128
+       */
       pp_num = (size/3 + MAX_SIZE_TRIANGLE - 1) / MAX_SIZE_TRIANGLE;
       pp = (PolygonPack*)manager->allocate(sizeof(PolygonPack)*pp_num);
     } else {
@@ -225,6 +234,7 @@
 
 }
 
+
 SceneGraph::SceneGraph(TaskManager *manager,const char *font,int pixels,Uint32 color,const char *string_name) {
 
     init();
--- a/Renderer/Engine/SceneGraphRoot.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -141,14 +141,14 @@
 
 /*文字列の生成*/
 void
-SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root, 
+SceneGraphRoot::createStringFont(TaskManager *manager, SceneGraphPtr root,
 				 const char *string,int pixels,int screen_w,
 				 int screen_h,Uint32 color)
 {
     SceneGraphPtr text;
   float width_shift = 0;
   int i;
-  int length = strlen(string); 
+  int length = strlen(string);
   for (i = 0; i < length;) {
     int len = 0;
     unsigned char initial = string[i];
@@ -172,7 +172,7 @@
     width_shift += text->seq;
     root->addChild(text);
     get_matrix_scale(text->matrix, text->angle, text->xyz, scale, root->matrix);
-    get_matrix(text->real_matrix, text->angle, text->xyz, root->real_matrix);
+    // get_matrix(text->real_matrix, text->angle, text->xyz, root->real_matrix);
     i += len;
   }
 }
@@ -204,7 +204,11 @@
     xmlNodePtr cur;
     SceneGraphPtr tmp;
 
-    /* パース DOM生成 */
+    /* パース DOM生成
+       xmlParseFile:ファイルに含まれるXML文書を分析する
+       xmlDocGetRootElement:ドキュメントルートを指定する。
+       よって、以下のcurにはドキュメントルートの位置が入っている
+     */
     doc = xmlParseFile(xmlfile);
     cur = xmlDocGetRootElement(doc);
 
@@ -213,24 +217,78 @@
 
     /* XMLのノードを一つずつ解析  */
     for (cur=cur->children; cur; cur=cur->next) {
-	/* 扱うのはsurfaceオンリー  */
-	if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
-	    continue;
-	}
+      /*初期化:curをドキュメントルートの一個下に設定
+	継続条件:curが真である
+	再初期化:次のノードへ
+       */
 
-	/* ポリゴン(SceneGraph)生成  */
-	tmp = new SceneGraph(manager, cur);	
+      /* 扱うのはsurfaceオンリーなので、ノードの名前がsurfaceでないなら
+	 以下の処理を行なわずにスキップする
+      */
+      if (xmlStrcmp(cur->name,(xmlChar*)"surface") != 0) {
+	continue;
+      }
+      
+      /* ポリゴン(SceneGraph)生成
+	 SceneGraph:SceneGraph.cc、L186
+      */
+	tmp = new SceneGraph(manager, cur);
+	
+	//シーングラフを登録
 	registSceneGraph(tmp);
     }
+    //解放
     xmlFreeDoc(doc);
 }
 
 void
+SceneGraphRoot::createFromCOLLADAfile(TaskManager *manager, const char *xmlColladafile)
+{
+	/*make parse dom*/
+	xmlDocPtr doc;
+	xmlNodePtr cur,cur_images,cur_effects,cur_geometries,cur_visual_scenes;
+	SceneGraphPtr tmp;
+
+	doc = xmlParseFile(xmlColladafile);
+	cur = xmlDocGetRootElement(doc);
+
+	/*エラー処理……だけど何書けばいいのか謎。とりあえず-1返してみる*/
+	if(xmlStrcmp(cur->name, (xmlChar*)"COLLADA")){
+		return ;
+       };
+
+	/* node analyze */
+	for(cur=cur->children; cur_images; cur_images=cur_images->next){
+
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_imeges") != 0){
+	    cur_images = cur;
+	    continue;
+	  }
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_effects") != 0){
+	    cur_effects = cur;
+	    continue;
+	  }
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_geometries") != 0){
+	    cur_geometries = cur;
+	    continue;
+	  }
+	  if(xmlStrcmp(cur->name,(xmlChar*)"library_visual_scenes")!=0){
+	    cur_visual_scenes = cur;
+	    continue;
+	  }
+	  
+	  tmp = new SceneGraph(manager, cur);
+	  registSceneGraph(tmp);
+	}
+	xmlFreeDoc(doc);
+}
+
+void
 SceneGraphRoot::createFromXMLmemory(TaskManager *manager, SceneGraph *node, char *data, int len)
 {
     xmlDocPtr doc;
     xmlNodePtr cur;
-    
+
     // size は取れるはず、テスト用に mmap したデータを使う
     /* パース DOM生成 */
 
@@ -247,7 +305,7 @@
 	    continue;
 	}
 	/* ポリゴン(SceneGraph)生成  */
-	SceneGraphPtr original = new SceneGraph(manager, cur);	
+	SceneGraphPtr original = new SceneGraph(manager, cur);
 	registSceneGraph(original);
 	SceneGraphPtr clone = createSceneGraph(original->sgid);
 	node->addChild(clone);
@@ -294,13 +352,13 @@
 	printf("error: createSceneGraph(name): name object not found.\n");
 	return NULL;
     }
-    
+
     /* オリジナルの SceneGraph */
     src = sg_src[id];
 
     /* ユーザーにはオリジナルの clone を返す */
     p = src->clone(this->tmanager);
-    
+
     /* move, collision に sgroot を渡したいのでここで sgroot を渡しておく*/
     p->sgroot = (void *)this;
 
@@ -312,7 +370,7 @@
 int
 SceneGraphRoot::getSgid(const char *name)
 {
-  return sgid_hash.get_sgid(name);    
+  return sgid_hash.get_sgid(name);
 }
 
 int
@@ -348,7 +406,6 @@
     int light_num = 4;
     for (int i = 0; i < light_num; i++) {
 
-	//get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
         get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->real_matrix);
       
 	light_vector[i*4] = 0.0f;
@@ -357,7 +414,7 @@
 	light_vector[i*4+3] = 1.0f;
 
 	ApplyMatrix(&light_vector[i*4], light[i]->matrix);
-      
+
 	light_vector[i*4] /= light_vector[i*4+2];
 	light_vector[i*4+1] /= light_vector[i*4+2];
 
@@ -401,11 +458,11 @@
     while (list) {
 
         list->move_execute(screen_w, screen_h);
-        list->collision_check(screen_w, screen_h, list);	
-        
-	list->frame++; 
+        list->collision_check(screen_w, screen_h, list);
+
+	list->frame++;
         list = list->next;
-    }    
+    }
 
     lightCalc();
 
@@ -425,7 +482,7 @@
 
     sg_exec_tree = camera->children;
 }
-   
+
 void
 SceneGraphRoot::copyTree(SceneGraphPtr t, SceneGraphPtr cur_parent)
 {
@@ -442,11 +499,11 @@
 	    /*親の回転、座標から、子の回転、座標を算出*/
 	    get_matrix(c->matrix, c->angle, c->xyz, cur_parent->matrix);
 	    /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
-	    get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
+	    // get_matrix(c->real_matrix, c->angle, c->xyz, cur_parent->real_matrix);
 	    //get_matrix(c->real_matrix, c->angle, c->xyz, camera->real_matrix);
 
-	} 
-	
+	}
+
 	if (t->children != NULL && c != NULL) {
 	    cur_parent = c;
 	    t = t->children;
@@ -466,12 +523,21 @@
                         t = t->parent;
 		    }
 		}
-	    }	    
+	    }
 	}
     }
 
 }
 
+
+void
+SceneGraphRoot::treeApply(int screen_w, int screen_h)
+{
+    // don't calcurate sg_draw_tree's brother
+    transTree(sg_draw_tree->children, camera);
+}
+
+
 /**
  *     破壊的に変換行列の親子関係を計算する
  */
@@ -487,9 +553,8 @@
 	    /*親の回転、座標から、子の回転、座標を算出*/
 	    matrix4x4(t->matrix,t->matrix,cur_parent->matrix);
 	    /*法線用の行列。Cameraの行列を抜いている(Cameraのコンストラクタで、単位行列にしている)*/
-	    matrix4x4(t->real_matrix,t->real_matrix,cur_parent->real_matrix);
+	    // matrix4x4(t->real_matrix,t->real_matrix,cur_parent->real_matrix);
 	} 
-	
 	if (t->children != NULL && c != NULL) {
 	    cur_parent = t;
 	    t = t->children;
@@ -509,7 +574,7 @@
                         t = t->parent;
 		    }
 		}
-	    }	    
+	    }
 	}
     }
 
@@ -520,31 +585,31 @@
 */
 void
 SceneGraphRoot::move_finish()
-{    
-    list->collision_check(screen_w, screen_h, list);	
+{
+    list->collision_check(screen_w, screen_h, list);
 
-    list->frame++; 
+    list->frame++;
     //list = list->next;
 
     int light_num = 4;
     for (int i = 0; i < light_num; i++) {
 
 	get_matrix(light[i]->matrix, light[i]->angle, light[i]->xyz, camera->matrix);
-      
+
 	light_vector[i*4] = 0.0f;
 	light_vector[i*4+1] = 0.0f;
 	light_vector[i*4+2] = 0.0f;
 	light_vector[i*4+3] = 1.0f;
 
 	ApplyMatrix(&light_vector[i*4], light[i]->matrix);
-      
+
 	light_vector[i*4] /= light_vector[i*4+2];
 	light_vector[i*4+1] /= light_vector[i*4+2];
 
 	light_vector[i*4+2] *= -1;
 	light_vector[i*4+3] *= -1;
-    }    
-    
+    }
+
     //sgchange->viewer->light_xyz_stock = getLightVector();
 }
 
@@ -565,7 +630,7 @@
 SceneGraphRoot::allRemove(SceneGraphPtr list)
 {
     SceneGraphPtr p = list;
-    
+
     while (p) {
 	SceneGraphPtr p1 = p->next;
 	delete p;
@@ -579,7 +644,7 @@
 {
     SceneGraphPtr p = sg_available_list;
     SceneGraphPtr p1;
-    
+
     while (p) {
 	p1 = p->next;
 	if (p->isRemoved()) {
@@ -605,7 +670,7 @@
 	if (!t->isRemoved()) {
 	    if (t->name) printf("name: %s ",t->name);
 	    printf("x=%g y=%g z=%g\n",t->xyz[0],t->xyz[1],t->xyz[2]);
-	} 
+	}
 	if (t->children != NULL) {
 	    t = t->children;
 	} else if (t->brother != NULL) {
@@ -623,7 +688,7 @@
                         t = t->parent;
 		    }
 		}
-	    }	    
+	    }
 	}
     }
 }
--- a/Renderer/Engine/SceneGraphRoot.h	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Tue Nov 22 19:40:47 2011 +0900
@@ -91,6 +91,7 @@
     void createStringFont(TaskManager *manager, SceneGraphPtr root,const char *string, int pixeles, int screen_w,int screen_h, Uint32 color);
     void createFont(TaskManager *manager,const char *font,int pixels,Uint32 color,const char *filename, int len, char **obj_name);    
     void createFromXMLfile(TaskManager *manager, const char *);
+    void createFromCOLLADAfile(TaskManager *manager, const char *);
     void createFromXMLmemory(TaskManager *manager, SceneGraph * node, char *data, int len);
     SceneGraphPtr createSceneGraph(int id);
     SceneGraphPtr createSceneGraph();
@@ -123,6 +124,7 @@
 
     /* Other System API */
     void allExecute(int screen_w, int screen_h);
+    void treeApply(int screen_w, int screen_h);
     void lightCalc();
     void flip();
     void copyTree(SceneGraphPtr from, SceneGraphPtr to);
--- a/Renderer/Engine/matrix_calc.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/matrix_calc.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -5,12 +5,6 @@
 #include "matrix_calc.h"
 using namespace std;
 
-void noMoreMemory()
-{
-  cout << "can't allocate memory\n";
-  exit(1);
-}
-
 void
 transMatrix(float *m0, float *m1, float *v)
 {
@@ -40,17 +34,16 @@
 
     for (int i = 0; i < 4; i++) {
 	for (int j = 0; j < 4; j++) {
-	    m[i*4+j] = m1[j*4+i];
+	    m0[i*4+j] = m[i*4+j] = m1[j*4+i];
 	}
     }
 
-    m[12] = -(m1[12]*m[0] + m1[13]*m[1] + m1[14]*m[2]);
-    m[13] = -(m1[12]*m[4] + m1[13]*m[5] + m1[14]*m[6]);
-    m[14] = -(m1[12]*m[8] + m1[13]*m[9] + m1[14]*m[10]);
-    m[3] = m[7] = m[11] = 0.0f;
-    m[15] = 1.0f;
+    m0[12] = -(m1[12]*m[0] + m1[13]*m[1] + m1[14]*m[2]);
+    m0[13] = -(m1[12]*m[4] + m1[13]*m[5] + m1[14]*m[6]);
+    m0[14] = -(m1[12]*m[8] + m1[13]*m[9] + m1[14]*m[10]);
+    m0[3] = m0[7] = m0[11] = 0.0f;
+    m0[15] = 1.0f;
 
-    memcpy(m0, m, sizeof(float)*16);
 }
 
 /**
@@ -67,6 +60,7 @@
     }
 }
 
+
 /**
  * ベクトルの正規化
  *
@@ -117,13 +111,14 @@
 {
     float t[16];
 
+    // こういう小細工よりベクタ使った方が良いんだが
     for (int i = 0; i < 4; i++) {
-	for (int j = 0; j < 4; j++) {
+	for (int j = i+1; j < 4; j++) {
+	    float tmp = t[j*4+i];
 	    t[i*4+j] = m1[j*4+i];
+	    m1[j*4+i] = tmp;
 	}
     }
-
-    memcpy(m0, t, sizeof(float)*16);
 }
 
 /**
@@ -149,6 +144,17 @@
     }
 }
 
+void matrix4x4R(float xyz[16], float xyz1[16], float xyz2[16]) 
+{
+  for(int t=0; t<16; t+=4)
+    {
+      for(int i=0; i<4; i++)
+	{
+	  xyz[t+i] = xyz1[t]*xyz2[i] + xyz1[t+1]*xyz2[4+i] + xyz1[t+2]*xyz2[8+i] + xyz1[t+3]*xyz2[12+i];
+	}
+    }
+}
+
 /**
  *   c_xyz を中心に sacle 倍する
  */
@@ -185,9 +191,9 @@
 get_matrix( float *matrix, float *rxyz, float *txyz, float *stack)
 {
   float radx,rady,radz;
-  radx = rxyz[0]*3.141562/180;
-  rady = rxyz[1]*3.141562/180;
-  radz = rxyz[2]*3.141562/180;
+  radx = rxyz[0]*M_PI/180;
+  rady = rxyz[1]*M_PI/180;
+  radz = rxyz[2]*M_PI/180;
 
   float sinx = sin(radx);
   float cosx = cos(radx);
@@ -228,9 +234,9 @@
 get_matrix_scale( float *matrix, float *rxyz, float *txyz, float *scale, float *stack)
 {
   float radx,rady,radz;
-  radx = rxyz[0]*3.14/180;
-  rady = rxyz[1]*3.14/180;
-  radz = rxyz[2]*3.14/180;
+  radx = rxyz[0]*M_PI/180;
+  rady = rxyz[1]*M_PI/180;
+  radz = rxyz[2]*M_PI/180;
 
   float sinx = sin(radx)*scale[0];
   float cosx = cos(radx)*scale[0];
@@ -267,9 +273,43 @@
 
 }
 
+void
+rotate_matrix( float m[16], float rxyz[4] )
+{
+  float radx,rady,radz;
+  radx = rxyz[0]*M_PI/180;
+  rady = rxyz[1]*M_PI/180;
+  radz = rxyz[2]*M_PI/180;
+
+  float sinx = sin(radx);
+  float cosx = cos(radx);
+  float siny = sin(rady);
+  float cosy = cos(rady);
+  float sinz = sin(radz);
+  float cosz = cos(radz);
+
+  /* View Transform */
+  m[0] = cosz*cosy+sinz*sinx*siny;
+  m[1] = sinz*cosx;
+  m[2] = -cosz*siny+sinz*sinx*cosy;
+  m[3] = 0;
+  m[4] = -sinz*cosy+cosz*sinx*siny;
+  m[5] = cosz*cosx;
+  m[6] = sinz*siny+cosz*sinx*cosy;
+  m[7] = 0;
+  m[8] = cosx*siny;
+  m[9] = -sinx;
+  m[10] = cosx*cosy;
+  m[11] = 0;
+  m[12] = 0;
+  m[13] = 0;
+  m[14] = 0;
+  m[15] = 1;
+}
+
 void rotate_x(float *xyz, float r)
 {
-  float rad = r*3.14/180;
+  float rad = r*M_PI/180;
 
   xyz[0] = xyz[0];
   xyz[1] = xyz[1]*cos(rad) - xyz[2]*sin(rad);
@@ -278,7 +318,7 @@
 
 void rotate_y(float *xyz, float r)
 {
-  float rad = r*3.14/180;
+  float rad = r*M_PI/180;
 
   xyz[0] = xyz[0]*cos(rad) + xyz[2]*sin(rad);
   xyz[1] = xyz[1];
@@ -287,7 +327,7 @@
 
 void rotate_z(float *xyz, float r)
 {
-  float rad = r*3.14/180;
+  float rad = r*M_PI/180;
 
   xyz[0] = xyz[0]*cos(rad) - xyz[1]*sin(rad);
   xyz[1] = xyz[0]*sin(rad) + xyz[1]*cos(rad);
--- a/Renderer/Engine/polygon.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/polygon.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -56,8 +56,12 @@
 
       TrianglePackPtr tri =  pp[i].tri;
       // TrianglePack の size のチェック
+      
       int tri_size = (count < MAX_SIZE_TRIANGLE) ? count : MAX_SIZE_TRIANGLE ;
+      
+      //それを構造体に登録
       pp[i].info.size = tri_size;
+      
 
       for (int j = 0; j < tri_size; j++) {
 
--- a/Renderer/Engine/task/DrawSpan.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/task/DrawSpan.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -65,8 +65,7 @@
 static    int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
 // static    void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
 
-static int getDrawParam(SchedTask *smanager, Gptr g, SpanPtr span, int localy, int startx, 
-                       int endx, int index, int j, DrawParamPtr param);
+//static int getDrawParam(SchedTask *smanager, Gptr g, SpanPtr span, int localy, int startx, int endx, int index, int j, DrawParamPtr param);
 
 static    int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z,
                                   SchedTask *smanager,int x, int y, float z, int world_x, int world_y, float world_z);
@@ -469,7 +468,7 @@
 
     return ret;
 }
-
+#if 0
 static int
 getDrawParam(SchedTask *smanager, Gptr g, SpanPtr span, int localy, int startx, int endx, int index, int j, DrawParamPtr param) {
 
@@ -536,6 +535,7 @@
     return 1; 
 
 }
+#endif
 
 static int
 infinity_light_calc(int color,float normal_x, float normal_y,
--- a/Renderer/Engine/viewer.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -293,6 +293,8 @@
 	} else {
 	    sgroot->allExecute(width, height);	
 	}
+    } else {
+	sgroot->treeApply(width, height);	
     }
 
     light_xyz_stock = sgroot->getLightVector();
--- a/Renderer/Test/xml_file/Ball.xml	Tue Nov 22 19:26:18 2011 +0900
+++ b/Renderer/Test/xml_file/Ball.xml	Tue Nov 22 19:40:47 2011 +0900
@@ -4345,4 +4345,4 @@
 			vLPuT//Z
 		</image>
 	</surface>
-</OBJECT-3D>
\ No newline at end of file
+</OBJECT-3D>
--- a/TaskManager/Fifo/ReferencedDmaManager.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/TaskManager/Fifo/ReferencedDmaManager.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -5,5 +5,10 @@
 void *
 ReferencedDmaManager::dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask)
 {
+#ifdef __CERIUM_FIFO__
+	asm("prefetcht0 %0"::"m"(addr):"memory");
+#endif // __CERIUM_FIFO__
+
 	return (void*)addr;
 }
+
--- a/TaskManager/Fifo/ReferencedDmaManager.h	Tue Nov 22 19:26:18 2011 +0900
+++ b/TaskManager/Fifo/ReferencedDmaManager.h	Tue Nov 22 19:40:47 2011 +0900
@@ -7,7 +7,7 @@
 
 public:
 	/* functions */
-    void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask);
+    virtual void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask);
 } ;
 
 #endif/* REFERENCED_DMA_MANAGER */
--- a/TaskManager/Makefile.def	Tue Nov 22 19:26:18 2011 +0900
+++ b/TaskManager/Makefile.def	Tue Nov 22 19:40:47 2011 +0900
@@ -29,8 +29,8 @@
 
 ABIBIT = 64
 
-OPT = -g -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE
-# OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE 
+# OPT = -g -O0 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE
+OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE 
 
 
 
--- a/TaskManager/kernel/schedule/SchedTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -97,7 +97,8 @@
     run(this, readbuf, writebuf);
 	//;TODO
 	//ReferencedDmaManagerを使う場合ここでfreeすると、wordcountが動かない
-    //free(readbuf);
+	//wordcountのmain.ccのrun16が実行されるときに、readbufをポインタで受けてる
+    free(readbuf);
 	
 
     // 書き込む領域がなければ無視
--- a/example/Eratosthenes/Func.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-enum {
-#include "SysTasks.h"
-	Prime,
-	SaveTask,
-	PrintTask,
-};
--- a/example/Eratosthenes/Makefile	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-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
--- a/example/Eratosthenes/Makefile.cell	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-include ./Makefile.def
-
-ABIBIT=32
-CFLAGS += -m$(ABIBIT)  -D__CERIUM_CELL__
-
-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) $(CFLAGS) -o $@ $(OBJS) $(TASK_OBJS) $(LIBS)
-
-speobject:
-	cd spe; $(MAKE) ABIBIT=$(ABIBIT)
-
-run:
-	./$(TARGET) -cpu 6 
-
-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/Eratosthenes/Makefile.def	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-TARGET = prime
-
-# include/library path
-# ex  macosx
-#CERIUM = /Users/gongo/Source/Cerium
-
-# ex  linux/ps3
-CERIUM = ../../../Cerium
-
-CC      = g++
-#CFLAGS  = -O9 -Wall
-CFLAGS  = -g -Wall
-
-INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L${CERIUM}/TaskManager
--- a/example/Eratosthenes/Makefile.linux	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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 += -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/\#*
--- a/example/Eratosthenes/Makefile.macosx	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +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 += -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/\#*
--- a/example/Eratosthenes/README	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-- 概要
-
-指定された範囲の素数を計算するプログラムです。
-
-- 実行方法
-
-% ./prime [-num number] [-print]
-
-  -num		出力する素数の範囲   
-  -print	計算した素数を出力
-
-- 実行例 (-cpu は Cerium 標準のオプションです)
-
-% ./prime -num 100 -print -cpu 6
-0 1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 
-
--- a/example/Eratosthenes/bitmap.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-#ifndef BITMAP_H_
-#define BITMAP_H_
-/*
- * $Id: bitmap.c,v 0.2 2010/07/27 15:27:02 dankogai Exp dankogai $
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include "bitmap.h"
-
-typedef struct {
-    int    fd;
-    size_t size;
-    char  *map;
-} bitmap;
-
-
-extern "C" {
-	bitmap *bitmap_free(bitmap *b);
-	bitmap *bitmap_new(size_t size, const char *filename);
-	int bitmap_save(bitmap *b, const char *filename);
-	void bitmap_fill(bitmap *b, int val);
-	inline int bitmap_set(bitmap *b, size_t where, int val);
-	inline int bitmap_get(bitmap *b, size_t where);
-}
-
-bitmap *bitmap_free(bitmap *b){
-    if (b){
-        if (b->map) {
-            if (b->fd){
-                munmap(b->map, b->size);
-                close(b->fd);
-            }else{
-                free(b->map);
-            }
-        }
-        free(b);
-    }
-    return (bitmap *)NULL;
-}
-
-bitmap *bitmap_new(size_t size, const char *filename){
-    bitmap *b = (bitmap *)malloc(sizeof(bitmap));
-    struct stat st;
-    if (!b) return (bitmap *)NULL;
-    if (filename){
-        b->fd = open(filename, 
-                     size ? O_RDWR|O_CREAT : O_RDONLY, 
-                     size ? (mode_t)0644   : (mode_t)0444);
-        if (b->fd == -1) {
-            perror(filename);
-            return bitmap_free(b);
-        }
-        if (size){
-            if (ftruncate(b->fd, size >> 3) == -1){
-                perror(filename);
-                return bitmap_free(b);
-            }
-            b->map = (char *)mmap(0, size >> 3, PROT_READ|PROT_WRITE,
-                                  MAP_SHARED, b->fd, 0);
-
-        }
-        else{
-            fstat(b->fd, &st);
-            size = st.st_size << 3;
-            b->map = (char *)mmap(0, size >> 3, PROT_READ, 
-                                  MAP_PRIVATE, b->fd, 0);
-        }
-        if (b->map == MAP_FAILED) return bitmap_free(b);
-    }
-    else{
-        if (!size) return (bitmap *)NULL;
-        b->map = (char *)malloc(size >> 3);
-        if (!b->map) return bitmap_free(b);
-        b->fd = 0;
-    }
-    b->size = size;
-    return b;
-}
-
-int bitmap_save(bitmap *b, const char *filename){
-    int ok = 0, fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, (mode_t)0644);
-    if (fd != -1){
-        if (write(fd, b->map, (b->size >> 3)) != -1) ok = 1;
-    }
-    if (!ok) perror(filename);
-    close(fd);
-    return ok;
-}
-
-void bitmap_fill(bitmap *b, int val){
-    size_t i;
-    for (i = 0; i < (b->size >> 3); i++) b->map[i] = val ? 0xff : 0;
-}
-
-static const int bits[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
-
-inline int bitmap_set(bitmap *b, size_t where, int val){
-    if (val) b->map[where >> 3] |=  bits[where & 7];
-    else b->map[where >> 3] &= ~bits[where & 7];
-    return val;
-}
-
-inline int bitmap_get(bitmap *b, size_t where){
-    return !!(b->map[where >> 3] & bits[where & 7]);
-}
-
-#ifdef TEST
-#include <errno.h>
-int main (int argc, char **argv){
-    bitmap *b = bitmap_new(4096, (argc > 1 ? argv[1] : NULL));
-    if (!b) return errno;
-    bitmap_set(b, 0, 1);
-    printf("%d\n", bitmap_get(b, 0));
-    bitmap_free(b);
-    return 0;
-}
-#endif
-
-#endif
--- a/example/Eratosthenes/main.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-#include <math.h>
-#include "TaskManager.h"
-#include "Func.h"
-
-#include <stdint.h>
-typedef uint32_t U32;
-typedef uint64_t U64;
-
-#include "bitmap.h"
-
-const char* const sieveFile = "sieve32.bm";
-
-/* task_initを宣言 */
-extern void task_init(void);
-
-/* TaskManagerを宣言 */
-extern TaskManager *manager;
-
-static U64 start = 0;
-static U64 size  = 1000 * 1000 * 1000;
-static bool print_flag = false;
-
-/* help文章 */
-const char *usr_help_str = "Usage: ./prime [-cpu spe_num] [-num N]\n\
-							-cpu    Number of SPE (default 1) \n\
-							-start 	Calculate of Prime scope start (default 0) \n\
-							-size	Calculate of Prime scope size (default 1000 * 1000 * 1000)";
-
-	int
-init(int argc, char **argv)
-{
-	for (int i = 1; argv[i]; ++i) {
-		if (strcmp(argv[i], "-start") == 0) {
-			start = atoll(argv[++i]);
-		}
-		else if (strcmp(argv[i], "-size") == 0) {
-			size = atoll(argv[++i]);
-		}
-		else if (strcmp(argv[i], "-print") == 0) {
-			print_flag = true;
-		}
-	}
-	return 0;
-}
-
-	void
-prime_init(TaskManager *manager)
-{
-	bitmap *sieve = bitmap_new(0, sieveFile);
-	if (!sieve) {
-		perror(sieveFile);
-		exit(errno);
-	}
-
-	bitmap *b = bitmap_new(size >> 1, NULL);
-	bitmap_fill(b, 1);
-	if (start == 0) bitmap_set(b, 0, 0); // 1は素数ではない
-	U64 pmax = (U64)sqrtl(start+size);
-
-	HTask *save = manager->create_task(SaveTask);
-
-	HTask *print = manager->create_task(PrintTask);
-
-
-#ifdef VERBOSE
-	printf("pmax = %llu\n", pmax);
-#endif
-	U64 p, i;
-	for (p = 3; p < pmax;) {
-
-#ifndef VERBOSE
-		printf("sieving %llu\r", p);
-		fflush(stdout);
-#endif
-
-		HTask *prime = manager->create_task(Prime);
-		prime->set_param(0, b);
-		prime->set_param(1, p); // ふるいの値
-		prime->set_param(2, start);
-		prime->set_param(3, size);
-		prime->set_cpu(SPE_ANY);
-
-		save->wait_for(prime);
-
-		prime->spawn();
-
-		for(p += 2; !bitmap_get(sieve, p>>1); p += 2);
-	}
-
-    char filename[256];
-    snprintf(filename, 256, "%llu~%llu.bm", start, start+size);
-
-	save->set_param(0, b);
-	save->set_param(1, filename);
-	save->set_cpu(CPU_PPE);
-
-	print->wait_for(save);
-
-#ifdef VERBOSE
-		printf("saving %s\n", filename);
-#endif
-
-	save->spawn();
-
-	if ( print_flag ) {
-		print->set_param(0, b);
-		print->set_param(1, start);
-		print->spawn();
-	}
-
-}
-
-	int
-TMmain(TaskManager *manager, int argc, char *argv[])
-{
-	if (init(argc, argv) < 0) {
-		return -1;
-	}
-
-	task_init();
-	prime_init(manager);
-
-	return 0;
-}
--- a/example/Eratosthenes/ppe/.#Hello.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-e065746@nakasone-hiroki-no-macbook.local.1456
\ No newline at end of file
--- a/example/Eratosthenes/ppe/Prime.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include "SchedTask.h"
-#include "Prime.h"
-#include "Func.h"
-
-#include <stdint.h>
-typedef uint32_t U32;
-typedef uint64_t U64;
-
-#include "bitmap.h"
-
-SchedDefineTask1(Prime, prime);
-
-	static int
-prime(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-	bitmap *b = (bitmap*)smanager->get_param(0);
-	U64 p	  = (U64)smanager->get_param(1);
-	U64 start = (U64)smanager->get_param(2);
-	U64 size  = (U64)smanager->get_param(3);
-
-
-	for ( U64 i = p + p - (start % p) ; i <= size; i += p) {
-		if ((i & 1) == 0) continue;
-		bitmap_set( b, i>>1, 0);
-	}
-
-	return 0;
-}
--- a/example/Eratosthenes/ppe/Prime.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef INCLUDED_TASK_PRIME
-#define INCLUDED_TASK_PRIME
-
-#include "SchedTask.h"
-
-#endif
--- a/example/Eratosthenes/ppe/PrintTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include "SchedTask.h"
-#include "PrintTask.h"
-#include "Func.h"
-
-#include "bitmap.h"
-
-SchedDefineTask1(PrintTask, print);
-
-	static int
-print(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-	bitmap *b = (bitmap*)smanager->get_param(0);
-	unsigned long long offset = (unsigned long long)smanager->get_param(1);
-
-    size_t i;
-    for (i = 0; i < b->size; i++){
-        if (bitmap_get(b, i)) printf("%llu ", offset + (i<<1) + 1);
-    }
-
-	return 0;
-}
--- a/example/Eratosthenes/ppe/PrintTask.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef INCLUDED_TASK_PRINTTASK
-#define INCLUDED_TASK_PRINTTASK
-
-#include "SchedTask.h"
-
-#endif
--- a/example/Eratosthenes/ppe/SaveTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-#include <stdio.h>
-#include "SchedTask.h"
-#include "SaveTask.h"
-#include "Func.h"
-
-#include "bitmap.h"
-
-SchedDefineTask1(SaveTask, save);
-
-	static int
-save(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-	bitmap *b = (bitmap*)smanager->get_param(0);
-	char *filename = (char*)smanager->get_param(1);
-
-	bitmap_save(b, filename);
-
-	return 0;
-}
--- a/example/Eratosthenes/ppe/SaveTask.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef INCLUDED_TASK_SAVETASK
-#define INCLUDED_TASK_SAVETASK
-
-#include "SchedTask.h"
-
-#endif
--- a/example/Eratosthenes/ppe/task_init.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-#include "Func.h"
-#include "Scheduler.h"
-
-SchedExternTask(Prime);
-SchedExternTask(SaveTask);
-SchedExternTask(PrintTask);
-
-	void
-task_init()
-{
-	SchedRegister(Prime);
-	SchedRegister(SaveTask);
-	SchedRegister(PrintTask);
-}
--- a/example/Eratosthenes/spe/Makefile	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-include ../Makefile.def
-
-TARGET = ../spe-main
-
-SRCS_TMP = $(wildcard *.cc)
-SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
-OBJS = $(SRCS:.cc=.o)
-
-CC      = spu-g++  -D__CERIUM_CELL__ -DABIBIT=$(ABIBIT)
-CFLAGS  = -O9 -g -Wall -fno-exceptions -fno-rtti#-DDEBUG
-INCLUDE = -I../${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L../${CERIUM}/TaskManager -lspemanager  -Wl,--gc-sections 
-
-.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 *~ \#*
--- a/example/Eratosthenes/spe/Prime.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <math.h>
-#include "SchedTask.h"
-#include "Prime.h"
-#include "Func.h"
-
-SchedDefineTask1(Prime, prime);
-
-	static int
-prime(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-	int start = (int)smanager->get_param(0);	/* 素数判定の開始地点 */
-	int end   = (int)smanager->get_param(1);	/* 素数判定の終了地点 */
-	int range = end - start;					/* 判定する範囲		  */
-
-	/* 判定結果を収める配列を受け取る */
-	int *output = (int*)smanager->get_output(wbuf, 0);
-
-	/* 初期化 */
-	for (int i = 0; i < range; i++){
-		output[i] = 1;
-	}
-
-
-	for (int i = start, index = 0; i < end; i++, index++) {
-		int limit = (int)sqrt((double) i);		/* 割る数の最大値を求める */
-		for (int j = 2; j <= limit; j++) {
-			/* 割り切れた場合、0を代入し素数じゃないという判定を下す */
-			if (i % j == 0) {
-				output[index] = 0;
-				break;
-			}
-		}
-	}
-	return 0;
-}
--- a/example/Eratosthenes/spe/Prime.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef INCLUDED_TASK_PRIME
-#define INCLUDED_TASK_PRIME
-
-#include "SchedTask.h"
-
-#endif
--- a/example/Eratosthenes/spe/PrintTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include <stdio.h>
-#include "SchedTask.h"
-#include "PrintTask.h"
-#include "Func.h"
-
-SchedDefineTask1(PrintTask, print);
-
-	static int
-print(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-	int print_flag = (long)smanager->get_param(1);		//プリントするかどうか
-
-	if (print_flag < 0) {
-		return 0;
-	}
-
-	int length = (int)smanager->get_param(0);			/* 出力する範囲 */
-	int *input = (int*)smanager->get_input(rbuf, 0);	/* 出力する配列 */
-
-	/* 素数の判定結果が1ならば出力する */
-	for (int i = 0; i < length; i++) {
-		if ( input[i] == 1 ) {
-			printf("%d ",i);
-		}
-	}
-	printf("\n");
-	return 0;
-}
--- a/example/Eratosthenes/spe/PrintTask.h	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#ifndef INCLUDED_TASK_PRINTTASK
-#define INCLUDED_TASK_PRINTTASK
-
-#include "SchedTask.h"
-
-#endif
--- a/example/Eratosthenes/spe/spe-main.cc	Tue Nov 22 19:26:18 2011 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#include "Func.h"
-#include "Scheduler.h"
-
-SchedExternTask(Prime);
-SchedExternTask(PrintTask);
-
-void
-task_init(Scheduler *s)
-{
-	SchedRegister(Prime);
-	SchedRegister(PrintTask);
-}
-
--- a/example/Miller_Rabin/Makefile.def	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/Miller_Rabin/Makefile.def	Tue Nov 22 19:40:47 2011 +0900
@@ -9,7 +9,8 @@
 
 CC      = g++
 CFLAGS  = -O9 -Wall
-#CFLAGS  = -g -Wall
+#CFLAGS  = -g -O0 -Wall
+#CFLAGS  = -pg -Wall
 
 INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
 LIBS = -L${CERIUM}/TaskManager
--- a/example/Miller_Rabin/main.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/Miller_Rabin/main.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -38,7 +38,7 @@
 prime_init(TaskManager *manager)
 {
 
-	U64 div_size = 1000;
+	U64 div_size = 256;
 	U64 task_num = (num + div_size - 1) / div_size;
 
 	bool *output = (bool*)manager->allocate(sizeof(bool)*(task_num*div_size >> 1)); /* 判定結果を収める配列 */
@@ -62,7 +62,7 @@
 	}
 
 	/* 出力用のタスクに判定結果を収めた配列を渡す */ 
-	print->set_inData(0,output,sizeof(bool)*task_num*div_size);
+	print->set_inData(0,output,sizeof(bool)*(task_num*div_size >> 1));
 	/* 出力する数を渡す */
 	print->set_param(0,(memaddr)num);
 	/* printするかどうかを渡す */
--- a/example/Miller_Rabin/ppe/PrintTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/Miller_Rabin/ppe/PrintTask.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -19,13 +19,14 @@
 	U64 size = ((U64)smanager->get_param(0)) >> 1;			/* 出力する範囲 */
 	bool *input = (bool*)smanager->get_input(rbuf, 0);	/* 出力する配列 */
 	
-	printf("%d\n",(int)2);
+	printf("%d ",(int)2);
 
 	/* 素数の判定結果が1ならば出力する */
 	for (U64 i = 1; i < size; i++) {
 		if ( input[i] == true ) {
-			printf("%llu\n",i*2+1);
+			printf("%llu ",i*2+1);
 		}
 	}
+	printf("\n");
 	return 0;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Miller_Rabin/run.sh	Tue Nov 22 19:40:47 2011 +0900
@@ -0,0 +1,14 @@
+#!/bin/zsh
+
+a=1
+while [ $a -le 24 ]
+do
+	b=0
+	while [ $b -le 5 ]
+	do
+		echo -n "CPU_NUM $a "
+		(time $* -cpu $a) 1>/dev/null
+		b=`expr $b + 1`
+	done
+	a=`expr $a + 1`
+done
--- a/example/Miller_Rabin/spe/PrintTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/Miller_Rabin/spe/PrintTask.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -19,13 +19,14 @@
 	U64 size = ((U64)smanager->get_param(0)) >> 1;			/* 出力する範囲 */
 	bool *input = (bool*)smanager->get_input(rbuf, 0);	/* 出力する配列 */
 	
-	printf("%d\n",(int)2);
+	printf("%d ",(int)2);
 
 	/* 素数の判定結果が1ならば出力する */
 	for (U64 i = 1; i < size; i++) {
 		if ( input[i] == true ) {
-			printf("%llu\n",i*2+1);
+			printf("%llu ",i*2+1);
 		}
 	}
+	printf("\n");
 	return 0;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/Miller_Rabin/time.sh	Tue Nov 22 19:40:47 2011 +0900
@@ -0,0 +1,4 @@
+#!/bin/zsh
+
+./run.sh $* |& awk '{cpu[$2]+=$12; total[$2]++;} END {for(i in cpu){ ans=cpu[i]/total[i]; print "CPU" i "\t" ans }}' 
+
--- a/example/Prime/ppe/PrintTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/Prime/ppe/PrintTask.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -23,8 +23,9 @@
 	/* 素数の判定結果が1ならば出力する */
 	for (long i = 0; i < length; i++) {
 		if ( input[i] == true ) {
-			printf("%ld\n",i);
+			printf("%ld ",i);
 		}
 	}
+	printf("\n");
 	return 0;
 }
--- a/example/Prime/spe/PrintTask.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/Prime/spe/PrintTask.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -23,8 +23,9 @@
 	/* 素数の判定結果が1ならば出力する */
 	for (long i = 0; i < length; i++) {
 		if ( input[i] == true ) {
-			printf("%ld\n",i);
+			printf("%ld ",i);
 		}
 	}
+	printf("\n");
 	return 0;
 }
--- a/example/many_task/Makefile.def	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/many_task/Makefile.def	Tue Nov 22 19:40:47 2011 +0900
@@ -6,7 +6,8 @@
 
 CERIUM = ../../../Cerium
 
-OPT = -g -O9
+OPT = -O9
+# OPT = -g -O9
 # OPT = -g
 CC      = g++
 CFLAGS  =  -DUSE_SIMPLE_TASK -Wall  $(OPT)
--- a/example/word_count/main.cc	Tue Nov 22 19:26:18 2011 +0900
+++ b/example/word_count/main.cc	Tue Nov 22 19:40:47 2011 +0900
@@ -11,6 +11,10 @@
 #include "Func.h"
 #include "WordCount.h"
 
+/* ;TODO
+ * PS3でCPU数が2以上の時に、あまりが計算されてない
+ */
+
 extern void task_init();
 
 int all = 0;
@@ -222,6 +226,7 @@
 	    h_exec->spawn();
 	    
 	    w->size -= size;
+		if (w->size == 0) break;
 	    w->task_num--;
 	    
 	  }