Mercurial > hg > Game > Cerium
changeset 1447:e8ff87511f46 draft
debug GpuThreads
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 23 Apr 2012 22:53:59 +0900 |
parents | ed1e38e82985 |
children | 3ee29c1733d1 |
files | TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuScheduler.h TaskManager/Gpu/GpuTaskManagerImpl.h TaskManager/Gpu/GpuThreads.cc TaskManager/Gpu/GpuThreads.h TaskManager/kernel/schedule/Scheduler.h |
diffstat | 6 files changed, 32 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc Mon Apr 23 22:01:51 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.cc Mon Apr 23 22:53:59 2012 +0900 @@ -8,10 +8,11 @@ void GpuScheduler::init_impl(int useRefDma) { - connector = new ReferencedDmaManager(); + fifoDmaManager = new ReferencedDmaManager(); + connector = fifoDmaManager; } -int +void GpuScheduler::run() { memaddr params_addr = connector->task_list_mail_read(); @@ -24,7 +25,6 @@ if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) { clFinish(command_queue); - return 0; } TaskListPtr tasklist = (TaskListPtr)connector->dma_load(this, params_addr, @@ -48,7 +48,6 @@ } } // TaskArrayの処理 - return 0; }
--- a/TaskManager/Gpu/GpuScheduler.h Mon Apr 23 22:01:51 2012 +0900 +++ b/TaskManager/Gpu/GpuScheduler.h Mon Apr 23 22:53:59 2012 +0900 @@ -2,6 +2,7 @@ #define INCLUDED_GPU_SCHEDULER #include "Scheduler.h" +#include "FifoDmaManager.h" #ifdef __APPLE__ #include <OpenCL/opencl.h> @@ -12,10 +13,22 @@ class GpuScheduler : public Scheduler { public: void init_impl(int useRefDma); - int run(); + void run(); + + void mail_write_from_host(memaddr data) { + fifoDmaManager->mail_write_from_host(data); + } + + memaddr mail_read_from_host() { + return fifoDmaManager->mail_read_from_host(); + } + + int has_mail_from_host() { + return fifoDmaManager->has_mail_from_host(); + } private: - + FifoDmaManager *fifoDmaManager; }; #endif
--- a/TaskManager/Gpu/GpuTaskManagerImpl.h Mon Apr 23 22:01:51 2012 +0900 +++ b/TaskManager/Gpu/GpuTaskManagerImpl.h Mon Apr 23 22:53:59 2012 +0900 @@ -8,6 +8,7 @@ class GpuTaskManagerImpl : public TaskManagerImpl { public: + GpuTaskManagerImpl(){}; GpuTaskManagerImpl(int num, Threads *gpus) : TaskManagerImpl(num) {gpuThreads = gpus;} ~GpuTaskManagerImpl();
--- a/TaskManager/Gpu/GpuThreads.cc Mon Apr 23 22:01:51 2012 +0900 +++ b/TaskManager/Gpu/GpuThreads.cc Mon Apr 23 22:53:59 2012 +0900 @@ -1,6 +1,7 @@ #include "GpuThreads.h" #include "GpuScheduler.h" #include "TaskManagerImpl.h" +#include "GpuTaskManagerImpl.h" GpuThreads::GpuThreads() { @@ -20,8 +21,8 @@ void GpuThreads::init() { - clGetPlatformIDs(1, &platfrom_id, &ret_num_platforms); - clGetDeviceIds(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices); + clGetPlatformIDs(1, &platform_id, &ret_num_platforms); + clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices); // unavailable GPU if( ret_num_devices == 0) { exit(EXIT_FAILURE); @@ -29,10 +30,10 @@ context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); command_queue = clCreateCommandQueue(context, device_id, 0, &ret); - args.scheduler = new GpuScheduler(); - args.useRefDma = use_refdma; + args->scheduler = new GpuScheduler(); + args->useRefDma = use_refdma; - pthread_create(&threads, NULL, &cpu_thread_run, (void*)&args); + pthread_create(threads, NULL, &gpu_thread_run, args); } @@ -50,20 +51,20 @@ g_scheduler->run(); g_scheduler->finish(); - return NULL + return NULL; } int GpuThreads::get_mail(int speid, int count, memaddr *ret) { - *ret = args.scheduler->mail_read_from_host(); + *ret = args->scheduler->mail_read_from_host(); return 1; } int GpuThreads::has_mail(int speid, int count, memaddr *ret) { - if (args.scheduler->has_mail_from_host() != 0) { + if (args->scheduler->has_mail_from_host() != 0) { return get_mail(0, 0, ret); } else { return 0; @@ -73,7 +74,7 @@ void CpuThreads::send_mail(int speid, int num, memaddr *data) { - args.scheduler->mail_write_from_host(*data); + args->scheduler->mail_write_from_host(*data); } void
--- a/TaskManager/Gpu/GpuThreads.h Mon Apr 23 22:01:51 2012 +0900 +++ b/TaskManager/Gpu/GpuThreads.h Mon Apr 23 22:53:59 2012 +0900 @@ -26,7 +26,7 @@ ~GpuThreads(); void init(); - void *gpu_thread_run(void *args); + static void *gpu_thread_run(void *args); int get_mail(int speid, int count, memaddr *ret); int has_mail(int speid, int count, memaddr *ret); @@ -40,6 +40,7 @@ cl_uint ret_num_devices; cl_context context; cl_command_queue command_queue; + cl_int ret; private: GpuThreads();
--- a/TaskManager/kernel/schedule/Scheduler.h Mon Apr 23 22:01:51 2012 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.h Mon Apr 23 22:53:59 2012 +0900 @@ -86,6 +86,7 @@ /* functions */ void init(TaskManagerImpl *m, int useRefDma=0); + virtual void run(); void run(SchedTaskBase* task1); virtual void init_impl(int useRefDma) {};