# HG changeset patch # User Daichi TOMA # Date 1333595708 -32400 # Node ID 11dcd8165424bfea1d3326e6891badcbe6d4d3e8 # Parent b77f32eb137ce9215b4c9eeace87ab7a8259ba6b add GpuTaskManagerImpl diff -r b77f32eb137c -r 11dcd8165424 TaskManager/Gpu/GpuTaskManagerImpl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Gpu/GpuTaskManagerImpl.cc Thu Apr 05 12:15:08 2012 +0900 @@ -0,0 +1,36 @@ +#include "GpuTaskManagerImpl.h" +#include "MainScheduler.h" +#include "SchedTask.h" + + +GpuTaskManagerImpl::~GpuTaskManagerImpl() { + +} + +void GpuTaskManagerImpl::init(int spuIdle_, int useRefDma) { + + gpuTaskList = new QueueInfo + TaskListInfo = new QueueInfo + + ppeManager = new FifoTaskManagerImpl(machineNum); + MainScheduler *mscheduler = new MainScheduler; + set_scheduler(mscheduler); + ppeManager->init(mscheduler, this, useRefDma); + + ret = clGetPlatformIDs(1, &platfrom_id, &ret_num_platforms); + ret = clGetDeviceIds(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &ret_num_devices); + + // unavailable GPU + if( ret_num_devices == 0) { + exit(EXIT_FAILURE); + } + + gpuThreads->init(device_id); + + htaskImpl = activeTaskQueue; + mscheduler->set_manager(this); + + schedTaskManager = new SchedTask(); + schedTaskManager->init(0, 0, 0, ppeManager->get_scheduler(), 0); + ppeManager->schedTaskManager = schedTaskManager; +} diff -r b77f32eb137c -r 11dcd8165424 TaskManager/Gpu/GpuTaskManagerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Gpu/GpuTaskManagerImpl.h Thu Apr 05 12:15:08 2012 +0900 @@ -0,0 +1,41 @@ +#ifndef INCLUDED_GPU_TASK_MANAGER_IMPL +#define INCLUDED_GPU_TASK_MANAGER_IMPL + +#ifdef __APPLE__ +#include +#else +#include +#endif + + +#include "TaskManagerImpl.h" +#include "FifoTaskManagerImpl.h" +#include "GpuThreads.h" +#include "QueueInfo.h" + +class GpuTaskManagerImpl : public TaskManagerImpl { +public: + GpuTaskManagerImpl(int num, Threads *gpus) : TaskManagerImpl(num) {gpuThreads = gpus;} + ~GpuTaskManagerImpl(); + + void init(int spuIdle,int useRefDma); + void run(); + +public: + QueueInfo *gpuTaskList; + QueueInfo *taskListInfo; + + FifoTaskManagerImpl *ppeManager; + + Threads *gpuThreads; + FifoTaskManagerImpl *ppeManager; + + cl_platform_id platform_id; + cl_device_id device_id; + cl_uint ret_num_platforms; + cl_uint ret_num_devices; + cl_int ret; + +}; + +#endif diff -r b77f32eb137c -r 11dcd8165424 TaskManager/Gpu/GpuThreads.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Gpu/GpuThreads.cc Thu Apr 05 12:15:08 2012 +0900 @@ -0,0 +1,33 @@ +#include "GpuThreads.h" + +GpuThreads::GpuThreads(int num, int useRefDma, int start_id) +{ + context = NULL; + command_queue = NULL; +} + +GpuThreads::~GpuThreads() +{ +} + +void +GpuThreads::init(cl_device_id device_id) +{ + context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); + command_queue = clCreateCommandQueue(context, device_id, 0, &ret); + + // schedulerの作成 + // schedulerは、GpuDmaManagerを持っている。 + // get_write_bufから、allocate経由で + // メモリオブジェクトを作成する。 + + // Thread立てる + +} + +void * +GpuThreads::gpu_thread_run(void *args) +{ + // scheduler->run + // schedulerはメールを受け取り、enqueueする。 +} diff -r b77f32eb137c -r 11dcd8165424 TaskManager/Gpu/GpuThreads.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Gpu/GpuThreads.h Thu Apr 05 12:15:08 2012 +0900 @@ -0,0 +1,25 @@ +#ifndef INCLUDED_GPU_THREADS +#define INCLUDED_GPU_THREADS + +#include "Threads.h" + +#ifdef __APPLE__ +#include +#else +#include +#endif + +class GpuThreads : public Threads { +public: + GpuThreads(int num, int useRefDma, int start_id); + ~GpuThreads(); + + void init(cl_device_id device_id;); + void *gpu_thread_run(void *args); + + cl_context context; + cl_command_queue command_queue; + cl_int ret; +}; + +#endif