changeset 876:00c84b5856c4

merged
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 06 Jul 2010 09:52:20 +0900
parents 157f2ffeb526 (current diff) 8df4323f9fdb (diff)
children 65f0c4c7f381
files
diffstat 29 files changed, 111 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SceneGraph.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/Renderer/Engine/SceneGraph.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -650,6 +650,7 @@
     this->create_sg = new_create_sg;
 }
 
+
 void
 SceneGraph::add_next(SceneGraphPtr next)
 {
--- a/Renderer/Engine/SceneGraph.h	Tue Jul 06 09:51:35 2010 +0900
+++ b/Renderer/Engine/SceneGraph.h	Tue Jul 06 09:52:20 2010 +0900
@@ -93,6 +93,7 @@
     void set_move_collision(move_func new_move, collision_func new_collision);
     void set_move_collision(move_func new_move, collision_func new_collision, void *sgroot);
     void set_move_collision(move_func new_move, collision_func new_collision, create_sg_func new_create_sg);
+    void set_game_task(void *sgroot_, int id, void *property, int size, PostFunction post_func);
     void remove(void);
     SceneGraphPtr realRemoveFromTree(SceneGraphPtr tree);
     SceneGraphPtr realRemoveFromList(SceneGraphPtr list);
--- a/Renderer/Engine/SceneGraphRoot.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -697,4 +697,18 @@
 
 }
 
+
+void
+SceneGraphRoot::set_game_task(int id, void *property, int size, PostFunction post_func)
+{ 
+  HTask *task = sgroot->tmanager->create_task(id);
+  task->set_cpu(SPE_ANY);
+  task->add_inData(property, size);
+  task->add_outData(property, size);
+  task->add_param((memaddr)1);
+  task->set_post(post_func, (void*)property, 0);
+  task->spawn();
+}
+
+
 /* end */
--- a/Renderer/Engine/SceneGraphRoot.h	Tue Jul 06 09:51:35 2010 +0900
+++ b/Renderer/Engine/SceneGraphRoot.h	Tue Jul 06 09:52:20 2010 +0900
@@ -105,6 +105,7 @@
     void OffLightSwitch(int id);
     void OnLightSysSwitch();
     void OffLightSysSwitch();
+    void set_game_task(int id, void *property, int size, PostFunction post_func);
 
     /* Other System API */
     void allExecute(int screen_w, int screen_h);
--- a/Renderer/Engine/viewer.h	Tue Jul 06 09:51:35 2010 +0900
+++ b/Renderer/Engine/viewer.h	Tue Jul 06 09:52:20 2010 +0900
@@ -60,7 +60,7 @@
     HTaskPtr initLoop();
 
     void clean_pixels() {}
-      
+
     void run_init(TaskManager *manager, Application *app);
     void run_loop(HTaskPtr task_next);
     void run_draw(HTaskPtr task_next);
@@ -89,6 +89,11 @@
     // void setSceneData(SceneGraph *g);
     void mainLoop();
 
+    void set_game_task(int id, void *property, int size, PostFunction post_func)
+    {
+      sgroot->set_game_task(id, property, size, post_func);
+    }
+
     void createFromXMLmemory(SceneGraph * node, char *data, int len)
     {
 	sgroot->createFromXMLmemory(manager, node, data, len);
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -46,6 +46,7 @@
     ppeManager = new FifoTaskManagerImpl(machineNum);
     // 大半のTaskQueueInfoは、共有される
     MainScheduler *mscheduler = new MainScheduler;
+    set_scheduler(mscheduler);
     ppeManager->init(mscheduler, this); // ここで HTaskInfo が共有される。
     
     ppeManager->get_scheduler()->set_manager(this);
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -38,6 +38,7 @@
     mfc_write_tag_mask(1 << mask);
     mfc_write_tag_update_all();
     mfc_read_tag_status();
+    __asm__ __volatile__("   sync");
     (this->*end_dmawait_profile)(&global_wait_time);
 }
 
@@ -45,10 +46,12 @@
 {
     (this->*start_dmawait_profile)();
     spu_write_out_mbox((uint32)data);
+#if 0
     if (ABIBIT>32) {
 	unsigned long data0 = (unsigned long)data;
-	spu_write_out_mbox((uint32)(data0>>4));
+	spu_write_out_mbox((uint32)(data0>>32));
     }
+#endif
     (this->*end_dmawait_profile)(&global_mail_time);
 }
 
@@ -56,9 +59,11 @@
 {
     (this->*start_dmawait_profile)();
     memaddr data = (memaddr)spu_read_in_mbox();
+#if 0 
     if (ABIBIT>32) {
-	data += (spu_read_in_mbox()<<4);
+	data += (spu_read_in_mbox()<<32);
     }
+#endif
     (this->*end_dmawait_profile)(&global_mail_time);
     return data;
 }
--- a/TaskManager/Cell/spe/CellScheduler.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/Cell/spe/CellScheduler.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -60,14 +60,14 @@
 
  */
 
-#define TEX_LOAD1      0
+// #define TEX_LOAD1      0
 // #define TEX_LOAD2      1
 
 uint32
 CellScheduler::get_tag()
 {
     static int count = 0;
-    return TEX_LOAD1+(count++ % 2);
+    return (count++ % 8)+16;
 }
 
 
--- a/TaskManager/Makefile.cell	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/Makefile.cell	Tue Jul 06 09:52:20 2010 +0900
@@ -57,7 +57,7 @@
 $(SPETARGET): $(CELL_SPE_OBJS)
 	ar crus $@ $(CELL_SPE_OBJS)
 
-$(CELL_SPE_SCHEDULE_SRC): kernel/schedule/*.cc
+$(CELL_SPE_SCHEDULE_SRC): kernel/schedule/*.cc kernel/memory/*.cc kernel/ppe/*.cc
 	cp kernel/schedule/*.cc $(CELL_SPE_DIR)/
 	cp kernel/memory/*.cc $(CELL_SPE_DIR)/
 	cp kernel/ppe/{TaskQueue.cc,Task.cc} $(CELL_SPE_DIR)/
--- a/TaskManager/kernel/memory/MemHash.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/kernel/memory/MemHash.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -3,6 +3,28 @@
 #include <stdlib.h>
 #include "MemHash.h"
 
+unsigned int
+MemHash::hash(memaddr data0)
+{
+    unsigned long data = (unsigned long)data0;
+#if ABIBIT>32
+        register int i_PeRlHaSh = 8; 
+#else
+        register int i_PeRlHaSh = 4; 
+#endif
+        register uint32 hash_PeRlHaSh = 0; 
+        while (i_PeRlHaSh--) { 
+            hash_PeRlHaSh += data & 0xff; 
+            hash_PeRlHaSh += (hash_PeRlHaSh << 10); 
+            hash_PeRlHaSh ^= (hash_PeRlHaSh >> 6); 
+	    data >>= 8;
+        } 
+        hash_PeRlHaSh += (hash_PeRlHaSh << 3); 
+        hash_PeRlHaSh ^= (hash_PeRlHaSh >> 11); 
+        return (hash_PeRlHaSh + (hash_PeRlHaSh << 15)); 
+}
+
+#if 0
 static unsigned short PRIME[8] = {
     0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd,
 };
@@ -10,7 +32,7 @@
 int
 MemHash::hash(memaddr data0)
 {
-    long data = (long)data0;
+    unsigned long data = (unsigned long)data0;
     int value = 0;
     int n = 0;
     long key;
@@ -20,9 +42,11 @@
         value += key * PRIME[n++ & 7];
         data >>= 4;
     }
+printf("hash value %0x => %0x\n",data0, value);
 
     return value % hashSize;
 }
+#endif
 
 MemHash::MemHash()
 {
@@ -57,6 +81,7 @@
 
         if (table[index] != NULL &&
             table[index]->address == key) {
+printf("get hash value %0x\n",index);
             return table[index];
         }
     }
--- a/TaskManager/kernel/memory/MemHash.h	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/kernel/memory/MemHash.h	Tue Jul 06 09:52:20 2010 +0900
@@ -12,7 +12,7 @@
 
 public:
     void clear(void);
-    int hash(memaddr data);
+    unsigned int hash(memaddr data);
     int put(memaddr addr, MemorySegmentPtr ms);
     MemorySegmentPtr get(memaddr addr);
     void remove(memaddr addr);
--- a/TaskManager/kernel/schedule/SchedTask.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -80,11 +80,11 @@
 {
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
+    task_list[task->command].wait(scheduler,task->command);
     if (task->w_size > 0) {
 	writebuf = manager->allocate(task->w_size);
     }
     scheduler->dma_wait(DMA_READ);
-    task_list[task->command].wait(scheduler,task->command);
     task_list[task->command].run(this, readbuf, writebuf);
     free(readbuf);
 
--- a/TaskManager/kernel/schedule/SchedTaskArray.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/kernel/schedule/SchedTaskArray.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -69,6 +69,7 @@
     }
 }
 
+
 /**
  * Task data / code read
  */
@@ -103,8 +104,10 @@
 void
 SchedTaskArray::exec()
 {
-
+    task_list[atask->command].wait(scheduler,atask->command);
+    TaskObjectRun run = task_list[atask->command].run;
     if (atask->outData_count > 0) {
+	// allocate write buffer
 	outListData.length = atask->outData_count;
 	outListData.size = atask->outData_total_size();
 	outListData.element = atask->outData(0);
@@ -113,10 +116,8 @@
 
 	writebuf = manager->allocate(outListData.size);
     }
-
     scheduler->dma_wait(DMA_READ);
-    task_list[atask->command].wait(scheduler,atask->command);
-    task_list[atask->command].run(this, readbuf, writebuf);
+    (*run)(this, readbuf, writebuf);
     free(readbuf);
     // 書き込む領域がなければ無視
 
--- a/TaskManager/kernel/schedule/Scheduler.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -109,7 +109,6 @@
     return buff_taskList[buffFlag_taskList];
 }
 
-
 void
 Scheduler::dma_load(void *buf, memaddr addr, uint32 size, uint32 mask)
 {
@@ -154,6 +153,7 @@
 }
 
 
+
 /*
     ここから下は、memory 以下にあるべき
  */
@@ -200,10 +200,18 @@
  *  Task load API
  */
 void
-Scheduler::allocate_code_segment(int size, int count)
+Scheduler::allocate_code_segment(int size, int count, struct tbl *table)
 {
     // 既に overlay 領域があるので、それを追加する必要がある...
     code_segment_pool = createMemList(size, count);
+    if (table) {
+        MemorySegment* here = (MemorySegment*)(
+	     manager->allocate(sizeof(MemorySegment)));
+        here->data = (void*)(table->vma);
+        here->size = size;
+	here->address = (memaddr)here;
+	code_segment_pool->addLast(here);
+    }
 }
 
 static void
@@ -214,12 +222,19 @@
 	m->code_segment_pool, 
 	task_list[task_id].end-task_list[task_id].location);
     task_list[task_id].segment = s;
+    // calcurate call address
+    TaskObjectRun run = 
+        (TaskObjectRun)(
+            (char*)task_list[task_id].segment->data +
+            task_list[task_id].entry_offset);
+    task_list[task_id].run = run;
 #if 0
-    m->printf("loadng task id %d at 0x%x entry 0x%x\n",task_id,
+    m->printf("loadng task id %d at 0x%x entry 0x%x location 0x%x\n",task_id,
 	    (unsigned int)(task_list[task_id].segment->data ),
 	    (unsigned int)(
             (char*)task_list[task_id].segment->data +
-            task_list[task_id].entry_offset));
+            task_list[task_id].entry_offset),
+            task_list[task_id].location);
 #endif
 }
 
@@ -240,15 +255,9 @@
 #endif
     // wait for code segment load
     m->wait_segment(task_list[task_id].segment);
-    // calcurate call address
-    TaskObjectRun run = 
-        (TaskObjectRun)(
-            (char*)task_list[task_id].segment->data +
-            task_list[task_id].entry_offset);
-    task_list[task_id].run = run;
 #if 0
     m->printf("wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id,
-	(unsigned int)run,
+	(unsigned int)(task_list[task_id].run),
             task_list[task_id].entry_offset);
 #endif
 }
--- a/TaskManager/kernel/schedule/Scheduler.h	Tue Jul 06 09:51:35 2010 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.h	Tue Jul 06 09:52:20 2010 +0900
@@ -108,7 +108,7 @@
 
     MemorySegment * get_segment(memaddr addr, MemList *m);
     MemorySegment * get_segment(memaddr addr, MemList *m, int size);
-    void allocate_code_segment(int size, int count);
+    void allocate_code_segment(int size, int count,struct tbl *table);
 
     virtual uint32 get_tag();
     void put_segment(MemorySegment *s);
--- a/example/Bulk/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/Bulk/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"
--- a/example/Bulk/Makefile.def	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/Bulk/Makefile.def	Tue Jul 06 09:52:20 2010 +0900
@@ -13,5 +13,9 @@
 
 ABIBIT = 32
 
-INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
-LIBS = -L${CERIUM}/TaskManager
+#INCLUDE = -I${CERIUM}/include/TaskManager -I. -I..
+#LIBS = -L${CERIUM}/TaskManager
+
+INCLUDE = -I. -I.. -I${CERIUM}/include/TaskManager -I$(CERIUM)/Renderer/Engine -I$(CERIUM)/include/Cerium
+LIBS = -L${CERIUM}/TaskManager -L$(CERIUM)/Renderer/Engine
+TOOL = $(CERIUM)/bin
--- a/example/Bulk/Makefile.macosx	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/Bulk/Makefile.macosx	Tue Jul 06 09:52:20 2010 +0900
@@ -11,7 +11,11 @@
 TASK_SRCS = $(filter-out $(TASK_DIR)/$(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
 TASK_OBJS = $(TASK_SRCS:.cc=.o)
 
-LIBS += -lFifoManager `sdl-config --libs`
+#LIBS += -lFifoManager `sdl-config --libs`
+CFLAGS += `sdl-config --cflags` `xml2-config --cflags`
+LIBS += -lCerium -lFifoManager
+LIBS += `sdl-config --libs` `xml2-config --libs` -lSDL_image -Wl,-framework,OpenGL 
+
 CC += -m$(ABIBIT)
 
 .SUFFIXES: .cc .o
--- a/example/Bulk/ppe/Twice.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/Bulk/ppe/Twice.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -14,7 +14,7 @@
     int *i_data;
     int *o_data;
     long length;
-    int count = (int)s->get_param(0);
+    long count = (long)s->get_param(0);
 
     for(int j = 0; j<count; j++) {
 	i_data = (int*)s->get_input(rbuf, j);
--- a/example/HelloWorld/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/HelloWorld/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"
--- a/example/Simple/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/Simple/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"
--- a/example/basic/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/basic/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"
--- a/example/get_segment/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/get_segment/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"
--- a/example/get_segment/spe/Hello.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/get_segment/spe/Hello.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -40,8 +40,9 @@
 
     smanager->printf(fmt+offset, fmt, offset);
 
-    smanager->printf("[%d] Hello, World!! Seg1 \n"+offset, task_id);
+    smanager->printf("[%d] Hello, World!! Seg1\n"+offset, task_id);
     smanager->printf("pc=0x%0x 0x%0lx\n"+offset,pc, (unsigned long)&runTask_Hello);
 
     return 0;
 }
+
--- a/example/get_segment/spe/Hello1.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/get_segment/spe/Hello1.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -29,7 +29,7 @@
 "1:"
         : "=r" (pc));
 
-    char *fmt = "char [%0x] offset [%0x]\n";
+    char *fmt = "char [%0x] offset [%0x] 2\n";
     int offset = rel_offset();
 
     //smanager->fprintf(smanager->stderr_,fmt+offset, fmt, offset);
--- a/example/get_segment/spe/spe-main.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/get_segment/spe/spe-main.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -18,7 +18,7 @@
     SchedRegisterDynamicTask(HELLO_TASK, Hello, 0);
     SchedRegisterDynamicTask(HELLO_TASK1, Hello1, 1);
     // createTask_Hello(scheduler);
-    scheduler->allocate_code_segment(1024,4);
+    scheduler->allocate_code_segment(1024,4, _ovly_table);
     print_ovly_table();
 }
 
--- a/example/task_queue/testQueueInfo.cc	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/task_queue/testQueueInfo.cc	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,6 @@
 #include "Func.h"
 
 
-// static QueueInfo<TaskList, TaskList>::queuePool;   
 static QueueInfo<TaskList> *queuePool = new QueueInfo<TaskList>() ;
 
 void
--- a/example/word_count/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/word_count/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"
--- a/example/word_count3/Makefile	Tue Jul 06 09:51:35 2010 +0900
+++ b/example/word_count3/Makefile	Tue Jul 06 09:52:20 2010 +0900
@@ -6,7 +6,7 @@
 
 fifo64: FORCE
 	@echo "Make for Mac OS X 64bit mode"
-	@$(MAKE) -f Makefile.fifo ABIBIT=64
+	@$(MAKE) -f Makefile.macosx ABIBIT=64
 
 linux: FORCE
 	@echo "Make for Linux"