Mercurial > hg > Members > kono > Cerium
changeset 81:b03a4d3565c0
*** empty log message ***
author | gongo |
---|---|
date | Wed, 20 Feb 2008 17:07:11 +0900 |
parents | 1c648675c2bd |
children | 14a5ca0be17e |
files | TaskManager/Cell/spe/SchedTask.cc TaskManager/Cell/spe/SchedTaskList.cc TaskManager/Cell/spe/main.cc TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/span_pack.h TaskManager/Test/simple_render/spe/spe-main.cpp TaskManager/Test/simple_render/spu_span.h TaskManager/Test/simple_render/viewer.cpp |
diffstat | 8 files changed, 302 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/SchedTask.cc Wed Feb 20 17:07:11 2008 +0900 @@ -0,0 +1,95 @@ +#include "SchedTask.h" +#include "SchedTaskList.h" +#include "SchedNop2Ready.h" +#include "DmaManager.h" +#include "error.h" +#include "TaskManager.h" + +//extern int (*func_list[16])(void*, void*); + +SchedTask::SchedTask(TaskListPtr _list, TaskPtr _task, void *rbuf, void *wbuf, + DmaManager* cn) +{ + list = _list; + task = _task; + readbuf = rbuf; + writebuf = wbuf; + connector = cn; +} + +void +SchedTask::read(void) +{ + __debug("[SchedTask:%s]\n", __FUNCTION__); + + //task = &list->tasks[--list->length]; + connector->dma_load(readbuf, task->in_addr, task->in_size, DMA_READ); +} + +void +SchedTask::exec(void) +{ + __debug("[SchedTask:%s]\n", __FUNCTION__); + + connector->dma_wait(DMA_READ); + + __debug(" task->command = %d\n", task->command); + __debug(" task->in_size = %d\n", task->in_size); + __debug(" task->in_addr = 0x%x\n", task->in_addr); + __debug(" task->out_addr = 0x%x\n", task->out_addr); + __debug(" list->next = 0x%x\n", (unsigned int)list->next); + __debug(" list->length = 0x%x\n", (unsigned int)list->length); + + //task->in_size = func_list[task->command](readbuf, writebuf); + task->in_size = run(readbuf, writebuf); + connector->dma_store(writebuf, task->out_addr, task->in_size, DMA_WRITE); +} + +void +SchedTask::write(void) +{ + __debug("[SchedTask:%s]\n", __FUNCTION__); + + connector->dma_wait(DMA_WRITE); + connector->mail_write((unsigned int)task->self); +} + +SchedTaskBase* +SchedTask::next(Scheduler *m, SchedTaskBase *p) +{ + __debug("[SchedTask:%s]\n", __FUNCTION__); + + delete p; + + // ここ直さねば。どうやって if 文消そう? + // オブジェクト増やせばいいのかな + if (list->length == 0) { + if (list->next == 0) { + return new SchedNop2Ready(connector); + } else { + return new SchedTaskList((unsigned int)list->next, + m->get_curListBuf(), connector); + } + } else { + //return new SchedTask(list, m->get_curReadBuf(), + //m->get_curWriteBuf(), connector); + + // 本当は、ここで task->command に対応する、 + // SchedTask を継承する class を作ればいい。。。はず + return new SchedTask(list, &list->tasks[--list->length], + m->get_curReadBuf(), m->get_curWriteBuf(), + connector); + } +} + +extern SchedTask* (*task_list[16])(TaskListPtr, TaskPtr, void*, void*, + DmaManager*); + +SchedTask* +CreateSchedTask(TaskListPtr taskList, void *readbuf, void *writebuf, + DmaManager* dma) +{ + TaskPtr task = &taskList->tasks[--taskList->length]; + + return task_list[task->command](taskList, task, readbuf, writebuf, dma); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/SchedTaskList.cc Wed Feb 20 17:07:11 2008 +0900 @@ -0,0 +1,48 @@ +#include "SchedTaskList.h" +#include "SchedTask.h" +#include "SchedNop2Ready.h" +#include "DmaManager.h" +#include "error.h" + +SchedTaskList::SchedTaskList(unsigned int addr, TaskListPtr listbuf, DmaManager* c) +{ + params_addr = addr; + list = listbuf; + connector = c; +} + +void +SchedTaskList::read(void) +{ + __debug("[SchedTaskList:%s]\n", __FUNCTION__); + + connector->dma_load(list, params_addr, sizeof(TaskList), DMA_READ); + connector->dma_wait(DMA_READ); +} + +extern SchedTask* CreateSchedTask(TaskListPtr, void*, void*, DmaManager*); + +SchedTaskBase* +SchedTaskList::next(Scheduler *m, SchedTaskBase *p) +{ + __debug("[SchedTaskList:%s]\n", __FUNCTION__); + + delete p; + + if (list->length < 1) { + return new SchedNop2Ready(connector); + } else { + // 本当は、ここで task->command に対応する、 + // SchedTask を継承する class を作ればいい。。。はず +#if 0 + return new SchedTask(list, &list->tasks[--list->length], + m->get_curReadBuf(), + m->get_curWriteBuf(), + connector); +#else + return CreateSchedTask(list, m->get_curReadBuf(), m->get_curWriteBuf(), + connector); +#endif + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Cell/spe/main.cc Wed Feb 20 17:07:11 2008 +0900 @@ -0,0 +1,16 @@ +#include <stdio.h> +#include "CellScheduler.h" + +int +main(unsigned long long speid, + unsigned long long argc, unsigned long long argv) +{ + CellScheduler *manager; + + manager = new CellScheduler(); + manager->init(); + manager->run(); + manager->finish(); + + return 0; +}
--- a/TaskManager/Test/simple_render/Makefile Wed Feb 20 10:56:37 2008 +0900 +++ b/TaskManager/Test/simple_render/Makefile Wed Feb 20 17:07:11 2008 +0900 @@ -13,8 +13,8 @@ EXTRA_CFLAGS = `sdl-config --cflags` `xml2-config --cflags`\ -#EXTRA_LIBS = -lCellManager -lspe2 -lpthread -EXTRA_LIBS = -lFifoManager +EXTRA_LIBS = -lCellManager -lspe2 -lpthread +#EXTRA_LIBS = -lFifoManager LIBS = `sdl-config --libs` -lSDL_image -lGL \ `xml2-config --libs` -L../.. $(EXTRA_LIBS)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Test/simple_render/span_pack.h Wed Feb 20 17:07:11 2008 +0900 @@ -0,0 +1,29 @@ +#ifndef INCLUDED_SPAN_PACK +#define INCLUDED_SPAN_PACK + +typedef struct Span { + long *tex_addr, tex_width, tex_height; + int x, y, length_x; + float start_z, end_z; + float tex_x1, tex_x2, tex_y1, tex_y2; +} SPAN, *SPNA_PTR; + +typedef struct SpanPack { + struct SPAN_INFO { + int size; + int light_pos[3]; + int light_rgb[3]; + } info; + //SPAN span[250]; + SPAN span[70]; + //SPAN *span; +} SPANPACK, *SPANPACK_PTR; + +typedef struct SpanPackList { + int size; + SPANPACK dline[60]; + //SPANPACK dline[135]; + //SPANPACK *dline; +} SPANPACKLIST; + +#endif
--- a/TaskManager/Test/simple_render/spe/spe-main.cpp Wed Feb 20 10:56:37 2008 +0900 +++ b/TaskManager/Test/simple_render/spe/spe-main.cpp Wed Feb 20 17:07:11 2008 +0900 @@ -1,6 +1,10 @@ +#include "SchedTask.h" + +#if 0 + +#include <stdio.h> #include <string.h> -//#include <simdmath.h> -#include <simdmath/sinf4.h> +#include <math.h> #include "polygon_pack.h" #include "scene_graph_pack.h" #include "sys.h" @@ -61,16 +65,6 @@ return sizeof(PolygonPack); } -void matrix4x4(float *xyz, float *xyz1, float *xyz2) //xyz[16] -{ - for(int t=0; t<16; t+=4) - { - for(int i=0; i<4; i++) - { - xyz[t+i] = xyz1[t]*xyz2[i] + xyz1[t+1]*xyz2[4+i] + xyz1[t+2]*xyz2[8+i] + xyz1[t+3]*xyz2[12+i]; - } - } -} void rotate(float *xyz, float *matrix) { @@ -87,6 +81,17 @@ } +void matrix4x4(float *xyz, float *xyz1, float *xyz2) //xyz[16] +{ + for(int t=0; t<16; t+=4) + { + for(int i=0; i<4; i++) + { + xyz[t+i] = xyz1[t]*xyz2[i] + xyz1[t+1]*xyz2[4+i] + xyz1[t+2]*xyz2[8+i] + xyz1[t+3]*xyz2[12+i]; + } + } +} + void get_matrix( float *matrix, float *rxyz, float *txyz, float *stack) { float radx,rady,radz; @@ -94,7 +99,7 @@ rady = rxyz[1]*3.14/180; radz = rxyz[2]*3.14/180; -#if 1 +#if 0 vector float rad = (vector float){radx, rady, radz, 0}; vector float in_sin = _sinf4(rad); vector float in_cos = _sinf4(rad); @@ -153,7 +158,6 @@ //update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp) update_sgp(void *rbuf, void *wbuf) { -#if 0 SceneGraphPack *sgp = (SceneGraphPack*)rbuf; SceneGraphPack *_sgp = (SceneGraphPack*)wbuf; @@ -192,9 +196,15 @@ // それはユーザ側で in/out になるように書かせるもの? memcpy(_sgp, sgp, sizeof(SceneGraphPack)); -#endif - return sizeof(SceneGraphPack); } int (*func_list[16])(void*, void*) = {0, update_sgp, create_pp, 0}; +//int (*func_list[16])(void*, void*) = {0, 0, create_pp, 0}; +#endif + +extern SchedTask* +createTask_createPolygonPack(TaskListPtr _taskList, TaskPtr _task, + void *rbuff, void *wbuff, DmaManager *dma); + +SchedTask* (*task_list[16])(TaskListPtr, TaskPtr, void*, void*, DmaManager*) = {0, 0, createTask_createPolygonPack, 0};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Test/simple_render/spu_span.h Wed Feb 20 17:07:11 2008 +0900 @@ -0,0 +1,23 @@ +#ifndef INCLUDED_SPU_SPAN +#define INCLUDED_SPU_SPAN + +#ifndef INCLUDED_SPAN_PACK +#include "span_pack.h" +#endif + +typedef struct SPUSPAN { + int length; + SPANPACK_PTR spp[64]; + SPUSPAN *next; +} SPUSPAN; + +typedef struct SPUSPANLIST { + SPUSPAN ss[6]; +} SPUSPANLIST; + +typedef struct SPLSSL { + SPUSPANLIST *ssl; + SPANPACKLIST *spl; +} SPLSSL; + +#endif
--- a/TaskManager/Test/simple_render/viewer.cpp Wed Feb 20 10:56:37 2008 +0900 +++ b/TaskManager/Test/simple_render/viewer.cpp Wed Feb 20 17:07:11 2008 +0900 @@ -3,6 +3,7 @@ #include "polygon.h" #include "viewer.h" #include "sys.h" +#include "spu_span.h" using namespace std; #define redMask 0x00ff0000 @@ -219,10 +220,15 @@ SDL_PixelFormat *pixelFormat; Uint32 background; Polygon *polygon; -SceneGraphPack *sgp; -PolygonPack *pp; -//DmaBuffer *sgp_buff __attribute__((aligned(DEFAULT_ALIGNMENT))); -//DmaBuffer *pp_buff __attribute__((aligned(DEFAULT_ALIGNMENT))); +//SceneGraphPack *sgp; +//PolygonPack *pp; +DmaBuffer *sgp_buff; +DmaBuffer *pp_buff; +DmaBuffer *spl_buff; +DmaBuffer *sp_buff; +DmaBuffer *ssl_buff; +DmaBuffer *splssl_buff; + void Viewer::run_init() @@ -231,6 +237,8 @@ int fd; SceneGraphPack *sgp; + SPANPACKLIST *spl; + SPLSSL *splssl; start_time = get_ticks(); this_time = 0; @@ -242,12 +250,29 @@ polygon->set_data("cube.xml"); polygon->viewer = this; -#if 0 +#if 1 // 通信用 buffer の allocate // これじゃないと通信用に使えない(ように処理を書かないと!) sgp_buff = manager->allocate(sizeof(SceneGraphPack)); + pp_buff = manager->allocate(sizeof(PolygonPack)); + + sp_buff = manager->allocate(sizeof(SPANPACK)); + spl_buff = manager->allocate(sizeof(SPANPACKLIST)); + + spl_buff->get_buffer(&spl); + spl->size = 60; + spl_buff->swap_buffer(); + spl_buff->get_buffer(&spl); + spl->size = 60; + spl_buff->swap_buffer(); + + ssl_buff = manager->allocate(sizeof(SPUSPANLIST)); + splssl_buff = manager->allocate(sizeof(SPLSSL)); + sgp_buff->get_buffer(&sgp); + //spl_buff->get_buffer(&spl); + create_sgp(polygon, sgp); sgp_buff->swap_buffer(); @@ -255,12 +280,16 @@ create_sgp(polygon, sgp); sgp_buff->swap_buffer(); - pp_buff = manager->allocate(sizeof(PolygonPack)); + + + #else - sgp = new SceneGraphPack; + //sgp = new SceneGraphPack; + posix_memalign((void**)&sgp, DEFAULT_ALIGNMENT, sizeof(SceneGraphPack)); create_sgp(polygon, sgp); - pp = new PolygonPack; + //pp = new PolygonPack; + posix_memalign((void**)&pp, DEFAULT_ALIGNMENT, sizeof(PolygonPack)); #endif pixels = new Uint32[width*height]; @@ -280,10 +309,14 @@ Viewer::run_loop(void) { HTaskPtr task_update_sgp = NULL; - HTaskPtr task_create_pp = NULL; - HTaskPtr task_finish = NULL; + HTaskPtr task_create_pp = NULL; + HTaskPtr task_create_sp = NULL; + HTaskPtr task_spu_sp = NULL; + HTaskPtr task_finish = NULL; int fd_update_sgp; int fd_create_pp; + int fd_create_sp; + int fd_spu_sp; int fd_finish; HTaskPtr task; @@ -308,22 +341,31 @@ fd_update_sgp = manager->open("UpdateSGP"); fd_create_pp = manager->open("CreatePP"); + //fd_create_sp = manager->open("CreateSP"); + //fd_spu_sp = manager->open("SpuSP"); fd = manager->open("ViewerRunDraw"); - task_update_sgp = manager->create_task(fd_update_sgp, - sizeof(SceneGraphPack), - //sgp_buff, sgp_buff, NULL); - (unsigned int)sgp, (unsigned int)sgp, NULL); - task_create_pp = manager->create_task(fd_create_pp, - sizeof(SceneGraphPack), - //sgp_buff, pp_buff, NULL); - (unsigned int)sgp, (unsigned int)pp, NULL); + + task_update_sgp + = manager->create_task(fd_update_sgp, sizeof(SceneGraphPack), + sgp_buff, sgp_buff, NULL); + task_create_pp + = manager->create_task(fd_create_pp, sizeof(SceneGraphPack), + sgp_buff, pp_buff, NULL); +#if 0 + task_create_sp + = manager->create_task(fd_update_sgp, sizeof(SceneGraphPack), + sgp_buff, sgp_buff, NULL); + task_spu_sp + = manager->create_task(fd_create_pp, sizeof(SceneGraphPack), + sgp_buff, pp_buff, NULL); +#endif task = manager->create_task(fd, 0, 0, 0, NULL); task->set_depend(task_update_sgp); task->set_depend(task_create_pp); //task_update_sgp->set_cpu(CPU_SPE); - //task_create_pp->set_cpu(CPU_SPE); + task_create_pp->set_cpu(CPU_SPE); task_update_sgp->spawn(); task_create_pp->spawn(); @@ -338,9 +380,9 @@ HTaskPtr task; int fd; - //PolygonPack *pp; + PolygonPack *pp; - //pp_buff->get_buffer(&pp); + pp_buff->get_buffer(&pp); polygon->draw(pp); // test draw of PolygonPack SDL_BlitSurface(bitmap, NULL, screen, NULL);