Mercurial > hg > Game > Cerium
changeset 1470:16731fa768de draft
Gpu task_init?
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jul 2012 18:56:16 +0900 |
parents | 9088e6f2c2e0 |
children | e8db2e2d426c |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuTaskManagerImpl.cc TaskManager/Gpu/GpuTaskManagerImpl.h TaskManager/test/GpuRunTest/GpuFunc.h TaskManager/test/GpuRunTest/GpuRunTest.cc |
diffstat | 5 files changed, 45 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Sun Jul 15 17:50:14 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Sun Jul 15 18:56:16 2012 +0900 @@ -34,32 +34,38 @@ TaskListPtr tasklist = (TaskListPtr)connector->dma_load(this, params_addr, sizeof(TaskList), DMA_READ_TASKLIST); - for (int cur_index = 0; cur_index < tasklist->length; cur_index++) { - SimpleTaskPtr nextTask = &tasklist->tasks[cur_index]; - cl_kernel& kernel = *task_list[nextTask->command].kernel; - - if ( nextTask->r_size != 0 ) { - cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, nextTask->r_size, NULL, &ret); - clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, nextTask->r_size, nextTask->rbuf, 0, NULL, NULL); - //clSetKernleArg(kernel, cur_index,); - } - // カーネル引数の設定 - - clEnqueueTask(command_queue, kernel, 0, NULL, NULL); - - if ( nextTask->w_size != 0 ) { - cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, nextTask->w_size, NULL, &ret); - clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, nextTask->w_size, nextTask->wbuf, 0, NULL, NULL); - } + for (TaskPtr nextTask = tasklist->tasks; nextTask < tasklist->last(); nextTask = nextTask->next()) { + cl_kernel& kernel = *task_list[nextTask->command].kernel; + int err = CL_SUCCESS; + for(int i=0;i<nextTask->param_count;i++) { + err |= clSetKernelArg(kernel, i, sizeof(memaddr), (cl_mem*)nextTask->param(i)); + } + + for(int i=0;i<nextTask->inData_count;i++) { + cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, nextTask->inData(i)->size, NULL, NULL); + err |= clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, + nextTask->inData(i)->size, nextTask->inData(i)->addr, 0, NULL, NULL); + //clSetKernleArg(kernel, cur_index,); + } + // カーネル引数の設定 + + clEnqueueTask(command_queue, kernel, 0, NULL, NULL); + + for(int i=0;i<nextTask->outData_count;i++) { + cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, nextTask->outData(i)->size, NULL, NULL); + err |= clEnqueueReadBuffer(command_queue, memobj, CL_TRUE, 0, + nextTask->outData(i)->size, nextTask->outData(i)->addr, 0, NULL, NULL); + } } clFlush(command_queue); // waiting for queued task -#ifdef TASK_LIST_MAILOD - if (!(cur_index < list->length) ) - connector->mail_write(waiter); +#ifdef TASK_LIST_MAIL + connector->mail_write((memaddr)(tasklist->waiter)); #else - connector->mail_write(waiter); + for (TaskPtr nextTask = &tasklist->tasks; nextTask < tasklist->last(); nextTask = nextTask->next()) { + connector->mail_write(nextTask->self); + } #endif }
--- a/TaskManager/Gpu/GpuTaskManagerImpl.cc Sun Jul 15 17:50:14 2012 +0900 +++ b/TaskManager/Gpu/GpuTaskManagerImpl.cc Sun Jul 15 18:56:16 2012 +0900 @@ -8,6 +8,7 @@ #include "MainScheduler.h" #include "types.h" #include "SysFunc.h" +#include <strings.h> static void send_alloc_reply(GpuTaskManagerImpl *tm, int id, GpuThreads *gpuThreads); @@ -32,7 +33,7 @@ // gpuThreads->init(); schedTaskManager = new SchedTask(); - schedTaskManager->init(0, 0, 0, ppeManager->get_scheduler(), 0); + schedTaskManager->init(0, 0, ppeManager->get_scheduler(), 0); ppeManager->schedTaskManager = schedTaskManager; } @@ -66,6 +67,14 @@ } } +TaskListPtr GpuTaskManagerImpl::createTaskList() +{ + TaskListPtr tl = taskListInfo->create(); + bzero(tl->tasks,sizeof(Task)*TASK_MAX_SIZE); + return tl; +} + + void GpuTaskManagerImpl::sendTaskList() { mail_check(); if (!gpuTaskList->empty()) {
--- a/TaskManager/Gpu/GpuTaskManagerImpl.h Sun Jul 15 17:50:14 2012 +0900 +++ b/TaskManager/Gpu/GpuTaskManagerImpl.h Sun Jul 15 18:56:16 2012 +0900 @@ -24,6 +24,7 @@ void show_profile(){} void polling(){} void print_arch(){} + TaskList* createTaskList(); public: QueueInfo<TaskList> *gpuTaskList;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/test/GpuRunTest/GpuFunc.h Sun Jul 15 18:56:16 2012 +0900 @@ -0,0 +1,5 @@ +enum { +#include "SysTasks.h" + SchedRun, + RUN_FINISH, +};
--- a/TaskManager/test/GpuRunTest/GpuRunTest.cc Sun Jul 15 17:50:14 2012 +0900 +++ b/TaskManager/test/GpuRunTest/GpuRunTest.cc Sun Jul 15 18:56:16 2012 +0900 @@ -7,6 +7,7 @@ #include "GpuFunc.h" #define DEFAULT 5 +char usr_help_str[] = "GpuRun [length]\n"; extern void gpu_register_task(int, const char*, const char*); extern void task_init(void); @@ -61,47 +62,8 @@ schedtask->set_inData(2, &count, sizeof (int)); schedtask->set_cpu(SPE_ANY); schedtask->spawn(); - - - //以下をGpuScheduler のrunへ - /* - cl_int ret = gputhreads->ret; - cl_context context = gputhreads->context; - cl_mem memobj_in = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int)*count, NULL, &ret); - cl_mem memobj_out = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int)*count, NULL, &ret); - cl_mem data_count = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(int)*count, NULL, &ret); - cl_command_queue command_queue = gputhreads->command_queue; - ret = clEnqueueWriteBuffer(command_queue, memobj_in, CL_TRUE, 0, - sizeof(int)*count, indata, 0, NULL, NULL); - ret = clEnqueueWriteBuffer(command_queue, data_count, CL_TRUE, 0, - sizeof(count), &count, 0, NULL, NULL); - - cl_kernel kernel = *(task_list[cmd].kernel); - - clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&memobj_in); - - - clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&memobj_out); - clSetKernelArg(kernel, 2, sizeof(cl_mem), (void *)&data_count); - - cl_event ev = NULL; - clEnqueueTask(command_queue, kernel, 0, NULL, &ev); - - clEnqueueReadBuffer(command_queue, memobj_out, CL_TRUE, 0, - sizeof(int)*count, outdata, 1, &ev, NULL); - - print_data(outdata, count, "after"); - tester(indata,outdata,count); - - delete [] indata; - delete [] outdata; - clReleaseCommandQueue(command_queue); - clReleaseContext(context); - clReleaseKernel(kernel); - */ - - } +} int TMmain(TaskManager *manager, int argc, char* argv[])