Mercurial > hg > Game > Cerium
changeset 1811:8039c48763c4 draft
remove goto syntax
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 11 Dec 2013 20:00:54 +0900 |
parents | b0bd89171162 |
children | df5fc3a6d318 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h TaskManager/Makefile.cell |
diffstat | 3 files changed, 38 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Wed Dec 11 18:49:06 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Wed Dec 11 20:00:54 2013 +0900 @@ -140,6 +140,19 @@ } } +void +GpuScheduler::gpuTaskError(int cur, TaskListPtr *tasklist, int ret) +{ + error(convert_error_status(ret)); + kernel_event[cur] = NOP_REPLY; + kernel[cur] = 0; + memout[cur].buf = 0; + memin[cur].buf = 0; + reply[cur] = (memaddr)tasklist[cur]->waiter; + + // wait kernel[1-cur] and write[1-cur] + wait_for_event(kernel_event, memout, reply, tasklist, cur); +} /* * run GPU task @@ -186,17 +199,20 @@ flag = tasklist[cur]->self->flag; } - for (TaskPtr nextTask = tasklist[cur]->tasks;nextTask < tasklist[cur]->last(); nextTask = nextTask->next()) { + for (TaskPtr nextTask = tasklist[cur]->tasks;nextTask < tasklist[cur]->last(); nextTask = nextTask->next(),params_addr = (memaddr)tasklist[cur]->next) { if(nextTask->command==ShowTime) { connector->show_profile(); - goto nop_reply; + gpuTaskError(cur,tasklist,ret); + continue; } if(nextTask->command==StartProfile) { connector->start_profile(); - goto nop_reply; + gpuTaskError(cur,tasklist,ret); + continue; } if (load_kernel(nextTask->command) == 0) { - goto nop_skip; + gpuTaskError(cur,tasklist,ret); + continue; } cl_program& program = *gpu_task_list[nextTask->command].gputask->program; const char *function = gpu_task_list[nextTask->command].name; @@ -205,9 +221,8 @@ clReleaseKernel(kernel[cur]); kernel[cur] = clCreateKernel(program, function, &ret); if (ret<0) { - const char *msg=convert_error_status(ret); - error(msg); - goto nop_reply; + gpuTaskError(cur,tasklist,ret); + continue; } int param = 0; @@ -225,16 +240,14 @@ // parameter is passed as first kernel arg param=0; if (ret<0) { - const char *msg=convert_error_status(ret); - error(msg); - goto nop_reply; + gpuTaskError(cur,tasklist,ret); + continue; } ret = clSetKernelArg(kernel[cur], param, sizeof(memaddr),(void *)&memin[cur].buf[0]); if (ret<0) { - const char *msg=convert_error_status(ret); - error(msg); - goto nop_reply; + gpuTaskError(cur,tasklist,ret); + continue; } param++; @@ -313,9 +326,7 @@ memin[cur].event, &kernel_event[cur]); } if (ret<0) { - const char *msg=convert_error_status(ret); - error(msg); - goto nop_reply; + gpuTaskError(cur, tasklist, ret); } for(int i=0;i<nextTask->outData_count;i++) { // read output data @@ -325,31 +336,25 @@ output_buf->size, output_buf->addr, 1, &kernel_event[cur], &memout[cur].event[i]); if (ret<0) { - const char *msg=convert_error_status(ret); - error(msg); - goto nop_reply; + gpuTaskError(cur,tasklist,ret); + continue; } } tasklist[cur]->task_end_time = gettime(); if (ret<0) { - error(convert_error_status(ret)); -nop_reply: - kernel_event[cur] = NOP_REPLY; - kernel[cur] = 0; - memout[cur].buf = 0; - memin[cur].buf = 0; + gpuTaskError(cur,tasklist,ret); + continue; } -nop_skip: + reply[cur] = (memaddr)tasklist[cur]->waiter; // wait kernel[1-cur] and write[1-cur] wait_for_event(kernel_event, memout, reply, tasklist, cur); - // pipeline : 1-cur - // no pipeline : cur - params_addr = (memaddr)tasklist[cur]->next; } printf("GPU %d %s\t%lld\n",tasklist[cur]->self->cpu_type,(char*)(gpu_task_list[tasklist[cur]->tasks[0].command].name),tasklist[cur]->task_end_time-tasklist[cur]->task_start_time); + // pipeline : 1-cur + // no pipeline : cur cur = 1 - cur; } wait_for_event(kernel_event, memout, reply, tasklist, cur);
--- a/TaskManager/Gpu/GpuScheduler.h Wed Dec 11 18:49:06 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.h Wed Dec 11 20:00:54 2013 +0900 @@ -61,6 +61,7 @@ cl_mem createBuffer(GpuBuffer m, int i, cl_context context, cl_mem_flags flags, size_t size, cl_int *error); void initGpuBuffer(GpuBuffer m); void destroyGpuBuffer(GpuBuffer m); + void gpuTaskError(int cur, TaskListPtr *tasklist, int ret); }; #define GpuSchedRegister(str, filename, functionname) \
--- a/TaskManager/Makefile.cell Wed Dec 11 18:49:06 2013 +0900 +++ b/TaskManager/Makefile.cell Wed Dec 11 20:00:54 2013 +0900 @@ -30,9 +30,9 @@ $(CELL_SPE_DIR)/TaskQueue.cc \ $(CELL_SPE_DIR)/Task.cc -CELL_SPE_PROFILE = \ - $(KERN_SYSTASK_DIR)/ShowTime.cc \ - $(KERN_SYSTASK_DIR)/StartProfile.cc +#CELL_SPE_PROFILE = \ +# $(KERN_SYSTASK_DIR)/ShowTime.cc \ +# $(KERN_SYSTASK_DIR)/StartProfile.cc # $(wildcard $(CELL_SPE_DIR)/*.cc)