changeset 1433:11dcd8165424 draft

add GpuTaskManagerImpl
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Thu, 05 Apr 2012 12:15:08 +0900
parents b77f32eb137c
children 05d480ab70ba
files TaskManager/Gpu/GpuTaskManagerImpl.cc TaskManager/Gpu/GpuTaskManagerImpl.h TaskManager/Gpu/GpuThreads.cc TaskManager/Gpu/GpuThreads.h
diffstat 4 files changed, 135 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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<TaskList>
+    TaskListInfo = new QueueInfo<TaskList>
+
+    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;
+}
--- /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 <OpenCL/opencl.h>
+#else
+#include <CL/cl.h>
+#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<TaskList> *gpuTaskList;
+    QueueInfo<TaskList> *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
--- /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する。
+}
--- /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 <OpenCL/opencl.h>
+#else
+#include <CL/cl.h>
+#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