Mercurial > hg > Game > Cerium
changeset 1486:756aa0f08814 draft
gpu task loader
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 06 Aug 2012 20:35:31 +0900 |
parents | cdf5d5d60b71 |
children | 6b451d72daf5 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h |
diffstat | 2 files changed, 22 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Mon Aug 06 20:17:30 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Mon Aug 06 20:35:31 2012 +0900 @@ -61,6 +61,9 @@ sizeof(TaskList), DMA_READ_TASKLIST); for (TaskPtr nextTask = tasklist->tasks; nextTask < tasklist->last(); nextTask = nextTask->next()) { + + load_kernel(nextTask->command); + cl_kernel& kernel = *task_list[nextTask->command].kernel; int err = CL_SUCCESS; int param = 0; @@ -95,14 +98,17 @@ connector->mail_write((memaddr)(tasklist->waiter)); } - // TaskArrayの処理 - } void -gpu_register_task(int cmd, const char* filename, const char* functionname) +GpuScheduler::load_kernel(int cmd) { + if (task_list[cmd].run != 0) return; + + const char *filename = (const char *)task_list[cmd].kernel; + const char *functionname = task_list[cmd].name; + int fp; char *source_str; size_t source_size; @@ -123,7 +129,7 @@ exit(1); } - source_str = (char*)malloc(size); + source_str = (char*)alloca(size); source_size = read(fp, source_str, size); close(fp); @@ -131,15 +137,21 @@ (const size_t *)&source_size, &ret); clBuildProgram(program, 1, &device_id, NULL, NULL, NULL); - cl_kernel *kernel = new cl_kernel; + cl_kernel *kernel = new cl_kernel; *kernel = clCreateKernel(program, functionname, &ret); - - task_list[cmd].run = null_run; + task_list[cmd].kernel = kernel; + task_list[cmd].run = null_run; // kernel is ready + +} + +void +gpu_register_task(int cmd, const char* filename, const char* functionname) +{ + task_list[cmd].run = 0; // not yet ready task_list[cmd].load = null_loader; task_list[cmd].wait = null_loader; task_list[cmd].name = functionname; - task_list[cmd].kernel = kernel; - + task_list[cmd].kernel = (cl_kernel *) filename; } /* end */