Mercurial > hg > Game > Cerium
changeset 1516:e544f9747169 draft
fix gpu kernel source
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 08 Nov 2012 17:20:10 +0900 |
parents | b3644b73d2cf |
children | 411401d1cb71 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Makefile.def TaskManager/test/GpuRunTest/GpuRunTest.cc TaskManager/test/GpuRunTest/Makefile.def example/many_task/Makefile example/many_task/Makefile.def example/many_task/main.cc example/many_task/sort.cc |
diffstat | 8 files changed, 28 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Tue Oct 23 14:41:27 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Thu Nov 08 17:20:10 2012 +0900 @@ -115,7 +115,8 @@ memout[i] = clCreateBuffer(context, out_mem_flag, nextTask->outData(i)->size, NULL, &ret); if (flag.flip) { // use output buffer as input buffer ret = clEnqueueWriteBuffer(command_queue[cur], memout[i], CL_TRUE, 0, - nextTask->inData(i)->size, nextTask->inData(i)->addr, 0, NULL, NULL); + nextTask->inData(i)->size, nextTask->inData(i)->addr, 0, NULL, NULL); + } ret = clSetKernelArg(kernel, param, sizeof(memaddr), (void *)&memout[i]); param++; @@ -130,21 +131,28 @@ for(int i=0;i<nextTask->outData_count;i++) { ret = clEnqueueReadBuffer(command_queue[cur], memout[i], CL_TRUE, 0, nextTask->outData(i)->size, nextTask->outData(i)->addr, 1, &ev, NULL); + } } reply[cur] = (memaddr)tasklist->waiter; - clFlush(command_queue[1-cur]); // waiting for queued task - if(reply[1-cur]) { - connector->mail_write(reply[1-cur]); + + usleep(10000); + clFinish(command_queue[cur]); // waiting for queued task + // pipeline : 1-cur + // no pipeline : cur + + if(reply[cur]) { + connector->mail_write(reply[cur]); } params_addr = (memaddr)tasklist->next; cur = 1 - cur; } - - clFlush(command_queue[1-cur]); // waiting for queued task - connector->mail_write(reply[1-cur]); + /* + clFlush(command_queue[1-cur]); // waiting for queued task + connector->mail_write(reply[1-cur]); + */ connector->mail_write((memaddr)MY_SPE_STATUS_READY); }
--- a/TaskManager/Makefile.def Tue Oct 23 14:41:27 2012 +0900 +++ b/TaskManager/Makefile.def Thu Nov 08 17:20:10 2012 +0900 @@ -33,13 +33,13 @@ ABIBIT = 64 -OPT = -g -DMAIL_QUEUE -DNOT_CHECK -DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE -#OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE +OPT = -g -O0 -DMAIL_QUEUE -DNOT_CHECK -DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE +#OPT = -O9 -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE -CC = g++ +CC = clang++ CFLAGS = -Wall `sdl-config --cflags` -m$(ABIBIT) $(OPT) LIBS = -m$(ABIBIT)
--- a/TaskManager/test/GpuRunTest/GpuRunTest.cc Tue Oct 23 14:41:27 2012 +0900 +++ b/TaskManager/test/GpuRunTest/GpuRunTest.cc Thu Nov 08 17:20:10 2012 +0900 @@ -82,7 +82,7 @@ HTaskPtr twice = manager->create_task(Twice); - twice->set_param(0, (memaddr)&length); + twice->set_param(0, (memaddr)length); twice->set_inData(0, indata, sizeof (int)*length); twice->set_outData(0, outdata, sizeof (int)*length); twice->set_cpu(GPU_0);
--- a/TaskManager/test/GpuRunTest/Makefile.def Tue Oct 23 14:41:27 2012 +0900 +++ b/TaskManager/test/GpuRunTest/Makefile.def Thu Nov 08 17:20:10 2012 +0900 @@ -2,8 +2,8 @@ CERIUM = ../../../../Cerium -CC = g++ -CFLAGS = -g -Wall +CC = clang++ +CFLAGS = -g -Wall -O0 INCLUDE = -I${CERIUM}/include/TaskManager -I. -I../.. LIBS = -L${CERIUM}/TaskManager
--- a/example/many_task/Makefile Tue Oct 23 14:41:27 2012 +0900 +++ b/example/many_task/Makefile Thu Nov 08 17:20:10 2012 +0900 @@ -20,7 +20,6 @@ @echo "Make for OpenCL" @$(MAKE) -f Makefile.gpu - FORCE: clean:
--- a/example/many_task/Makefile.def Tue Oct 23 14:41:27 2012 +0900 +++ b/example/many_task/Makefile.def Thu Nov 08 17:20:10 2012 +0900 @@ -9,7 +9,7 @@ OPT = -O9 # OPT = -g -O9 # OPT = -g -CC = g++ +CC = clang++ CFLAGS = -Wall $(OPT) -DUSE_SIMPLE_TASK # CFLAGS = -Wall $(OPT)
--- a/example/many_task/main.cc Tue Oct 23 14:41:27 2012 +0900 +++ b/example/many_task/main.cc Thu Nov 08 17:20:10 2012 +0900 @@ -153,7 +153,7 @@ TMend(TaskManager *manager) { ed_time = getTime(); - // show_data(); + show_data(); check_data(); printf("Time: %0.6f\n",ed_time-st_time); }
--- a/example/many_task/sort.cc Tue Oct 23 14:41:27 2012 +0900 +++ b/example/many_task/sort.cc Thu Nov 08 17:20:10 2012 +0900 @@ -57,16 +57,19 @@ } + for (int i = 0; i < s->split_num-1; i++) { s->fsort[i] = manager->create_task(QUICK_SORT, (memaddr)&s->data[i*block_num], sizeof(Data)*block_num, (memaddr)&s->data[i*block_num], sizeof(Data)*block_num); + s->fsort[i]->flip(); + if (i>0 && s->bsort[i-1]) { s->fsort[i]->wait_for(s->bsort[i-1]); } if (i<s->split_num-2 && s->bsort[i]) { - s->fsort[i]->wait_for(s->bsort[i]); + s->fsort[i]->wait_for(s->bsort[i]); } s->fsort[i]->set_cpu(SPE_ANY); s->fsort[i]->set_param(0,(memaddr)block_num); @@ -134,6 +137,7 @@ } } restart->spawn(); + return 0; }