changeset 364:87462f8d3761

uint32 to memaddr(uint64)
author tkaito@localhost.localdomain
date Fri, 24 Jul 2009 17:40:53 +0900
parents a8fcb4431c76
children f8769040a5df
files TaskManager/Cell/spe/CellDmaManager.cc example/MemList/Func.h example/MemList/Makefile example/MemList/Makefile.cell example/MemList/Makefile.def example/MemList/Makefile.linux example/MemList/Makefile.macosx example/MemList/README example/MemList/main.cc include/TaskManager/CellDmaManager.h include/TaskManager/types.h
diffstat 11 files changed, 247 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Fri Jul 24 17:08:08 2009 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Fri Jul 24 17:40:53 2009 +0900
@@ -11,7 +11,7 @@
  * @param[in] mask DMA tag
 */
 void
-CellDmaManager::dma_load(void *buf, uint32 addr, uint32 size, uint32 mask)
+CellDmaManager::dma_load(void *buf, memaddr addr, uint32 size, uint32 mask)
 {
     if (size == 0) return ;
     mfc_get((volatile void *)buf, addr, size, mask, 0, 0);
@@ -26,7 +26,7 @@
  * @param[in] mask DMA tag
 */
 void
-CellDmaManager::dma_store(void *buf, uint32 addr, uint32 size, uint32 mask)
+CellDmaManager::dma_store(void *buf, memaddr addr, uint32 size, uint32 mask)
 {
     if (size == 0) return ;
     mfc_put((volatile void *)buf, addr, size, mask, 0, 0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MemList/Func.h	Fri Jul 24 17:40:53 2009 +0900
@@ -0,0 +1,5 @@
+enum {
+    HELLO_TASK,
+    RUN_FINISH,
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MemList/Makefile	Fri Jul 24 17:40:53 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
+
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MemList/Makefile.cell	Fri Jul 24 17:40:53 2009 +0900
@@ -0,0 +1,42 @@
+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)
+
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MemList/Makefile.def	Fri Jul 24 17:40:53 2009 +0900
@@ -0,0 +1,14 @@
+TARGET = mainMem
+
+# include/library path
+# ex: macosx
+#CERIUM = /Users/gongo/Source/Cerium
+
+# ex: linux/ps3
+CERIUM = ../../../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/MemList/Makefile.linux	Fri Jul 24 17:40:53 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/MemList/Makefile.macosx	Fri Jul 24 17:40:53 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/MemList/README	Fri Jul 24 17:40:53 2009 +0900
@@ -0,0 +1,47 @@
+/*
+ * $Id: README,v 1.5 2008/11/01 02:37:12 gongo Exp $
+ */
+
+- 概要
+
+"Hello, World!!" を出力するプログラムです。
+タスク Hello が文字列を表示します。
+
+- 実行方法
+
+% ./hello [-count COUNT]
+
+  -count   表示する "Hello, World!!" の数(つまり、タスク Hello の数)です。
+
+- 実行例 (-cpu は Cerium 標準のオプションです)
+
+% ./hello
+[0] Hello, World!!
+
+% ./hello -count 10
+[0] Hello, World!!
+[1] Hello, World!!
+[2] Hello, World!!
+[3] Hello, World!!
+[4] Hello, World!!
+[5] Hello, World!!
+[6] Hello, World!!
+[7] Hello, World!!
+[8] Hello, World!!
+[9] Hello, World!!
+
+% ./hello -count 10 -cpu 3
+[0] Hello, World!!
+[2] Hello, World!!
+[3] Hello, World!!
+[5] Hello, World!!
+[6] Hello, World!!
+[8] Hello, World!!
+[9] Hello, World!!
+[1] Hello, World!!
+[4] Hello, World!!
+[7] Hello, World!!
+
+上の例では、Hello タスク 10 個を、
+3 つの CPU に振り分けて実行しているので
+表示が順になっていない -> 並列に実行されていることがわかります。
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/MemList/main.cc	Fri Jul 24 17:40:53 2009 +0900
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "TaskManager.h"
+#include "Func.h"
+
+extern void task_init(void);
+
+static int count = 1;
+
+extern TaskManager *manager;
+
+const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
+  -cpu    Number of SPE (default 1) \n\
+  -count  Number of task is print \"Hello, World!!\"";
+
+// get 鴻
+
+int
+main(int argc, char *argv[])
+{
+	uint32 size = 128;
+	uint32 count = 64;
+
+	MemList* active = createMemList(size, 0);
+	MemList* freelist = createMemList(size,count);
+
+	// 鐚
+	for () {
+		MemorySegment* e = freelost.getFirst();
+	}		
+	return 0;
+}
--- a/include/TaskManager/CellDmaManager.h	Fri Jul 24 17:08:08 2009 +0900
+++ b/include/TaskManager/CellDmaManager.h	Fri Jul 24 17:40:53 2009 +0900
@@ -13,7 +13,7 @@
     BASE_NEW_DELETE(CellDmaManager);
 
     typedef struct dma_list {
-	uint32 addr;
+	memaddr addr;
 	uint32 size;
     } DmaList, *DmaListPtr;
 
@@ -22,8 +22,8 @@
     unsigned long long global_busy_time, global_wait_time;
 
     /* functions */
-    void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
-    void dma_store(void *buf, uint32 addr, uint32 size, uint32 mask);
+    void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask);
+    void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask);
     void dma_wait(uint32 mask) ;
     void start_dmawait_profile();
     void end_dmawait_profile();
--- a/include/TaskManager/types.h	Fri Jul 24 17:08:08 2009 +0900
+++ b/include/TaskManager/types.h	Fri Jul 24 17:40:53 2009 +0900
@@ -5,6 +5,15 @@
 
 typedef uint32_t uint32;
 typedef uint64_t uint64;
+#ifdef SPU
+typedef memaddr  uint64;
+#else
+#if (sizeof (void*) == 8)
+typedef memaddr  uint64;
+#else
+typedef memaddr  uint32;
+#endif
+#endif
 
 #define SPE_ALIGNMENT 16
 #define SPE_ALIGNMENT_FULL 128