Mercurial > hg > Game > Cerium
changeset 1553:21ddbc06dcde draft
fix GpuScheduler
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 17 Feb 2013 19:42:36 +0900 |
parents | 40a554d45fc6 |
children | bd97edaed523 |
files | TaskManager/Gpu/GpuScheduler.cc example/fft/task_init.cc example/many_task/main.cc |
diffstat | 3 files changed, 26 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Sun Feb 17 14:51:45 2013 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Sun Feb 17 19:42:36 2013 +0900 @@ -45,7 +45,11 @@ exit(EXIT_FAILURE); } context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); - command_queue = clCreateCommandQueue(context, device_id, 0, &ret); + command_queue = clCreateCommandQueue(context, device_id, 0,&ret); + if (ret<0) { + const char *msg=convert_error_status(ret); + error(msg); + } } GpuScheduler::~GpuScheduler() @@ -68,9 +72,7 @@ int cur = 0; memaddr reply[2]; cl_kernel *kernel = new cl_kernel[2]; - cl_event event[2]; - event[0] = NULL; - event[1] = NULL; + cl_event *event = new cl_event[2]; cl_mem *memin[2]; cl_mem *memout[2]; HTask::htask_flag flag; @@ -142,9 +144,14 @@ // set arg count cl_mem memparam = clCreateBuffer(context, CL_MEM_READ_ONLY, - sizeof(memaddr)*nextTask->param_count, NULL, NULL); - ret = clEnqueueWriteBuffer(command_queue, memparam, CL_TRUE, 0, - sizeof(memaddr)*nextTask->param_count,nextTask->param(0), 0, NULL, NULL); + sizeof(memaddr)*nextTask->param_count, NULL, &ret); + if (ret<0) { + const char *msg=convert_error_status(ret); + error(msg); + } + + ret = clEnqueueWriteBuffer(command_queue, memparam, CL_TRUE, 0,sizeof(memaddr)*nextTask->param_count, + nextTask->param(0), 0, NULL, NULL); if (ret<0) { const char *msg=convert_error_status(ret); error(msg); @@ -230,30 +237,27 @@ const char *msg=convert_error_status(ret); error(msg); } - // ndrange flagが0ならdim,global_work_size[0],local_work_size[0] = 1で固定に - // clEnqueueNDRange - // (command_queue, kernel[cur], dim, NULL,global_work_size[0],local_work_size[0],NULL&ev); 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][i], CL_TRUE, 0, - output_buf->size, output_buf->addr, 0, NULL, NULL); + output_buf->size, output_buf->addr, 0, NULL, &event[cur]); if (ret<0) { const char *msg=convert_error_status(ret); error(msg); } } - - ret = clEnqueueMarkerWithWaitList(command_queue,0,NULL,&event[cur]); + if (ret<0) { const char *msg=convert_error_status(ret); error(msg); } reply[cur] = (memaddr)tasklist->waiter; //clFlush(command_queue); // waiting for queued task - if (event[1-cur] != NULL) { + if (event[1-cur] != 0) { ret=clWaitForEvents(1,&event[1-cur]); + event[1-cur]=NULL; } if (ret<0) { const char *msg=convert_error_status(ret); @@ -275,7 +279,7 @@ } } clFlush(command_queue); // waiting for queued task - //ret=clWaitForEvents(1,&event[1-cur]); + clFinish(command_queue); // waiting for queued task connector->mail_write(reply[1-cur]); connector->mail_write((memaddr)MY_SPE_STATUS_READY);
--- a/example/fft/task_init.cc Sun Feb 17 14:51:45 2013 +0900 +++ b/example/fft/task_init.cc Sun Feb 17 19:42:36 2013 +0900 @@ -15,12 +15,12 @@ task_init(void) { #ifdef __CERIUM_GPU__ - GpuSchedRegister(SPIN_FACT, "gpu/fft.cl", "spinFact"); - GpuSchedRegister(BIT_REVERSE, "gpu/fft.cl", "bitReverse"); - GpuSchedRegister(NORMALIZATION, "gpu/fft.cl", "norm"); - GpuSchedRegister(BUTTERFLY, "gpu/fft.cl", "butterfly"); - GpuSchedRegister(TRANSEPOSE, "gpu/fft.cl", "transpose"); - GpuSchedRegister(HIGH_PASS_FILTER, "gpu/fft.cl", "highPassFilter"); + GpuSchedRegister(SPIN_FACT, "gpu/spinFact.cl", "spinFact"); + GpuSchedRegister(BIT_REVERSE, "gpu/bitReverse.cl", "bitReverse"); + GpuSchedRegister(NORMALIZATION, "gpu/norm.cl", "norm"); + GpuSchedRegister(BUTTERFLY, "gpu/butterfly.cl", "butterfly"); + GpuSchedRegister(TRANSEPOSE, "gpu/transpose.cl", "transpose"); + GpuSchedRegister(HIGH_PASS_FILTER, "gpu/passFilter.cl", "highPassFilter"); #else SchedRegisterTask(QUICK_SORT, QuickSort); SchedRegisterTask(SPIN_FACT,spinFact);
--- a/example/many_task/main.cc Sun Feb 17 14:51:45 2013 +0900 +++ b/example/many_task/main.cc Sun Feb 17 19:42:36 2013 +0900 @@ -77,7 +77,7 @@ static void show_data(void) { - /* + /* puts("-----------------------------------------------"); for(int i = 0; i < sorter.data_length; i++) { printf("data[%02d].index = %d\n", i, sorter.data[i].index);