Mercurial > hg > Game > Cerium
diff TaskManager/Gpu/GpuThreads.cc @ 1434:05d480ab70ba draft
add GpuScheduler
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 05 Apr 2012 19:05:35 +0900 |
parents | 11dcd8165424 |
children | 9f6ba00ca15c |
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuThreads.cc Thu Apr 05 12:15:08 2012 +0900 +++ b/TaskManager/Gpu/GpuThreads.cc Thu Apr 05 19:05:35 2012 +0900 @@ -1,13 +1,20 @@ #include "GpuThreads.h" +#include "GpuScheduler.h" +#include "TaskManagerImpl.h" -GpuThreads::GpuThreads(int num, int useRefDma, int start_id) +GpuThreads::GpuThreads(int num, int useRefDma, int start_id) : use_refdma(useRefDma) { + threads = new pthread_t; + args = new gpu_arg; + context = NULL; command_queue = NULL; } GpuThreads::~GpuThreads() { + delete threads; + delete args; } void @@ -16,18 +23,29 @@ context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); command_queue = clCreateCommandQueue(context, device_id, 0, &ret); - // schedulerの作成 - // schedulerは、GpuDmaManagerを持っている。 - // get_write_bufから、allocate経由で - // メモリオブジェクトを作成する。 + args.scheduler = new GpuScheduler(); + args.useRefDma = use_refdma; + args.command_queue = &command_queue; - // Thread立てる + pthread_create(&threads, NULL, &cpu_thread_run, (void*)&args); } void * GpuThreads::gpu_thread_run(void *args) { - // scheduler->run - // schedulerはメールを受け取り、enqueueする。 + gpu_arg *argt = (gpu_arg *) args; + Scheduler *g_scheduler = argt->scheduler; + cl_command_queue *command_queue = argt->command_queue; + + TaskManagerImpl *manager = new GpuTaskManagerImpl(); + g_scheduler->init(manager, argt->useRefDma); + g_scheduler->set_command_queue(command_queue); + + manager->set_scheduler(g_scheduler); + + g_scheduler->run(); + g_scheduler->finish(); + + return NULL }