Mercurial > hg > Game > Cerium
changeset 1481:a9da5c6bea91 draft
fix GpuThreads
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 31 Jul 2012 19:12:41 +0900 |
parents | f2512fb94223 |
children | 85a848d7f181 |
files | TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuThreads.cc TaskManager/Makefile.gpu TaskManager/kernel/ppe/CpuThreads.cc TaskManager/test/GpuRunTest/GpuRunTest.cc example/OpenCL/twice.cl |
diffstat | 7 files changed, 33 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc Wed Jul 25 19:41:04 2012 +0900 +++ b/TaskManager/Cell/CellTaskManagerImpl.cc Tue Jul 31 19:12:41 2012 +0900 @@ -365,12 +365,14 @@ return tl; } -#if defined (__CERIUM_CELL__)||(__CERIUM_GPU__) +#if defined (__CERIUM_CELL__)||defined (__CERIUM_GPU__) TaskManagerImpl *create_impl(int num, int useRefDma) { #ifdef __CERIUM_CELL__ Threads *cpus = new SpeThreads(num); -#elif __CERIUM_GPU__ +#elif __CERIUM_GPU__ + Threads *cpus = new GpuThreads(num, useRefDma); +#else Threads *cpus = new CpuThreads(num, useRefDma); #endif return new CellTaskManagerImpl(num, cpus);
--- a/TaskManager/Gpu/GpuScheduler.cc Wed Jul 25 19:41:04 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Tue Jul 31 19:12:41 2012 +0900 @@ -57,15 +57,18 @@ 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)); + int param = 0; + + for(;param<nextTask->param_count;param++) { + err |= clSetKernelArg(kernel, param, sizeof(memaddr), (cl_mem*)nextTask->param(param)); } 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); - + err |= clSetKernelArg(kernel, param, sizeof(memaddr), memobj); + param++; } // カーネル引数の設定 @@ -75,6 +78,8 @@ 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); + err |= clSetKernelArg(kernel, param, sizeof(memaddr), memobj); + param++; } } @@ -134,4 +139,3 @@ } /* end */ -
--- a/TaskManager/Gpu/GpuThreads.cc Wed Jul 25 19:41:04 2012 +0900 +++ b/TaskManager/Gpu/GpuThreads.cc Tue Jul 31 19:12:41 2012 +0900 @@ -23,7 +23,7 @@ args->scheduler = new GpuScheduler(); args->useRefDma = use_refdma; - //pthread_create(threads, NULL, &gpu_thread_run, args); + pthread_create(threads, NULL, &gpu_thread_run, args); }
--- a/TaskManager/Makefile.gpu Wed Jul 25 19:41:04 2012 +0900 +++ b/TaskManager/Makefile.gpu Tue Jul 31 19:12:41 2012 +0900 @@ -8,7 +8,7 @@ .SUFFIXES: .cc .o -EXTRA_CFLAGS = -D__CERIUM_GPU__ +EXTRA_CFLAGS = -D__CERIUM_GPU__ .cc.o: $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@
--- a/TaskManager/kernel/ppe/CpuThreads.cc Wed Jul 25 19:41:04 2012 +0900 +++ b/TaskManager/kernel/ppe/CpuThreads.cc Tue Jul 31 19:12:41 2012 +0900 @@ -101,7 +101,7 @@ CpuThreads::get_mail(int cpuid, int count, memaddr *ret) { if (is_gpu(cpuid)) { - return 0;//gpu->get_mail(cpuid, count, ret); + return gpu->get_mail(cpuid, count, ret); } else { *ret = args[cpuid-id_offset].scheduler->mail_read_from_host(); return 1; @@ -139,7 +139,7 @@ CpuThreads::send_mail(int cpuid, int num, memaddr *data) { if (is_gpu(cpuid)) { - //gpu->send_mail(cpuid, num, data); + gpu->send_mail(cpuid, num, data); } else { args[cpuid-id_offset].scheduler->mail_write_from_host(*data); }
--- a/TaskManager/test/GpuRunTest/GpuRunTest.cc Wed Jul 25 19:41:04 2012 +0900 +++ b/TaskManager/test/GpuRunTest/GpuRunTest.cc Tue Jul 31 19:12:41 2012 +0900 @@ -2,17 +2,15 @@ #include <fcntl.h> #include <sys/stat.h> #include "TaskManager.h" -#include "GpuScheduler.h" +//#include "GpuScheduler.h" #include "GpuThreads.h" #include "GpuFunc.h" #define DEFAULT 5 char usr_help_str[] = "GpuRun [length]\n"; - extern void task_init(void); - void print_data(int *data, int size, const char *title) { @@ -40,16 +38,9 @@ } -void -task_init(GpuScheduler *g_scheduler) -{ - int cmd = SchedRun; - g_scheduler->regist_task(cmd, "twice.cl", "twice"); - -} void -test(TaskManager *manager, long int length, GpuScheduler *g_scheduler) { +test(TaskManager *manager, long int length, GpuScheduler *gpu) { int *indata = new int[length]; int *outdata = new int[length]; @@ -67,8 +58,14 @@ schedtask->set_cpu(GPU_0); schedtask->spawn(); - g_scheduler->run(); - + gpu->run(); +} + +void +task_init(GpuScheduler *gpu) +{ + int cmd = SchedRun; + gpu->regist_task(cmd, "twice.cl", "twice"); } int @@ -81,10 +78,10 @@ length = atoi(argv[1]); } } - GpuScheduler *g_scheduler = new GpuScheduler(); - task_init(g_scheduler); + GpuScheduler *gpu = new GpuScheduler(); + task_init(gpu); - test(manager, length, g_scheduler); + test(manager, length, gpu); return 0; }
--- a/example/OpenCL/twice.cl Wed Jul 25 19:41:04 2012 +0900 +++ b/example/OpenCL/twice.cl Tue Jul 31 19:12:41 2012 +0900 @@ -1,9 +1,9 @@ __kernel void -twice(__global int *input_data, - __global int *output_data, - __global int *data_count) +twice(__global int *data_count, + __global int *input_data, + __global int *output_data) { - int count = *data_count; + long count = (long)data_count; for (int i = 0; i<count; i++) { output_data[i] = input_data[i] * 2; }