Mercurial > hg > Game > Cerium
changeset 1834:9f5dbb845689 draft
fix for statement in GpuScheduler
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Dec 2013 11:11:41 +0900 |
parents | cfa08ee89d64 |
children | 144e573b030b |
files | TaskManager/Gpu/GpuScheduler.cc example/fft/Makefile |
diffstat | 2 files changed, 22 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Wed Dec 18 20:10:32 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Thu Dec 19 11:11:41 2013 +0900 @@ -217,65 +217,36 @@ if (tasklist->self) { flag = tasklist->self->flag; } - TaskPtr nextTask = NULL; - nextTask = tasklist->tasks; - while (nextTask < tasklist->last()) { + for (TaskPtr nextTask = tasklist->tasks; nextTask < tasklist->last(); nextTask = nextTask->next()) { if(nextTask->command==ShowTime) { - connector->show_profile(); - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; + connector->show_profile(); continue; } if(nextTask->command==StartProfile) { - connector->start_profile(); - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; + connector->start_profile(); continue; } - if (load_kernel(nextTask->command) == 0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (load_kernel(nextTask->command) == 0) { gpuTaskError(cur,tasklist,ret); continue; } 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]); kernel[cur] = clCreateKernel(program, function, &ret); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } int param = 0; // set arg count cl_mem memparam = createBuffer(&memin[cur], 0, context, CL_MEM_READ_ONLY, sizeof(memaddr)*nextTask->param_count, &ret); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } + // parameter is passed as first kernel arg - param=0; - ret = clEnqueueWriteBuffer(command_queue, memparam, CL_TRUE, 0,sizeof(memaddr)*nextTask->param_count, nextTask->param(param), 0, NULL, &memin[cur].event[0]); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } ret = clSetKernelArg(kernel[cur], param, sizeof(memaddr),(void *)&memin[cur].buf[0]); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } param++; @@ -286,25 +257,13 @@ ListElement *input_buf = nextTask->inData(i); if (input_buf->size==0) break; createBuffer(&memin[cur], param, context, mem_flag, input_buf->size, &ret); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } ret = clEnqueueWriteBuffer(command_queue, memin[cur].buf[param], CL_TRUE, 0, input_buf->size, input_buf->addr, 0, NULL, &memin[cur].event[param]); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } ret = clSetKernelArg(kernel[cur], param, sizeof(memaddr), (void *)&memin[cur].buf[param]); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } param++; } @@ -321,11 +280,7 @@ ListElement *output_buf = flag.flip? nextTask->inData(i) : nextTask->outData(i); if (output_buf->size==0) break; createBuffer(&memout[cur], i, context, out_mem_flag, output_buf->size, &ret); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } if (flag.flip) { // use output buffer as input buffer ListElement *input_buf = nextTask->inData(i); @@ -333,18 +288,10 @@ ret = clEnqueueWriteBuffer(command_queue, memout[cur].buf[param], CL_TRUE, 0, input_buf->size, input_buf->addr, 0, NULL, &memout[cur].event[param]); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } } ret = clSetKernelArg(kernel[cur], param, sizeof(memaddr), (void *)&memout[cur].buf[i]); - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } param++; } @@ -356,37 +303,20 @@ ret = clEnqueueTask(command_queue, kernel[cur], memin[cur].size, memin[cur].event, &kernel_event[cur]); } - if (ret<0) { - gpuTaskError(cur, tasklist, ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur, tasklist, ret); continue; } for(int i=0;i<nextTask->outData_count;i++) { // read output data ListElement *output_buf = flag.flip? nextTask->inData(i) :nextTask->outData(i); if (output_buf->size==0) break; ret = clEnqueueReadBuffer(command_queue, memout[cur].buf[i], CL_FALSE, 0, output_buf->size, output_buf->addr, 1, &kernel_event[cur], &memout[cur].event[i]); - - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } + if (ret<0) { gpuTaskError(cur,tasklist,ret); continue; } } - - if (ret<0) { - gpuTaskError(cur,tasklist,ret); - nextTask = nextTask->next(); - continue; - } - // wait kernel[1-cur] and write[1-cur] + // pipeline : cur + // to stop pipeline set 1-cur wait_for_event(kernel_event, memout, tasklist, cur); - // pipeline : cur - // no pipeline : 1-cur cur = 1 - cur; - nextTask = nextTask->next(); } reply = (memaddr)tasklist->waiter; params_addr = (memaddr)tasklist->next;
--- a/example/fft/Makefile Wed Dec 18 20:10:32 2013 +0900 +++ b/example/fft/Makefile Thu Dec 19 11:11:41 2013 +0900 @@ -1,5 +1,4 @@ -default: macosx - +default: macosx macosx: FORCE @echo "Make for Mac OS X" @$(MAKE) -f Makefile.macosx @@ -20,8 +19,8 @@ @echo "Make for OpenCL" @$(MAKE) -f Makefile.gpu -test: FORCE - @$(MAKE) -f Makefile.macosx hoge +test: gpu + ./fft -file lena512.pgm -gpu -g FORCE: