changeset 1413:5b024efa2429 draft

fix free on non copy DMA
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 19 Feb 2012 10:07:27 +0900
parents f40558ec00a8
children 94ac6d8e73aa
files Renderer/Engine/TODO TaskManager/Fifo/FifoTaskManagerImpl.cc TaskManager/Fifo/MainScheduler.cc TaskManager/Fifo/PreRefDmaManager.cc TaskManager/Fifo/PreRefDmaManager.h TaskManager/Fifo/ReferencedDmaManager.cc TaskManager/Fifo/ReferencedDmaManager.h TaskManager/Makefile.cell TaskManager/kernel/main.cc TaskManager/kernel/schedule/DmaManager.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTaskArray.cc TaskManager/kernel/schedule/SchedTaskArrayNop.cc example/Bulk/Makefile.def example/many_task/Makefile.def
diffstat 15 files changed, 51 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/TODO	Sat Feb 18 17:26:32 2012 +0900
+++ b/Renderer/Engine/TODO	Sun Feb 19 10:07:27 2012 +0900
@@ -1,3 +1,7 @@
+Sat Feb 18 17:31:10 JST 2012
+
+Texture でenbugしたらしい。こういうのどうやってdebugするんだろう?
+
 Sat Jul 30 15:57:25 JST 2011
 
 SceneGraph
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -339,7 +339,7 @@
 #endif
 
 	if (num == 0) {
-    return new FifoTaskManagerImpl(num);
+                return new FifoTaskManagerImpl(num);
 	} else {
 		Threads *cpus = new CpuThreads(num,useRefDma);
 		return new CellTaskManagerImpl(num,cpus);
--- a/TaskManager/Fifo/MainScheduler.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Fifo/MainScheduler.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -10,13 +10,13 @@
 void
 MainScheduler::init_impl(int useRefDma)
 {
-	if (useRefDma & 0x10) {
-		fifoDmaManager = new PreRefDmaManager();
-	} else if (useRefDma & 0x01) {
-		fifoDmaManager = new ReferencedDmaManager();
-	} else {
-		fifoDmaManager = new FifoDmaManager();
-	}
+    if (useRefDma & 0x10) {
+        fifoDmaManager = new PreRefDmaManager();
+    } else if (useRefDma & 0x01) {
+        fifoDmaManager = new FifoDmaManager();
+    } else {
+        fifoDmaManager = new ReferencedDmaManager();
+    }
     connector = fifoDmaManager;
 }
 
--- a/TaskManager/Fifo/PreRefDmaManager.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Fifo/PreRefDmaManager.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -19,3 +19,6 @@
 	return (void*)addr;
 }
 
+void
+PreRefDmaManager::free(void *buf) {
+}
--- a/TaskManager/Fifo/PreRefDmaManager.h	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Fifo/PreRefDmaManager.h	Sun Feb 19 10:07:27 2012 +0900
@@ -8,6 +8,7 @@
 public:
 	/* functions */
     virtual void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask);
+    virtual void free(void *buf);
 } ;
 
 #endif/* PRE_REFERENCED_DMA_MANAGER */
--- a/TaskManager/Fifo/ReferencedDmaManager.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Fifo/ReferencedDmaManager.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -29,3 +29,9 @@
 
     return (void*)elm->addr; 
 }
+
+void
+ReferencedDmaManager::free(void *buf) {
+}
+
+
--- a/TaskManager/Fifo/ReferencedDmaManager.h	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Fifo/ReferencedDmaManager.h	Sun Feb 19 10:07:27 2012 +0900
@@ -8,7 +8,8 @@
 public:
 	/* functions */
     virtual void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask);
-	virtual void *dma_loadList(Scheduler *s, ListDataPtr list, void *buff, uint32 mask);
+    virtual void *dma_loadList(Scheduler *s, ListDataPtr list, void *buff, uint32 mask);
+    virtual void free(void *buff);
 } ;
 
 #endif/* REFERENCED_DMA_MANAGER */
--- a/TaskManager/Makefile.cell	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/Makefile.cell	Sun Feb 19 10:07:27 2012 +0900
@@ -39,7 +39,7 @@
 
 # $(wildcard $(CELL_SPE_DIR)/*.cc)
 
-CELL_SPE_OBJS = $(CELL_SPE_SRCS:.cc=.o) $(CELL_SPE_SCHEDULE_OBJ) $(CELL_SPE_TASK_SRCS:.cc=.o) $(CELL_SPE_PROFILE:.cc=.o)
+CELL_SPE_OBJS = $(CELL_SPE_SRCS:.cc=.o) $(CELL_SPE_SCHEDULE_OBJ) $(CELL_SPE_TASK_SRCS:.cc=.o) # $(CELL_SPE_PROFILE:.cc=.o)
 
 SPUCC = spu-g++ -DABIBIT=$(ABIBIT)
 
--- a/TaskManager/kernel/main.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/kernel/main.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -35,24 +35,21 @@
 {
     int machineNum = 0;
     int speIdle = 0;
-    int poll_pattern = 0;
-	int useRefDma = 0;
+    int useRefDma = 0;
 
     for (int i = 1; argv[i]; ++i) {
         if (strcmp(argv[i], "-cpu") == 0) {
-			machineNum = atoi(argv[++i]);
+            machineNum = atoi(argv[++i]);
         } else if (strcmp(argv[i], "-p") == 0) {
-			profile = 1;
-        } else if (strcmp(argv[i], "-speidle") == 0) {
-			speIdle = atoi(argv[++i]);
-        } else if (strcmp(argv[i], "-poll") == 0) {
-			poll_pattern = 1;
-		} else if (strcmp(argv[i], "-ref") == 0) {
-			useRefDma |= 0x01;
-		} else if (strcmp(argv[i], "-pre") == 0) {
-			useRefDma |= 0x10;
-		}
-	}
+            profile = 1;
+        } else if (strcmp(argv[i], "-speidle") == 0) { // これなんだよ?
+            speIdle = atoi(argv[++i]);
+        } else if (strcmp(argv[i], "-copy") == 0) { // force copy DMA in FifoManager
+            useRefDma |= 0x01;
+        } else if (strcmp(argv[i], "-pre") == 0) {  // deplicated 
+            useRefDma |= 0x10;
+        }
+    }
 
     TaskManager *manager = new TaskManager(machineNum);
     manager->init(speIdle,useRefDma);
--- a/TaskManager/kernel/schedule/DmaManager.h	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/kernel/schedule/DmaManager.h	Sun Feb 19 10:07:27 2012 +0900
@@ -23,9 +23,10 @@
     BASE_NEW_DELETE(DmaManager);
 
     // API for DMA transfer
-    virtual void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask) { return 0;}
-    virtual void *dma_store(void *buf,memaddr addr, uint32 size, uint32 mask) { return 0;}
-    virtual void *get_writebuf(Scheduler *s, memaddr addr, uint32 size) { return 0;}
+    virtual void *dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask) { return 0; }
+    virtual void *dma_store(void *buf,memaddr addr, uint32 size, uint32 mask) { return 0; }
+    virtual void free(void *buf) { free(buf); }
+    virtual void *get_writebuf(Scheduler *s, memaddr addr, uint32 size) { return 0; }
     virtual void dma_wait(uint32 mask) {}
     virtual void dma_wait(uint32 mask, int cmd) {}
     virtual void show_dma_wait(Scheduler *s, int cpu) {}
@@ -38,9 +39,9 @@
     virtual memaddr task_list_mail_read() { return 0; }
     
     // API for MFC list DMA transfer
-    virtual void *dma_loadList(Scheduler *s, ListDataPtr list, void *,uint32 mask) { return 0;}
+    virtual void *dma_loadList(Scheduler *s, ListDataPtr list, void *,uint32 mask) { return 0; }
     virtual void dma_storeList(ListDataPtr, void *buff, uint32 mask) {}
-    virtual void *get_writebuf(Scheduler *s, ListDataPtr, uint32 size) { return 0;}
+    virtual void *get_writebuf(Scheduler *s, ListDataPtr, uint32 size) { return 0; }
     virtual uint32 get_tag() { return 0;}
     virtual void bound(ListData *) {}
 };
--- a/TaskManager/kernel/schedule/SchedTask.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -95,11 +95,7 @@
     }
     connector->dma_wait(DMA_READ + this->tag);
     run(this, readbuf, writebuf);
-	//;TODO
-	//ReferencedDmaManagerを使う場合ここでfreeすると、wordcountが動かない
-	//wordcountのmain.ccのrun16が実行されるときに、readbufをポインタで受けてる
-    free(readbuf);
-	
+    connector->free(readbuf);
 
     // 書き込む領域がなければ無視
 
@@ -114,7 +110,7 @@
     __debug("[SchedTask:%s]\n", __FUNCTION__);
 
     connector->dma_wait(DMA_WRITE);
-    free(writebuf);
+    connector->free(writebuf);
 #ifdef TASK_LIST_MAIL
     if (!(cur_index < list->length) )
 	connector->mail_write(waiter);
--- a/TaskManager/kernel/schedule/SchedTaskArray.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTaskArray.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -105,7 +105,7 @@
     outListData.bound = (int*)manager->allocate(outListData.length*sizeof(int));
     connector->bound(&outListData);
 
-    free(writebuf);
+    // connector->free(writebuf); what?!
     writebuf = connector->get_writebuf(scheduler, &outListData, outListData.size);
     //if (outListData.element == inListData.element ) {
     //   printf("bad %x\n",outListData.element);
@@ -126,7 +126,7 @@
     }
     connector->dma_wait((DMA_READ + this->tag));
     run(this, get_input(readbuf, 0), get_output(writebuf, 0));
-    free(readbuf);
+    connector->free(readbuf);
     // 書き込む領域がなければ無視
 
     // User 側で作る方法が必要...
@@ -146,7 +146,7 @@
 {
 
     connector->dma_wait(DMA_WRITE);
-    free(writebuf);
+    connector->free(writebuf);
     free(inListData.bound);
     free(outListData.bound);
 }
--- a/TaskManager/kernel/schedule/SchedTaskArrayNop.cc	Sat Feb 18 17:26:32 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTaskArrayNop.cc	Sun Feb 19 10:07:27 2012 +0900
@@ -57,7 +57,7 @@
 {
     savedTask->write();
 
-    free(atask);
+    connector->free(atask);
     delete savedTask;
     savedTask = 0;
 }
--- a/example/Bulk/Makefile.def	Sat Feb 18 17:26:32 2012 +0900
+++ b/example/Bulk/Makefile.def	Sun Feb 19 10:07:27 2012 +0900
@@ -8,7 +8,7 @@
 CERIUM = ../../../Cerium
 
 CC      = g++
-OPT = -g -O9
+OPT = -g # -O9
 CFLAGS  =  -Wall $(OPT)  
 
 ABIBIT = 64
--- a/example/many_task/Makefile.def	Sat Feb 18 17:26:32 2012 +0900
+++ b/example/many_task/Makefile.def	Sun Feb 19 10:07:27 2012 +0900
@@ -6,9 +6,9 @@
 
 CERIUM = ../../../Cerium
 
-OPT = -O9
+# OPT = -O9
 # OPT = -g -O9
-# OPT = -g
+OPT = -g
 CC      = g++
 CFLAGS  =  -DUSE_SIMPLE_TASK -Wall  $(OPT)
 # CFLAGS  =   -Wall  $(OPT)