Mercurial > hg > Game > Cerium
changeset 1483:f402f6444237 draft
create gpuTaskinit
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 06 Aug 2012 19:55:47 +0900 |
parents | 85a848d7f181 |
children | fc1d9f87853b |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h TaskManager/kernel/ppe/CpuThreads.cc TaskManager/kernel/schedule/Scheduler.h TaskManager/test/GpuRunTest/GpuFunc.h TaskManager/test/GpuRunTest/GpuRunTest.cc |
diffstat | 6 files changed, 32 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Wed Aug 01 21:37:29 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Mon Aug 06 19:55:47 2012 +0900 @@ -58,9 +58,7 @@ while (params_addr) { tasklist = (TaskListPtr)connector->dma_load(this, params_addr, - sizeof(TaskList), DMA_READ_TASKLIST); - - + sizeof(TaskList), DMA_READ_TASKLIST); for (TaskPtr nextTask = tasklist->tasks; nextTask < tasklist->last(); nextTask = nextTask->next()) { cl_kernel& kernel = *task_list[nextTask->command].kernel; @@ -103,7 +101,7 @@ } void -GpuScheduler::regist_task(int cmd, const char* filename, const char* functionname) +GpuScheduler::gpu_register_task(int cmd, const char* filename, const char* functionname) { int fp; char *source_str; @@ -129,9 +127,7 @@ source_size = read(fp, source_str, size); close(fp); - cl_program program = NULL; - - program = clCreateProgramWithSource(context, 1, (const char **)&source_str, + cl_program program = clCreateProgramWithSource(context, 1, (const char **)&source_str, (const size_t *)&source_size, &ret); clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
--- a/TaskManager/Gpu/GpuScheduler.h Wed Aug 01 21:37:29 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.h Mon Aug 06 19:55:47 2012 +0900 @@ -19,7 +19,7 @@ void init_impl(int useRefDma); void init_gpu(); void run(); - void regist_task(int cmd,const char* filename,const char* functionname); + void gpu_register_task(int cmd,const char* filename,const char* functionname); void mail_write_from_host(memaddr data) { fifoDmaManager->mail_write_from_host(data); @@ -47,4 +47,5 @@ #endif - +#define GpuSchedRegister(str, filename, functionname) \ + gpu_register_task(str, filename, functionname);
--- a/TaskManager/kernel/ppe/CpuThreads.cc Wed Aug 01 21:37:29 2012 +0900 +++ b/TaskManager/kernel/ppe/CpuThreads.cc Mon Aug 06 19:55:47 2012 +0900 @@ -111,26 +111,25 @@ int CpuThreads::get_mail(int cpuid, int count, memaddr *ret) { - if (is_gpu(cpuid)) { - return gpu->get_mail(cpuid, count, ret); - } else { - *ret = args[cpuid-id_offset].scheduler->mail_read_from_host(); - return 1; - } +#ifdef __CERIUM_GPU__ + if (is_gpu(cpuid)) return gpu->get_mail(cpuid, count, ret); +#endif + *ret = args[cpuid-id_offset].scheduler->mail_read_from_host(); + return 1; } int CpuThreads::has_mail(int cpuid, int count, memaddr *ret) { - if (is_gpu(cpuid)) { - return gpu->has_mail(cpuid, count, ret); +#ifdef __CERIUM_GPU__ + if (is_gpu(cpuid)) return gpu->has_mail(cpuid, count, ret); +#endif + if (args[cpuid-id_offset].scheduler->has_mail_from_host() != 0) { + return get_mail(cpuid,count,ret); } else { - if (args[cpuid-id_offset].scheduler->has_mail_from_host() != 0) { - return get_mail(cpuid,count,ret); - } else { - return 0; //mailがないとき0を返す - } + return 0; //mailがないとき0を返す } + } /** * Inbound Mailbox @@ -149,11 +148,13 @@ void CpuThreads::send_mail(int cpuid, int num, memaddr *data) { - if (is_gpu(cpuid)) { +#ifdef __CERIUM_GPU__ + if (is_gpu(cpuid)){ gpu->send_mail(cpuid, num, data); - } else { - args[cpuid-id_offset].scheduler->mail_write_from_host(*data); + return; } +#endif + args[cpuid-id_offset].scheduler->mail_write_from_host(*data); } void
--- a/TaskManager/kernel/schedule/Scheduler.h Wed Aug 01 21:37:29 2012 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Mon Aug 06 19:55:47 2012 +0900 @@ -11,11 +11,13 @@ #include "MemList.h" #include "MemHash.h" +#ifdef __CERIUM_GPU__ #ifdef __APPLE__ #include <OpenCL/opencl.h> #else #include <CL/cl.h> #endif +#endif #define MAX_USER_TASK 100 #define MAX_SYSTEM_TASK 2 @@ -45,7 +47,9 @@ const char *name; void (*load)(Scheduler *,int); void (*wait)(Scheduler *,int); +#ifdef __CERIUM_GPU__ cl_kernel *kernel; +#endif } __attribute__ ((aligned (DEFAULT_ALIGNMENT))) //sizeはどれくらい? TaskObject, *TaskObjectPtr;
--- a/TaskManager/test/GpuRunTest/GpuFunc.h Wed Aug 01 21:37:29 2012 +0900 +++ b/TaskManager/test/GpuRunTest/GpuFunc.h Mon Aug 06 19:55:47 2012 +0900 @@ -1,5 +1,5 @@ enum { #include "SysTasks.h" - SchedRun, - RUN_FINISH, + Twice, + Func1, };
--- a/TaskManager/test/GpuRunTest/GpuRunTest.cc Wed Aug 01 21:37:29 2012 +0900 +++ b/TaskManager/test/GpuRunTest/GpuRunTest.cc Mon Aug 06 19:55:47 2012 +0900 @@ -2,7 +2,6 @@ #include <fcntl.h> #include <sys/stat.h> #include "TaskManager.h" -//#include "GpuScheduler.h" #include "GpuThreads.h" #include "GpuFunc.h" @@ -48,6 +47,7 @@ for (count=0; count < length ;count++) { indata[count] = count; } + print_data(indata, count, "before"); HTaskPtr schedtask = manager->create_task(SchedRun); @@ -59,13 +59,6 @@ schedtask->spawn(); } - -void -task_init(GpuScheduler *gpu) -{ - int cmd = SchedRun; - gpu->regist_task(cmd, "twice.cl", "twice"); -} int TMmain(TaskManager *manager, int argc, char* argv[]) @@ -77,8 +70,8 @@ length = atoi(argv[1]); } } - GpuScheduler *gpu = new GpuScheduler(); - task_init(gpu); + + task_init(); test(manager, length, gpu);