Mercurial > hg > Game > Cerium
changeset 1832:be9076dc8d49 draft
1-cur in GpuScheduler
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Dec 2013 19:53:52 +0900 |
parents | 1b4d4b3c0546 |
children | cfa08ee89d64 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h |
diffstat | 2 files changed, 17 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Wed Dec 18 18:55:23 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Wed Dec 18 19:53:52 2013 +0900 @@ -97,12 +97,12 @@ #define NOP_REPLY NULL static void -release_buf_event(int cur,GpuBufferPtr memout) { +release_buf_event(int cur, GpuScheduler::GpuBufferPtr memout) { for (int i=0; i < memout[1-cur].size; i++) { - if (memout[cur-1].event[i] != 0) + if (memout[1-cur].event[i] != 0) clReleaseEvent(memout[1-cur].event[i]); memout[1-cur].event[i] = 0; - if (memout[cur-1].buf[i] != 0) + if (memout[1-cur].buf[i] != 0) clReleaseMemObject(memout[1-cur].buf[i]); memout[1-cur].buf[i] = 0; } @@ -114,12 +114,9 @@ * kernel_event, memout_event */ void -GpuScheduler::wait_for_event(cl_event* kernel_event, GpuBufferPtr memout, memaddr reply, TaskListPtr taskList, int cur) { +GpuScheduler::wait_for_event(cl_event* kernel_event, GpuBufferPtr memout, TaskListPtr taskList, int cur) { if (kernel_event[1-cur] == NOP_REPLY) { - if(reply) { - connector->mail_write(reply); - reply=0; - } + } else if (kernel_event[1-cur] != NULL) { int ret=clWaitForEvents(1,&kernel_event[1-cur]); @@ -137,6 +134,7 @@ } clReleaseEvent(kernel_event[1-cur]); kernel_event[1-cur] = 0; + } if (memout[1-cur].size > 0) { @@ -150,8 +148,10 @@ if (memin[1-cur].size > 0) { release_buf_event(cur,memin); } - - + if(reply) { + connector->mail_write(reply); + reply = 0; + } } void @@ -166,10 +166,9 @@ kernel[cur] = 0; release_buf_event(1-cur,memout); release_buf_event(1-cur,memin); - reply = (memaddr)tasklist->waiter; // wait kernel[1-cur] and write[1-cur] - wait_for_event(kernel_event, memout, reply, tasklist, cur); + wait_for_event(kernel_event, memout, tasklist, cur); } /* @@ -183,6 +182,7 @@ { int cur = 0; TaskListPtr tasklist = NULL; + reply = 0; initGpuBuffer(&memin[0]);initGpuBuffer(&memin[1]); initGpuBuffer(&memout[0]);initGpuBuffer(&memout[1]); memset(&flag, 0, sizeof(HTask::htask_flag)); @@ -194,10 +194,10 @@ if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) { // wait_for_envet was called, so all kernel,buf,event have been released. clFinish(command_queue); - destroyGpuBuffer(&memout[cur-1]); + destroyGpuBuffer(&memout[1-cur]); destroyGpuBuffer(&memout[cur]); destroyGpuBuffer(&memin[cur]); - destroyGpuBuffer(&memin[cur-1]); + destroyGpuBuffer(&memin[1-cur]); return ; } @@ -382,21 +382,16 @@ printf("GPU %d %s\t%lld\n",tasklist->self->cpu_type,(char*)(gpu_task_list[tasklist->tasks[0].command].name),tasklist->task_end_time-tasklist->task_start_time); // wait kernel[1-cur] and write[1-cur] - wait_for_event(kernel_event, memout, 0, tasklist, cur); + wait_for_event(kernel_event, memout, tasklist, cur); // pipeline : 1-cur // no pipeline : cur cur = 1 - cur; nextTask = nextTask->next(); } reply = (memaddr)tasklist->waiter; - if(reply) { - connector->mail_write(reply); - reply=0; - } - params_addr = (memaddr)tasklist->next; } - wait_for_event(kernel_event, memout, reply, tasklist, cur); + wait_for_event(kernel_event, memout, tasklist, cur); unsigned long long wait = 0; (*connector->end_dmawait_profile)(&wait, &(connector->start_time), &(connector->stop_time));
--- a/TaskManager/Gpu/GpuScheduler.h Wed Dec 18 18:55:23 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.h Wed Dec 18 19:53:52 2013 +0900 @@ -27,7 +27,7 @@ virtual ~GpuScheduler(); void init_impl(int useRefDma); void init_gpu(); - void wait_for_event(cl_event* event,GpuBufferPtr m, memaddr reply,TaskListPtr taskList,int cur); + void wait_for_event(cl_event* event,GpuBufferPtr m, TaskListPtr taskList,int cur); void run(); void mail_write_from_host(memaddr data) {