Mercurial > hg > Members > kono > Cerium
changeset 737:50220f219341
merge
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 27 Dec 2009 20:49:38 +0900 |
parents | 08d201fb1d66 (current diff) 31d0a5baafdf (diff) |
children | 510424e175ae |
files | Renderer/Engine/Application.h Renderer/Engine/SgChange.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h |
diffstat | 24 files changed, 114 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def Thu Dec 24 05:04:34 2009 +0900 +++ b/Renderer/Engine/Makefile.def Sun Dec 27 20:49:38 2009 +0900 @@ -5,7 +5,7 @@ ABIBIT = 32 ABI = -m$(ABIBIT) CC = g++ -OPT = -g +OPT = -g -O2 CFLAGS = -g -Wall $(ABI) $(OPT) # -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I.
--- a/Renderer/Engine/spe/ChainInit.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/Renderer/Engine/spe/ChainInit.cc Sun Dec 27 20:49:38 2009 +0900 @@ -21,12 +21,13 @@ static int run(SchedTask *s,void *rbuf, void *wbuf) { + /* CHAIN_VARS* idata = (CHAIN_VARS*)s->get_input(rbuf, 0); uint32 chain_len = (unsigned long)s->get_param(0); // property は spe 上で allocate している(global) CHAIN_VARS *property = (CHAIN_VARS*)s->global_alloc(DATA_ID, sizeof(CHAIN_VARS)*chain_len); memcpy(property, idata, sizeof(CHAIN_VARS)*chain_len); - + */ return 0; }
--- a/Renderer/Engine/spe/Makefile Thu Dec 24 05:04:34 2009 +0900 +++ b/Renderer/Engine/spe/Makefile Sun Dec 27 20:49:38 2009 +0900 @@ -10,7 +10,7 @@ OBJS = $(SRCS:.cc=.o) CC = spu-g++ -CFLAGS = -Wall -g -fno-exceptions -fno-rtti #-DDEBUG +CFLAGS = -Wall -fno-exceptions -fno-rtti $(OPT)#-DDEBUG INCLUDE = -I$(TOP)/include/TaskManager -I. -I.. LIBS = -L$(TOP)/TaskManager -lspemanager
--- a/Renderer/Engine/viewer.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/Renderer/Engine/viewer.cc Sun Dec 27 20:49:38 2009 +0900 @@ -105,13 +105,20 @@ int size = sizeof(float)*4; + light_xyz = (float *)manager->allocate(size); light_xyz[0] = 0.0f; light_xyz[1] = 0.0f; light_xyz[2] = 0.0f; light_xyz[3] = 0.0f; HTaskPtr data_load; - for(int i = 0; i < spe_num; i++) { + data_load = manager->create_task(DataLoad); + data_load->set_param(0,(memaddr)size); + data_load->set_param(1,(memaddr)Light); + data_load->set_cpu((CPU_TYPE)((int)SPE_0)); + data_load->spawn(); + + for(int i = 1; i < spe_num; i++) { data_load = manager->create_task(DataLoad); data_load->set_param(0,(memaddr)size); data_load->set_param(1,(memaddr)Light);
--- a/Renderer/Engine/viewer.h Thu Dec 24 05:04:34 2009 +0900 +++ b/Renderer/Engine/viewer.h Sun Dec 27 20:49:38 2009 +0900 @@ -22,6 +22,7 @@ Viewer(TaskManager *manager, ViewerDevice *dev, int bpp, int width, int height, int spenum); virtual ~Viewer() {} + BASE_NEW_DELETE(Viewer); ViewerDevice *dev; Application *app; @@ -31,16 +32,18 @@ HTaskPtr draw_dummy; /* screen info */ - int width; - int height; int bpp; + int rgb_size[3]; int spe_num; + int width; + int height; - int rgb_size[3]; - float light_xyz[4]; + //float light_xyz[4] __attribute__((aligned(16))); + float *light_xyz; float *light_xyz_stock; + Uint32 video_flags; Uint32 *pixels;
--- a/Renderer/Test/viewer.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/Renderer/Test/viewer.cc Sun Dec 27 20:49:38 2009 +0900 @@ -141,12 +141,6 @@ return sgroot; } -MainLoopPtr -viewer::init_only_sg(SgChange *sgroot, int screen_w, int screen_h) -{ - return sgroot; -} - extern Application * application() { return new viewer();
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Sun Dec 27 20:49:38 2009 +0900 @@ -185,7 +185,7 @@ } while (ppeManager->activeTaskQueue->empty() && spe_running >0 ); } while (ppeTaskList || spe_running >0); if (!waitTaskQueue->empty()) { - fprintf(stderr,"Dead lock detected\n"); + get_scheduler()->printf("Dead lock detected\n"); } }
--- a/TaskManager/Cell/SpeThreads.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/Cell/SpeThreads.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,6 +1,7 @@ #include <stdlib.h> #include "types.h" #include "SpeThreads.h" +#include "Scheduler.h" SpeThreads::SpeThreads(int num) : spe_num(num) {} @@ -44,8 +45,7 @@ | (stop_info.result.spe_signal_code & 0xff); switch(stop_info.stop_reason) { - case SPE_EXIT: - //printf("SPE_EXIT stop_info.result.stop_exit_code=0x%x\n", stop_info.result.spe_exit_code); + case SPE_EXIT: break; case SPE_STOP_AND_SIGNAL: printf("[SPE %d] SPE_STOP_AND_SIGNAL stop_info.result.stop_signal_code=%d\n", arg_t->speid, stop_info.result.spe_signal_code);
--- a/TaskManager/Cell/SpeThreads.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/Cell/SpeThreads.h Sun Dec 27 20:49:38 2009 +0900 @@ -11,6 +11,7 @@ spe_context_ptr_t ctx; } thread_arg_t; + class SpeThreads { public: /* constructor */
--- a/TaskManager/Cell/spe/CellDmaManager.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include "CellDmaManager.h" - +#include "Scheduler.h" /** @@ -120,13 +120,13 @@ void CellDmaManager::null_end_dmawait_profile(unsigned long long *counter) {} void -CellDmaManager::show_dma_wait(int cpu) +CellDmaManager::show_dma_wait(Scheduler *s, int cpu) { double r = ((double)global_busy_time)/((double)( global_busy_time+global_wait_time+global_mail_time ))*100.0; - printf("spu%d: busy_time = %lld" + s->printf("spu%d: busy_time = %lld" " wait_time = %lld" " mail_time = %lld" " busy_ratio = %g%%\n", cpu, global_busy_time,
--- a/TaskManager/Cell/spe/CellDmaManager.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/Cell/spe/CellDmaManager.h Sun Dec 27 20:49:38 2009 +0900 @@ -9,6 +9,8 @@ #define SPU_PROFILE 1 +class Scheduler; + class CellDmaManager : public DmaManager { public: BASE_NEW_DELETE(CellDmaManager); @@ -35,7 +37,7 @@ void stop_profile(); - void show_dma_wait(int cpu); + void show_dma_wait(Scheduler *s, int cpu); void mail_write(memaddr data); memaddr mail_read();
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc Sun Dec 27 20:49:38 2009 +0900 @@ -151,7 +151,7 @@ mail_check(); } if (!waitTaskQueue->empty()) { - fprintf(stderr,"Dead lock detected\n"); + get_scheduler()->printf("Dead lock detected\n"); } } @@ -199,7 +199,7 @@ } else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) { // MY_SPE_COMMAND_MALLOC PPE からのmain memory request // 本来は呼ばれないはず... - fprintf(stderr, "error: MY_SPE_COMMAND_MALLOC from PPE\n"); + get_scheduler()->printf("error: MY_SPE_COMMAND_MALLOC from PPE\n"); // send_alloc_reply(this, 0, mainScheduler); } else if (data != (memaddr)MY_SPE_NOP) { __debug_ppe("mail_check(): recv from 0x%x\n", data);
--- a/TaskManager/include/error.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/include/error.h Sun Dec 27 20:49:38 2009 +0900 @@ -3,8 +3,8 @@ #ifdef DEBUG # include <stdio.h> -# define __debug(...) do { \ - fprintf(stderr, __VA_ARGS__); \ +# define __debugs(s, ...) do { \ + s->printf(__VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug(...) @@ -12,8 +12,8 @@ #ifdef DEBUG # include <stdio.h> -# define __debug_ppe(...) do { \ - printf("[PPE] "); printf(__VA_ARGS__); \ +# define __debugs_ppe(s, ...) do { \ + s->printf("[PPE] ", __VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug_ppe(...) @@ -21,8 +21,8 @@ #ifdef DEBUG # include <stdio.h> -# define __debug_spe(...) do { \ - printf("[SPE] "); printf(__VA_ARGS__); \ +# define __debugs_spe(s, ...) do { \ + s->printf("[SPE] ", __VA_ARGS__); \ } while (0) #else /* DEBUG */ # define __debug_spe(...)
--- a/TaskManager/kernel/main.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/main.cc Sun Dec 27 20:49:38 2009 +0900 @@ -40,12 +40,6 @@ machineNum = atoi(argv[++i]); } else if (strcmp(argv[i], "-p") == 0) { profile = 1; - } else if (strcmp(argv[i], "-help") == 0) { - if (usr_help_str) { - printf("%s", usr_help_str); - } - printf("%s", help_str); - return EXIT_SUCCESS; } } @@ -54,6 +48,15 @@ manager->set_TMend(defaultTMend); + for (int i = 1; argv[i]; ++i) { + if (strcmp(argv[i], "-help") == 0) { + if (usr_help_str) { + manager->get_scheduler()->printf("%s", usr_help_str); + } + manager->get_scheduler()->printf("%s", help_str); + return EXIT_SUCCESS; + } + } if (profile) manager->start_profile(); if (TMmain(manager, argc, argv) < 0) {
--- a/TaskManager/kernel/ppe/HTask.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Sun Dec 27 20:49:38 2009 +0900 @@ -75,7 +75,7 @@ Task *next = t->next(); next->init(id, first->param_count, first->inData_count, first->outData_count); if ((memaddr)next - (memaddr)rbuf > r_size) - printf("too many task array used.\n"); + mimpl->get_scheduler()->printf("too many task array used.\n"); return next; } @@ -84,7 +84,7 @@ { int size = (memaddr)last - rbuf; if (size!= r_size) { - printf("spawn task array size differ size 0x%x r_size 0x%x\n", + mimpl->get_scheduler()->printf("spawn task array size differ size 0x%x r_size 0x%x\n", size, r_size); } }
--- a/TaskManager/kernel/ppe/Task.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,15 +1,16 @@ #include "Task.h" +#include "Scheduler.h" void -Task::print() +Task::print(Scheduler *s) { - printf("task id %d task size = %d param size %d " + s->printf("task id %d task size = %d param size %d " "inData size %d " "outData size %d\n", command, size(), param_count, inData_count, outData_count ); for(int i=0; i< param_count && i<5; i++) { // large param_count shall be a bug - printf("param %d = 0x%ld\n", i, (long)param(i)); + s->printf("param %d = 0x%ld\n", i, (long)param(i)); } }
--- a/TaskManager/kernel/ppe/Task.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/ppe/Task.h Sun Dec 27 20:49:38 2009 +0900 @@ -8,6 +8,7 @@ class SchedTask; +class Scheduler; class Task { public: // variables @@ -22,7 +23,7 @@ public: // functions - void print(); + void print(Scheduler *s); memaddr *param(int index) { memaddr p = (memaddr)data + sizeof(memaddr)*index;
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Sun Dec 27 20:49:38 2009 +0900 @@ -63,7 +63,7 @@ new_task = htaskImpl->create(TaskArray1); new_task->post_func = noaction; new_task->mimpl = this; - Task *task = new_task->create_task_array(cmd,1,8,8,8); + new_task->create_task_array(cmd,1,8,8,8); // rbuf, r_size were set new_task->command = TaskArray1;
--- a/TaskManager/kernel/ppe/TaskManagerImpl.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.h Sun Dec 27 20:49:38 2009 +0900 @@ -6,7 +6,8 @@ #include "TaskListInfo.h" #include "TaskQueueInfo.h" #include "HTaskInfo.h" -class Scheduler; +#include "Scheduler.h" +//class Scheduler; class MemList; @@ -59,7 +60,8 @@ #else posix_memalign(&buff, alignment, size); #endif - if (buff==0) fprintf(stderr,"Can't allocate memory\n"); + if (buff==0) + get_scheduler()->printf("Can't allocate memory\n"); return buff; } @@ -72,7 +74,8 @@ #else posix_memalign(&buff, DEFAULT_ALIGNMENT, size); #endif - if (buff==0) fprintf(stderr,"Can't allocate memory\n"); + if (buff==0) + get_scheduler()->printf("Can't allocate memory\n"); return buff; }
--- a/TaskManager/kernel/schedule/ListData.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/schedule/ListData.h Sun Dec 27 20:49:38 2009 +0900 @@ -35,12 +35,14 @@ size = 0; } - void print() { - printf("inList length %d size %d\n",length, size); +/* + void print(Scheduler *s) { + s->printf("inList length %d size %d\n",length, size); for(int i=0;i<length;i++) { - printf("inList element[%d] size %d addr %lx\n",i, element[i].size, (unsigned long)element[i].addr); + s->printf("inList element[%d] size %d addr %lx\n",i, element[i].size, (unsigned long)element[i].addr); } } +*/ }; typedef ListData* ListDataPtr;
--- a/TaskManager/kernel/schedule/SchedTask.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,3 +1,4 @@ + #include <stdlib.h> #include <string.h> #include "SchedTask.h" @@ -153,7 +154,7 @@ void* SchedTask::get_input(void *buff, int index) { - printf("Cannot use inData in SimpleTask use TaskArray\n"); + scheduler->printf("Cannot use inData in SimpleTask use TaskArray\n"); return NULL; } memaddr SchedTask::get_inputAddr(int index) { return 0; } int SchedTask::get_inputSize(int index) {return 0; } @@ -293,25 +294,14 @@ /* system call */ int -SchedTask::fprintf(FILE * stream, const char * format, ...) -{ - va_list ap; - va_start(ap,format); - int ret = vfprintf(stream,format, ap); - va_end(ap); - return ret; -} - -int SchedTask::printf(const char * format, ...) { va_list ap; va_start(ap,format); - int ret= vfprintf(stdout,format, ap); + int ret= scheduler->vprintf(format, ap); va_end(ap); return ret; } - /* end */
--- a/TaskManager/kernel/schedule/SchedTask.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.h Sun Dec 27 20:49:38 2009 +0900 @@ -130,7 +130,7 @@ FILE *stdout_; FILE *stderr_; FILE *stdin_; - int fprintf(FILE * stream, const char * format, ...); + int printf(const char * format, ...); };
--- a/TaskManager/kernel/schedule/Scheduler.cc Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Sun Dec 27 20:49:38 2009 +0900 @@ -1,6 +1,8 @@ #include <stdio.h> #include <stdlib.h> +#include <stdarg.h> #include "Scheduler.h" +#include "SchedTask.h" #include "SchedNop.h" #include "error.h" #include <assert.h> @@ -21,7 +23,7 @@ static int null_run(SchedTask* smanager, void* r, void *w) { - printf("Calling Undefined Task\n"); + smanager->printf("Calling Undefined Task\n"); return 0; } @@ -211,7 +213,7 @@ task_list[task_id].end-task_list[task_id].location); task_list[task_id].segment = s; #if 0 - fprintf(stderr,"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\n",task_id, (unsigned int)(task_list[task_id].segment->data ), (unsigned int)( (char*)task_list[task_id].segment->data + @@ -230,9 +232,9 @@ #if 0 MemorySegment *s = task_list[task_id].segment; if (s) - fprintf(stderr,"wait load task id %d 0x%x\n",task_id,(int)s->data); + m->printf("wait load task id %d 0x%x\n",task_id,(int)s->data); else - fprintf(stderr,"wait load task id %d 000000\n",task_id); + m->printf("wait load task id %d 000000\n",task_id); #endif // wait for code segment load m->wait_segment(task_list[task_id].segment); @@ -243,7 +245,7 @@ task_list[task_id].entry_offset); task_list[task_id].run = run; #if 0 - fprintf(stderr,"wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, + m->printf("wait load task id %d done. creator = 0x%x entry_offset = 0x%x\n",task_id, (unsigned int)run, task_list[task_id].entry_offset); #endif @@ -275,11 +277,11 @@ task_list[cmd].load = load_task; task_list[cmd].wait = wait_load; #if 0 -fprintf(stderr,"cmd = %d\n",cmd); -fprintf(stderr,"locatation = 0x%x\n",start); -fprintf(stderr,"end = 0x%x\n",start+size); -fprintf(stderr,"size = 0x%x\n",size); -fprintf(stderr,"entry = 0x%x\n",entry_offset); +this->printf("cmd = %d\n",cmd); +this->printf("locatation = 0x%x\n",start); +this->printf("end = 0x%x\n",start+size); +this->printf("size = 0x%x\n",size); +this->printf("entry = 0x%x\n",entry_offset); #endif } @@ -342,7 +344,7 @@ MemorySegment *s = hash->get(addr); if (s) { /* 既に load されている */ -// fprintf(stderr,"get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); +// this->printf("get_segement loaded %llx 0x%x size 0x%d\n",addr,s->data,size); m->moveToFirst(s); return s; } @@ -361,7 +363,7 @@ s->address = addr; hash->put(s->address, s); -// fprintf(stderr,"get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); +// this->printf("get_segement %llx 0x%x size 0x%d\n",addr, s->data,size); return s; } @@ -432,4 +434,31 @@ } +int +Scheduler::printf(const char * format, ...) +{ +#if !defined(__SPU__) + va_list ap; + va_start(ap,format); + int ret= vprintf(format, ap); + va_end(ap); + return ret; +#else + return 0; +#endif +} + + +int +Scheduler::vprintf(const char * format, va_list ap) +{ +#if !defined(__SPU__) + int ret= vprintf(format, ap); + return ret; +#else + return 0; +#endif +} + + /* end */
--- a/TaskManager/kernel/schedule/Scheduler.h Thu Dec 24 05:04:34 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Sun Dec 27 20:49:38 2009 +0900 @@ -2,6 +2,7 @@ #define INCLUDED_SCHEDULER #include <stdlib.h> +#include <stdarg.h> #include "base.h" #include "TaskList.h" #include "ListData.h" @@ -136,7 +137,8 @@ void* allocate(int size,int align) ; long get_random() ; Scheduler *get_scheduler() { return this; }; - + int printf(const char *format, ...); + int vprintf(const char *format, va_list ap); }; @@ -157,7 +159,6 @@ inline void loadSchedTask(Scheduler *scheduler,int command) { -// fprintf(stderr,"loadSchedTask %d\n",task->command); task_list[command].load(scheduler,command); }