Mercurial > hg > Game > Cerium
changeset 302:40db021f6272 draft
working on macosx
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Jun 2009 18:07:26 +0900 |
parents | 7f991471d43f |
children | ad413540eeec |
files | TaskManager/Makefile.cell TaskManager/Test/Sum/Makefile TaskManager/Test/Sum/main.cpp TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTaskImpl.cc example/many_task/Makefile.def example/many_task/Makefile.macosx include/TaskManager/SchedTask.h include/TaskManager/SchedTaskImpl.h include/TaskManager/SchedTaskList.h include/TaskManager/Scheduler.h |
diffstat | 11 files changed, 115 insertions(+), 291 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Makefile.cell Sun Jun 07 19:45:41 2009 +0900 +++ b/TaskManager/Makefile.cell Mon Jun 08 18:07:26 2009 +0900 @@ -3,15 +3,20 @@ TARGET = libCellManager.a SPETARGET = libspemanager.a +CELL_SPE_SCHEDULE_SRC = $(CELL_SPE_DIR)/SchedExit.cc \ + $(CELL_SPE_DIR)/SchedNop2Ready.cc \ + $(CELL_SPE_DIR)/SchedTaskList.cc \ + $(CELL_SPE_DIR)/SchedMail.cc \ + $(CELL_SPE_DIR)/SchedTask.cc \ + $(CELL_SPE_DIR)/Scheduler.cc\ + $(CELL_SPE_DIR)/SchedNop.cc \ + $(CELL_SPE_DIR)/SchedTaskImpl.cc \ + $(CELL_SPE_DIR)/TaskGroup.cc +CELL_SPE_SCHEDULE_OBJ = $(CELL_SPE_SCHEDULE_SRC: .cc=.o) + CELL_SPE_DIR = $(IMPL_CELL_DIR)/spe CELL_SPE_SRCS = $(wildcard $(CELL_SPE_DIR)/*.cc) -CELL_SPE_OBJS = $(CELL_SPE_SRCS:.cc=.o) - -CELL_SPE_KERNEL = kernel/schedule -CELL_SPE_KERNEL_OBJS = $(CELL_SPE_DIR)/SchedExit.o $(CELL_SPE_DIR)/SchedNop2Ready.o \ - $(CELL_SPE_DIR)/Scheduler.o $(CELL_SPE_DIR)/SchedMail.o $(CELL_SPE_DIR)/SchedTask.o \ - $(CELL_SPE_DIR)/TaskGroup.o $(CELL_SPE_DIR)/SchedNop.o $(CELL_SPE_DIR)/SchedTaskList.o - +CELL_SPE_OBJS = $(CELL_SPE_SRCS:.cc=.o) $(CELL_SPE_SCHEDULE_OBJ) SPUCC = spu-g++ @@ -20,6 +25,7 @@ SPE_CFLAGS = -fno-exceptions -fno-rtti all: default + default: $(TARGET) $(SPETARGET) PPE_ALL_OBJS = $(KERN_MAIN_OBJS) $(KERN_PPE_OBJS) $(KERN_SCHED_OBJS) $(KERN_SYSTASK_OBJS) $(IMPL_CELL_OBJS) @@ -30,36 +36,22 @@ $(PPE_ALL_OBJS): %.o : %.cc $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ -$(SPETARGET): $(CELL_SPE_OBJS) $(CELL_SPE_KERNEL_OBJS) - ar crus $@ $(CELL_SPE_OBJS) $(CELL_SPE_KERNEL_OBJS) +$(SPETARGET): $(CELL_SPE_OBJS) + ar crus $@ $(CELL_SPE_OBJS) $(CELL_SPE_OBJS): %.o : %.cc $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_KERNEL_OBJS): - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ - -$(CELL_SPE_DIR)/SchedExit.o: $(CELL_SPE_KERNEL)/SchedExit.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/SchedNop2Ready.o: $(CELL_SPE_KERNEL)/SchedNop2Ready.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/Scheduler.o: $(CELL_SPE_KERNEL)/Scheduler.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/SchedMail.o: $(CELL_SPE_KERNEL)/SchedMail.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/SchedTask.o: $(CELL_SPE_KERNEL)/SchedTask.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/TaskGroup.o: $(CELL_SPE_KERNEL)/TaskGroup.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/SchedNop.o: $(CELL_SPE_KERNEL)/SchedNop.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ -$(CELL_SPE_DIR)/SchedTaskList.o: $(CELL_SPE_KERNEL)/SchedTaskList.cc - $(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@ +$(CELL_SPE_SCHEDULE_SRC): kernel/schedule/*.cc + cp kernel/schedule/*.cc $(CELL_SPE_DIR)/ celldistclean: cellclean rm -f $(TARGET) rm -f $(SPETARGET) cellclean: - rm -f $(CELL_SPE_OBJS) - cd $(CELL_SPE_DIR); rm -f *~ \#* + rm -f $(CELL_SPE_OBJS) $(CELL_SPE_SCHEDULE_SRC) + (cd $(CELL_SPE_DIR); rm -f *~ \#*) + + +
--- a/TaskManager/Test/Sum/Makefile Sun Jun 07 19:45:41 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -TARGET = main - -CC = g++ -CFLAGS = -Wall -g -LIBS = -L../../ -lmanager -INCLUDE = -I../../../include/TaskManager - - -all: $(TARGET) - -$(TARGET): main.o - $(CC) $< -o $@ $(LIBS) - -main.o: main.cpp - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ - -clean: - rm -f main.o $(TARGET) - rm -f *~ \#* \ No newline at end of file
--- a/TaskManager/Test/Sum/main.cpp Sun Jun 07 19:45:41 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include "TaskManager.h" - -#define MAX 1024 - -TaskManager *manager; - -int sum(void*, void*); -int sum2(void*, void*); - -int data[MAX] __attribute__((aligned(16))); -int buff[MAX] __attribute__((aligned(16))); -int out[MAX] __attribute__((aligned(16))); - -int -sum(void *wbuf, void *rbuf) -{ - int *ret = (int*)wbuf; - int *data = (int*)rbuf; - int i; - - *ret = 0; - - for (i = 0; i < 16; i++) { - *ret += data[i]; - } - - return sizeof(int); -} - -int -sum2(void *wbuf, void *rbuf) -{ - int *ret = (int*)wbuf; - int *data = (int*)rbuf; - int i; - - *ret = 0; - - for (i = 0; i < 64; i++) { - *ret += data[i*4]; - } - - return sizeof(int); -} - -int -init2(void *w, void *r) -{ - int i, fd; - int div = MAX/16; - - HTaskPtr *task = new HTaskPtr[div]; - HTaskPtr last; - - for (i = 0; i < MAX; i++) { - data[i] = i; - } - - memset(buff, 0, sizeof(int)*1024); - memset(out, 0, sizeof(int)*1024); - - fd = manager->open("Sum"); - for (i = 0; i < div; i++) { - task[i] = manager->create_task(fd, sizeof(int)*16, - (unsigned int)&data[i*16], - (unsigned int)&buff[i*4], - NULL); - } - - fd = manager->open("Sum2"); - last = manager->create_task(fd, sizeof(int)*256, - (unsigned int)buff, - (unsigned int)&out[0], NULL); - - for (i = 0; i < div; i++) { - manager->set_task_depend(task[i], last); - } - for (i = 0; i < div; i++) { - manager->spawn_task(task[i]); - } - manager->spawn_task(last); - - return 0; -} - - -int -result(void *w, void *r) -{ - - printf("manager : %d\n", out[0]); - - out[0] = 0; - for (int i = 0; i < MAX; i++) { - out[0] += i; - } - - printf("for : %d\n", out[0]); - - return 0; -} - -int -init(void *w, void *r) -{ - HTaskPtr init_task; - HTaskPtr finish_task; - - int fd; - - fd = manager->open("Init2"); - init_task = manager->create_task(fd, 0, 0, 0, NULL); - manager->spawn_task(init_task); - - fd = manager->open("Result"); - finish_task = manager->create_task(fd, 0, 0, 0, NULL); - manager->set_task_depend(init_task, finish_task); - manager->spawn_task(finish_task); - - return 0; -} - -int -main(void) -{ - manager = new TaskManager(1); - manager->init(); - - // ここは user 側で書かない...のか? - // 設定ファイルかなにかで読むとか?違うな - // あと、void* って書くのめんどくせ - manager->set_symbol("Init", (void*)init); - manager->set_symbol("Init2", (void*)init2); - manager->set_symbol("Result", (void*)result); - manager->set_symbol("Sum", (void*)sum); - manager->set_symbol("Sum2", (void*)sum2); - - manager->set_init_task("Init"); - manager->run(); - - manager->finish(); - delete manager; - - return 0; -}
--- a/TaskManager/kernel/schedule/SchedTask.cc Sun Jun 07 19:45:41 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Mon Jun 08 18:07:26 2009 +0900 @@ -1,5 +1,8 @@ #include "SchedTask.h" - /* constructor */ - SchedTask(); - ~SchedTask(); +SchedTask* +createSchedTask(TaskPtr task) +{ + return createSchedTaskImpl(task); +} +
--- a/TaskManager/kernel/schedule/SchedTaskImpl.cc Sun Jun 07 19:45:41 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTaskImpl.cc Mon Jun 08 18:07:26 2009 +0900 @@ -1,6 +1,7 @@ #include <stdlib.h> #include <string.h> #include "SchedTaskImpl.h" +#include "SchedTask.h" #include "SchedTaskList.h" #include "SchedNop2Ready.h" #include "DmaManager.h" @@ -11,13 +12,14 @@ //#define NO_PIPELINE -SchedTask* +SchedTask * createSchedTask(TaskPtr task) { return task_list[task->command](); } -SchedTaskImpl::SchedTask(void) + +SchedTaskImpl::SchedTaskImpl() { __list = NULL; __task = NULL; @@ -553,3 +555,5 @@ SchedTaskImpl::dma_wait(uint32 mask) { __scheduler->dma_wait(mask); } + +/* end */
--- a/example/many_task/Makefile.def Sun Jun 07 19:45:41 2009 +0900 +++ b/example/many_task/Makefile.def Mon Jun 08 18:07:26 2009 +0900 @@ -4,7 +4,11 @@ # ex macosx #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium +<<<<<<< local +# ex linux/ps3 +======= # ex: linux/ps3 +>>>>>>> other CERIUM = ../../../Cerium CC = g++
--- a/example/many_task/Makefile.macosx Sun Jun 07 19:45:41 2009 +0900 +++ b/example/many_task/Makefile.macosx Mon Jun 08 18:07:26 2009 +0900 @@ -15,7 +15,7 @@ CFLAGS = -g -Wall# -O9 #-DDEBUG INCLUDE = -I${CERIUM}/include/TaskManager -I. -I.. -LIBS = -L${CERIUM}/TaskManager -lFifoManager +LIBS = -L${CERIUM}/TaskManager -lFifoManager `sdl-config --libs` .SUFFIXES: .cc .o
--- a/include/TaskManager/SchedTask.h Sun Jun 07 19:45:41 2009 +0900 +++ b/include/TaskManager/SchedTask.h Mon Jun 08 18:07:26 2009 +0900 @@ -1,53 +1,54 @@ #ifndef INCLUDED_SCHED_TASK #define INCLUDED_SCHED_TASK -#include "base.h" -#include "Scheduler.h" -#include "SchedTaskBase.h" -#include "ListData.h" -#include "TaskGroup.h" +#include "SchedTaskImpl.h" + +class SchedTask : public SchedTaskImpl { +public: -class SchedTask : public SchedTaskBase { -public: + /* variables */ + + virtual ~SchedTask() { + } + /* constructor */ - SchedTask(void); - ~SchedTask(void); BASE_NEW_DELETE(SchedTask); - /* variables */ - SchedTaskImpl* schedTaskImpl; // ここをユーザが継承して // それぞれのタスクに対応した処理を記述する - virtual int run(void* r, void *w) { return 0; } + virtual int run(void* r, void *w) { return 0;} //--- User API --- - int get_cpuid() {schedTaskImpl->get_cpuid();} + + int get_cpuid() {return SchedTaskImpl::get_cpuid();} - void* get_input(void *buff, int index); - void* get_output(void *buff, int index); - uint32 get_inputAddr(int index); - uint32 get_outputAddr(int index); - int get_inputSize(int index); - int get_outputSize(int index); - int get_param(int index); + void* get_input(void *buff, int index) {return SchedTaskImpl::get_input(buff,index);} + void* get_output(void *buff, int index) {return SchedTaskImpl::get_output(buff,index);} + uint32 get_inputAddr(int index) {return SchedTaskImpl::get_inputAddr(index);} + uint32 get_outputAddr(int index) {return SchedTaskImpl::get_outputAddr(index);} + int get_inputSize(int index) {return SchedTaskImpl::get_inputSize(index);} + int get_outputSize(int index) {return SchedTaskImpl::get_outputSize(index);} + int get_param(int index) {return SchedTaskImpl::get_param(index);} - TaskPtr create_task(int cmd); - void wait_task(TaskPtr waitTask); + TaskPtr create_task(int cmd) {return SchedTaskImpl::create_task(cmd);} + void wait_task(TaskPtr waitTask) {SchedTaskImpl::wait_task(waitTask);} - void* global_alloc(int id, int size); - void* global_get(int id); - void global_free(int id); + void* global_alloc(int id, int size) {return SchedTaskImpl::global_alloc(id,size);} + void* global_get(int id) {return SchedTaskImpl::global_get(id);} + void global_free(int id) {SchedTaskImpl::global_free(id);} - void mainMem_alloc(int id, int size); - void mainMem_wait(void); - void* mainMem_get(int id); + void mainMem_alloc(int id, int size) {SchedTaskImpl::mainMem_alloc(id,size);} + void mainMem_wait() { SchedTaskImpl::mainMem_wait();} + void* mainMem_get(int id) {return SchedTaskImpl::mainMem_get(id);} - void *allocate(int size); + void *allocate(int size) {return SchedTaskImpl::allocate(size);} - void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask); - void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask); - void dma_wait(uint32 mask); -#endif + void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask) {SchedTaskImpl::dma_load(buf,addr,size,mask);} + void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask) {SchedTaskImpl::dma_load(buf,addr,size,mask);} + void dma_wait(uint32 mask) {SchedTaskImpl::dma_wait(mask);} +}; extern SchedTask* createSchedTask(TaskPtr); + +#endif
--- a/include/TaskManager/SchedTaskImpl.h Sun Jun 07 19:45:41 2009 +0900 +++ b/include/TaskManager/SchedTaskImpl.h Mon Jun 08 18:07:26 2009 +0900 @@ -1,32 +1,17 @@ -#ifndef INCLUDED_SCHED_TASK -#define INCLUDED_SCHED_TASK - -#ifndef INCLUDED_BASE_H_ -# include "base.h" -#endif - -#ifndef INCLUDED_SCHEDULER -# include "Scheduler.h" -#endif +#ifndef INCLUDED_SCHED_TASK_IMPL +#define INCLUDED_SCHED_TASK_IMPL -#ifndef INCLUDED_SCHED_TASK_BASE -# include "SchedTaskBase.h" -#endif +#include "base.h" +#include "Scheduler.h" +#include "SchedTaskBase.h" +#include "ListData.h" +#include "TaskGroup.h" -#ifndef INCLUDED_LIST_DATA -# include "ListData.h" -#endif - -#ifndef INCLUDED_TASK_GROUP -# include "TaskGroup.h" -#endif - - -class SchedTask : public SchedTaskBase { +class SchedTaskImpl : public SchedTaskBase { public: /* constructor */ - SchedTask(void); - ~SchedTask(void); + SchedTaskImpl(); + ~SchedTaskImpl(); BASE_NEW_DELETE(SchedTask); @@ -68,55 +53,55 @@ // SPE で生成されたものかによって、データの扱いが変わってくる。 // そのために if (__flag_renewTask) を連発するのはよくないので // 関数ポインタで持っておく - void (SchedTask::*ex_init)(void); - void (SchedTask::*ex_read)(void); - void (SchedTask::*ex_exec)(void); - void (SchedTask::*ex_write)(void); - SchedTaskBase* (SchedTask::*ex_next)(void); + void (SchedTaskImpl::*ex_init)(); + void (SchedTaskImpl::*ex_read)(); + void (SchedTaskImpl::*ex_exec)(); + void (SchedTaskImpl::*ex_write)(); + SchedTaskBase* (SchedTaskImpl::*ex_next)(); /* functions */ - void __setRenew(void); + void __setRenew(); void __init__(TaskListPtr _list, TaskPtr _task, int index, ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc); // override - void read(void); - void exec(void); - void write(void); + void read(); + void exec(); + void write(); SchedTaskBase* next(Scheduler *, SchedTaskBase *); // ここをユーザが継承して // それぞれのタスクに対応した処理を記述する virtual int run(void* r, void *w) { return 0; } - int (SchedTask::*run_func)(void* r, void *w); + int (SchedTaskImpl::*run_func)(void* r, void *w); //--- System API --- - SchedTask* get_nextTask(TaskListPtr list); + SchedTaskImpl* get_nextTask(TaskListPtr list); /** * PPE で生成されたタスクに対する * __init__, read,exec,write,next の付属(?)処理 */ - void ex_init_normal(void); - void ex_read_normal(void); - void ex_exec_normal(void); - void ex_write_normal(void); - SchedTaskBase* ex_next_normal(void); + void ex_init_normal(); + void ex_read_normal(); + void ex_exec_normal(); + void ex_write_normal(); + SchedTaskBase* ex_next_normal(); /** * SPE で生成されたタスクに対する * __inti__, ead,exec,write,next の付属(?)処理 */ - void ex_init_renew(void); - void ex_read_renew(void); - void ex_exec_renew(void); - void ex_write_renew(void); - SchedTaskBase* ex_next_renew(void); + void ex_init_renew(); + void ex_read_renew(); + void ex_exec_renew(); + void ex_write_renew(); + SchedTaskBase* ex_next_renew(); //--- User API --- - int get_cpuid(void); + int get_cpuid(); void* get_input(void *buff, int index); void* get_output(void *buff, int index); @@ -134,7 +119,7 @@ void global_free(int id); void mainMem_alloc(int id, int size); - void mainMem_wait(void); + void mainMem_wait(); void* mainMem_get(int id); void *allocate(int size); @@ -145,15 +130,15 @@ class STaskManager { public: - STaskManager(SchedTask *_t) { + STaskManager(SchedTaskImpl *_t) { outer = _t; } BASE_NEW_DELETE(STaskManager); - SchedTask *outer; + SchedTaskImpl *outer; - int get_cpuid(void) { + int get_cpuid() { return outer->get_cpuid(); } @@ -209,7 +194,7 @@ outer->mainMem_alloc(id, size); } - void mainMem_wait(void) { + void mainMem_wait() { outer->mainMem_wait(); } @@ -240,6 +225,7 @@ const int SCHED_TASK_NORMAL = 0; const int SCHED_TASK_RENEW = 1; +extern SchedTask* createSchedTaskImpl(TaskPtr); + #endif -extern SchedTask* createSchedTask(TaskPtr);
--- a/include/TaskManager/SchedTaskList.h Sun Jun 07 19:45:41 2009 +0900 +++ b/include/TaskManager/SchedTaskList.h Mon Jun 08 18:07:26 2009 +0900 @@ -45,6 +45,7 @@ const int SCHED_TASKLIST_NORMAL = 0; const int SCHED_TASKLIST_RENEW = 1; +extern SchedTaskList* createSchedTaskList(uint32, Scheduler*, int); + #endif -extern SchedTaskList* createSchedTaskList(uint32, Scheduler*, int);
--- a/include/TaskManager/Scheduler.h Sun Jun 07 19:45:41 2009 +0900 +++ b/include/TaskManager/Scheduler.h Mon Jun 08 18:07:26 2009 +0900 @@ -6,7 +6,6 @@ #include "ListData.h" #include "DmaManager.h" #include "SchedTaskBase.h" -#include "SchedTask.h" #include "SchedTaskList.h" #include "TaskGroup.h" @@ -146,9 +145,9 @@ void dma_storeList(ListDataPtr list, void *, uint32 mask); }; +extern void register_task(int cmd, Scheduler::TaskObject task); #endif -extern void register_task(int cmd, Scheduler::TaskObject task); #define SchedConstructor(str) \ str(void) {} \