changeset 1123:2a63ba2c9506 draft

bug fix.
author yutaka@localhost.localdomain
date Fri, 11 Feb 2011 06:09:32 +0900
parents ec6b55aed337
children c43f49400c22
files Renderer/Engine/SceneGraph.cc Renderer/Engine/spe/DrawSpan.cc TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/CellTaskManagerImpl.h TaskManager/Cell/spe/CellDmaManager.cc TaskManager/Cell/spe/CellDmaManager.h TaskManager/ChangeLog TaskManager/kernel/main.cc TaskManager/kernel/memory/MemHash.cc TaskManager/kernel/memory/MemHash.h TaskManager/kernel/schedule/Scheduler.cc example/word_count/main.cc
diffstat 12 files changed, 72 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -475,7 +475,7 @@
     SDL_Surface *texture_image = IMG_Load(image_name);
     if (!texture_image) return 0;
     SDL_Surface *tmpImage
-        = SDL_CreateRGBSurface(SDL_SWSURFACE, texture_image->w,
+        = SDL_CreateRGBSurface(SDL_HWSURFACE, texture_image->w,
                              texture_image->h, 32, redMask,
                             greenMask, blueMask, alphaMask);
 
--- a/Renderer/Engine/spe/DrawSpan.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/Renderer/Engine/spe/DrawSpan.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -226,6 +226,7 @@
 
     //完全に透けているか判断
     int flag = (alpha != 0);
+
     int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch);
     //smanager->printf("sys %d\n",light_sysswitch);
 
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -167,24 +167,29 @@
        ppeManager->run();
        return;
     }
-    do {
-        // PPE side
-	ppeManager->poll();
-        // SPE side
-	do {
-	    poll();
-	} while (ppeManager->activeTaskQueue->empty() && spe_running >0 );
-	if (spe_running < spu_limit) {
-	  debug_check_spe_idle(ppeManager->activeTaskQueue, spe_running);
-	} 
-    } while (!ppeManager->activeTaskQueue->empty() || 
-	     !activeTaskQueue->empty() ||
-	     spe_running >0); 
-    if (!waitTaskQueue->empty()) {
-      show_dead_lock_info();
-    }
+ 
+     do {
+       // PPE side
+       ppeManager->poll();
+       // SPE side
+       do {
+	 poll();
+       } while (ppeManager->activeTaskQueue->empty() && spe_running >0 );
+       
+       if (spe_running < spu_limit) {
+	 debug_check_spe_idle(ppeManager->activeTaskQueue, spe_running);
+       } 
+       
+     } while (!ppeManager->activeTaskQueue->empty() || 
+	      !activeTaskQueue->empty() ||
+	      spe_running >0); 
+     if (!waitTaskQueue->empty()) {
+       show_dead_lock_info();
+     }
+     
 }
 
+
 static void
 loop_check(HTask *p,HTask *me, int depth)
 {
--- a/TaskManager/Cell/CellTaskManagerImpl.h	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.h	Fri Feb 11 06:09:32 2011 +0900
@@ -25,6 +25,8 @@
     void init(int spuIdle);
     void run();
     void poll();
+    void poll1(int spu_limit);
+    void poll2(int spu_limit);
     void mail_check(int id);
     //void set_runTaskList(*QueueInfo<HTask>);
     void set_runTaskList(QueueInfo<HTask>* activeTaskQueue);
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -68,11 +68,6 @@
 
     global_wait_time += wait;
 
-  if (cmd == TaskArray) {
-    task_array_load_time += wait;
-  } else if (cmd == TaskArray1) {
-  }
-
 }
 
 void CellDmaManager::mail_write(memaddr data)
@@ -161,8 +156,10 @@
     memaddr data = (memaddr)spu_read_in_mbox();
     (this->*end_dmawait_profile)(&wait);
 
+
     task_list_mail_time += wait;
     global_mail_time += wait;
+    task_list_read_count += 1;
 
     return data;
 }
@@ -194,8 +191,8 @@
     global_busy_time = 0;
     global_mail_time = 0;
     global_wait_time = 0;
-    task_array_load_time = 0;
     task_list_mail_time = 0;
+    task_list_read_count = 0;
     start_dmawait_profile =  &CellDmaManager::do_start_dmawait_profile;
     end_dmawait_profile =  &CellDmaManager::do_end_dmawait_profile;  
 
@@ -268,18 +265,19 @@
   " mail_time = %lld(%.3g%%), " 
   " task_list_mail_time = %lld(%.3g%%), " 
   " busy_ratio = %.3g%%, "
-  " array_load_time = %lld, "
+  " task_list_read_count = %d"
+  " average_tasklist_mail_time = %lld"
   " mainMem_alloc_time = %lld\n"
     ,cpu, global_busy_time,
     global_wait_time, d, global_mail_time, m, 
     task_list_mail_time, t, r,
-    task_array_load_time,
+    task_list_read_count,
+    task_list_mail_time / task_list_read_count,	    
     mainMemalloc_time);
 
     global_busy_time = 0;
     global_mail_time = 0;
     global_wait_time = 0;
-    task_array_load_time = 0;
     task_list_mail_time = 0;
     mainMemalloc_time = 0;
     alloc_flag = 0;
--- a/TaskManager/Cell/spe/CellDmaManager.h	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.h	Fri Feb 11 06:09:32 2011 +0900
@@ -28,8 +28,8 @@
     /* variables */
     unsigned int wait_time, busy_time, alloc_busy_time;
     unsigned long long global_busy_time, global_wait_time, global_mail_time, mainMemalloc_time;
-    unsigned long long task_array_load_time;
     unsigned long long task_list_mail_time;
+    int task_list_read_count;
 
     /* functions */
     void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask);
--- a/TaskManager/ChangeLog	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/ChangeLog	Fri Feb 11 06:09:32 2011 +0900
@@ -1,3 +1,20 @@
+2011-2-12 Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
+
+        MemHash の hash() の返り値の受け取りが int でした。そのせいで、配列のindexがマイナスを示し、値が毎回変わる結果に。
+	キャッシュに失敗しているので、毎回テクスチャのロードが入っていた見たいです。
+	そのロード時間が busy_ratio の値に含まれていた。なぜ? unsinged intになおし
+	その結果なんと!
+
+	Cell
+	
+	  ball_bound 40 〜 50 FPS
+	  universe 約 20 FPS
+	  gaplant 40 FPS
+	  panel 3 FPS
+	  ieshoot 30 FPS
+
+	です。タスクリストのメール時間も全体の速度が速くなったので、7,8%から30%になり改善の余地あり。面白くなってきました。
+
 2010-12-10 Shinji KONO <kono@ie.u-ryukyu.ac.jp>
 
 	task_list を PPE の main memory において、それを get_segment で取って来る。
--- a/TaskManager/kernel/main.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/kernel/main.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -35,6 +35,7 @@
 {
     int machineNum = 1;
     int speIdle = 0;
+    int poll_pattern = 0;
 
     for (int i = 1; argv[i]; ++i) {
         if (strcmp(argv[i], "-cpu") == 0) {
@@ -43,6 +44,8 @@
 	    profile = 1;
         } else if (strcmp(argv[i], "-speidle") == 0) {
 	    speIdle = atoi(argv[++i]);
+        } else if (strcmp(argv[i], "-poll") == 0) {
+	    poll_pattern = 1;
 	}
 
     }
--- a/TaskManager/kernel/memory/MemHash.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/kernel/memory/MemHash.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -8,11 +8,11 @@
 {
     unsigned long data = (unsigned long)data0;
 #if ABIBIT>32
-        register int i_PeRlHaSh = 8; 
+        int i_PeRlHaSh = 8; 
 #else
-        register int i_PeRlHaSh = 4; 
+        int i_PeRlHaSh = 4; 
 #endif
-        register uint32 hash_PeRlHaSh = 0; 
+        uint32 hash_PeRlHaSh = 0; 
         while (i_PeRlHaSh--) { 
             hash_PeRlHaSh += data & 0xff; 
             hash_PeRlHaSh += (hash_PeRlHaSh << 10); 
@@ -57,10 +57,10 @@
 int
 MemHash::put(memaddr key, MemorySegmentPtr data)
 {
-    int hashval = hash(key);
+    unsigned int hashval = hash(key);
 
     for (int i = 0; i < hashSize/2; i++) {
-        int index = (hashval + i*i)%hashSize;
+        unsigned int index = (hashval + i*i)%hashSize;
 
         if (table[index] == 0) { // 空の table に入れる
             table[index] = data;
@@ -71,21 +71,26 @@
     return -1;
 }
 
+
 MemorySegmentPtr
 MemHash::get(memaddr key)
 {
     unsigned int hashval = hash(key);
+    //printf("get hash value %d\n",hashval);
 
     for (int i = 0; i < hashSize/2; i++) {
-        int index = (hashval + i*i)%hashSize;
+        unsigned int index = (hashval + i*i)%hashSize;
 
         if (table[index] != NULL &&
             table[index]->address == key) {
-//printf("get hash value %0x\n",index);
+	  //printf("get hash value %0x\n",index);
+	  //printf("get hash value %d\n",index);
             return table[index];
         }
     }
 
+    //printf("hoge\n");
+
     return NULL;
 }
 
--- a/TaskManager/kernel/memory/MemHash.h	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/kernel/memory/MemHash.h	Fri Feb 11 06:09:32 2011 +0900
@@ -13,14 +13,18 @@
 public:
     void clear(void);
     unsigned int hash(memaddr data);
+    unsigned int hash2(memaddr data);
     int put(memaddr addr, MemorySegmentPtr ms);
+    int put2(memaddr addr, MemorySegmentPtr ms);
     MemorySegmentPtr get(memaddr addr);
+    MemorySegmentPtr get2(memaddr addr);
     void remove(memaddr addr);
 };
 
 typedef MemHash* MemHashPtr;
 
 const int hashSize = 263;
+
 const int tableSize = sizeof(MemorySegmentPtr)*hashSize;
 
 #endif
--- a/TaskManager/kernel/schedule/Scheduler.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -384,6 +384,7 @@
 {
     // memory segment のsizeをoverride する場合がある
     MemorySegment *s = hash->get(addr);
+
 #if 1
     if (s) {
 	/* 既に load されている */
--- a/example/word_count/main.cc	Tue Feb 01 15:50:10 2011 +0900
+++ b/example/word_count/main.cc	Fri Feb 11 06:09:32 2011 +0900
@@ -182,13 +182,6 @@
     array_task_num = task_count;
     if (task_count<=0) return;
   }
- 
-  //static void simple_task_creater(int in_total_size, int out_total_size, 
-  //			     int command, int in_data_size, int out_data_size, 
-  //			     void *in_data, void *out_data, TaskManager *manager,
-  //			     HTask *wait_i, HTask *wait_me)
-
-
 
   if (use_task_creater) {
     simple_task_creater(w->file_size, w->division_out_size * w->task_num, TASK_EXEC, w->division_size, w->division_out_size,
@@ -361,6 +354,7 @@
 
 
 static int blocks = 48;
+//static int blocks = 31 * 6 * 24;
 static int division = 16; // in Kbyte
 
 static void
@@ -423,7 +417,7 @@
 
     w->t_print = t_print;
 
-    for(int i = 0;i<1;i++) {
+    for(int i = 0;i<20;i++) {
 	/* Task を task_blocks ずつ起動する Task */
         /* serialize されていると仮定する... */
 	HTaskPtr t_exec = manager->create_task(RUN_TASK_BLOCKS,