Mercurial > hg > Game > Cerium
changeset 1633:fbb4757d82ee draft
refactor GpuScheduler
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 11 Jun 2013 16:32:17 +0900 |
parents | b0e84541e2d6 |
children | c0841aa109a8 a11565fea1e5 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h example/add/ppe/task_init.cc example/fft/main.cc |
diffstat | 4 files changed, 39 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Tue Jun 11 16:15:32 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Tue Jun 11 16:32:17 2013 +0900 @@ -63,20 +63,20 @@ void -GpuScheduler::WaitForEvent(cl_event* event,memaddr* reply,int cur) { - if (event[1-cur] != NULL) { - int ret=clWaitForEvents(1,&event[1-cur]); - clReleaseEvent(event[1-cur]); - if (ret<0) { - const char *msg=convert_error_status(ret); - error(msg); +GpuScheduler::wait_for_event(cl_event* event,memaddr* reply,int cur) { + if (event[1-cur] != NULL) { + int ret=clWaitForEvents(1,&event[1-cur]); + clReleaseEvent(event[1-cur]); + if (ret<0) { + const char *msg=convert_error_status(ret); + error(msg); + } + if(reply[1-cur]) { + connector->mail_write(reply[1-cur]); + reply[1-cur]=0; + } + event[1-cur]=NULL; } - if(reply[1-cur]) { - connector->mail_write(reply[1-cur]); - reply[1-cur]=0; - } - event[1-cur]=NULL; - } } @@ -106,21 +106,21 @@ if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) { clFinish(command_queue); - if (kernel[0]) - clReleaseKernel(kernel[0]); - if (kernel[1]) - clReleaseKernel(kernel[1]); - if (event[0]) - clReleaseEvent(event[0]); - if (event[1]) - clReleaseEvent(event[1]); + if (kernel[0]) + clReleaseKernel(kernel[0]); + if (kernel[1]) + clReleaseKernel(kernel[1]); + if (event[0]) + clReleaseEvent(event[0]); + if (event[1]) + clReleaseEvent(event[1]); return ; } while (params_addr) { // since we are on the same memory space, we don't has to use dma_load here TaskListPtr tasklist = (TaskListPtr)connector->dma_load(this, params_addr, - sizeof(TaskList), DMA_READ_TASKLIST); + sizeof(TaskList), DMA_READ_TASKLIST); /* * get flip flag @@ -136,8 +136,8 @@ cl_program& program = *gpu_task_list[nextTask->command].gputask->program; const char *function = gpu_task_list[nextTask->command].name; - if (kernel[cur]) - clReleaseKernel(kernel[cur]); + if (kernel[cur]) + clReleaseKernel(kernel[cur]); kernel[cur] = clCreateKernel(program, function, &ret); if (ret<0) { const char *msg=convert_error_status(ret); @@ -263,7 +263,7 @@ reply[cur] = (memaddr)tasklist->waiter; - WaitForEvent(event,reply,cur); + wait_for_event(event,reply,cur); //clFlush(command_queue); // waiting for queued task // clFlush(command_queue); @@ -278,7 +278,7 @@ cur = 1 - cur; } } - WaitForEvent(event,reply,cur); + wait_for_event(event,reply,cur); //clFlush(command_queue); // waiting for queued task //clFinish(command_queue); // waiting for queued task connector->mail_write((memaddr)MY_SPE_STATUS_READY); @@ -329,8 +329,8 @@ cl_program *program = new cl_program; *program = clCreateProgramWithSource(context, 1, - (const char **)&source_str, - (const size_t *)&source_size, &ret); + (const char **)&source_str, + (const size_t *)&source_size, &ret); ret = clBuildProgram(*program, 1, &device_id, NULL, NULL, NULL); if(ret<0) {
--- a/TaskManager/Gpu/GpuScheduler.h Tue Jun 11 16:15:32 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.h Tue Jun 11 16:32:17 2013 +0900 @@ -21,7 +21,7 @@ virtual ~GpuScheduler(); void init_impl(int useRefDma); void init_gpu(); - void WaitForEvent(cl_event* event,memaddr* reply,int cur); + void wait_for_event(cl_event* event,memaddr* reply,int cur); void run(); void mail_write_from_host(memaddr data) {
--- a/example/add/ppe/task_init.cc Tue Jun 11 16:15:32 2013 +0900 +++ b/example/add/ppe/task_init.cc Tue Jun 11 16:32:17 2013 +0900 @@ -13,5 +13,5 @@ void task_init(void) { - SchedRegisterTask(ADD_TASK, Add); + SchedRegisterTask(ADD_TASK, Add); }
--- a/example/fft/main.cc Tue Jun 11 16:15:32 2013 +0900 +++ b/example/fft/main.cc Tue Jun 11 16:32:17 2013 +0900 @@ -78,19 +78,19 @@ case forward:flag[0] = 0x00000000; break; case inverse:flag[0] = 0x80000000; break; } - int* n = new int[1]; - int* m = new int[1]; - m[0] = m_; - n[0] = 1<<m[0]; + int n; + int m; + m = m_; + n = 1<<m; size_t gws[2],lws[2]; - int length_dst = n[0]*n[0]; - int length_src = n[0]*n[0]; + int length_dst = n*n; + int length_src = n*n; HTask* brev = manager->create_task(BIT_REVERSE); - setWorkSize(gws,lws,n[0],n[0]); + setWorkSize(gws,lws,n,n); brev->set_inData(0, src, length_src*sizeof(cl_float2)); - brev->set_inData(1, m,sizeof(int)); - brev->set_inData(2, n,sizeof(int)); + brev->set_inData(1, (memaddr)m,sizeof(int)); + brev->set_inData(2, (memaddr)n,sizeof(int)); brev->set_outData(0, dst, length_dst*sizeof(cl_float2)); brev->set_cpu(spe_cpu); brev->iterate(gws[0],gws[1]);