changeset 1442:db8a954fcfb3 draft

merge
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Mon, 23 Apr 2012 19:07:41 +0900
parents 50d2c1e85535
children dff9b3f388e2
files TaskManager/Gpu/GpuScheduler.cc TaskManager/Gpu/GpuTaskManagerImpl.cc TaskManager/Gpu/GpuThreads.cc
diffstat 3 files changed, 28 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc	Mon Apr 23 18:53:35 2012 +0900
+++ b/TaskManager/Gpu/GpuScheduler.cc	Mon Apr 23 19:07:41 2012 +0900
@@ -1,5 +1,5 @@
 #include "GpuScheduler.h"
-#include "GpuDmaManager.h"
+#include "ReferencedDmaManager.h"
 #include "GpuThreads.h"
 #include "stdio.h"
 #include <fcntl.h>
@@ -7,7 +7,7 @@
 void
 GpuScheduler::init_impl(int useRefDma)
 {
-    connector = new GpuDmamanager;
+    connector = new ReferencedDmaManager();
 }
 
 int
@@ -15,23 +15,39 @@
 {
     memaddr params_addr = connector->task_list_mail_read();
 
+    // Get OpenCL infomation
+    GpuThreads gputhreads = GpuThreads::getInstance();
+    cl_context& context = &gputhreads.context;
+    cl_command_queue& command_queue = &gputhreads.command_queue;
+    cl_int ret;
+
     if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) {
-        // 終了確認
+        clFinish(command_queue);
         return 0;
     }
 
     TaskListPtr *tasklist = (TaskListPtr)connector->dma_load(tasklist, params_addr, 
                                          sizeof(TaskList), DMA_READ_TASKLIST);
+
     GpuThreads gputhreads = GpuThreads::getInstance();
     cl_command_queue& command_queue = gputhreads.cl_command_queue;
 
     for (int cur_index = 0; cur_index < tasklist->length; cur_index++) {
         TaskPtr task = tasklist.tasks[cur_index];
         cl_kernel& kernel = task_list[task->command].kernel;
-        // メモリオブジェクトの生成? GpuThreadsでやるのがよい?
+
+        if ( task.r_size != 0 ) {
+            cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, r_size, NULL, &ret);
+            clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, r_size, rbuf, 0, NULL, NULL);
+        }
         // カーネル引数の設定
+
         clEnqueueTask(command_queue, kernel, 0, NULL, NULL);
-        // メモリオブジェクトからの読み込み
+
+        if ( task.w_size != 0 ) {
+            cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, w_size, NULL, &ret);
+            clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, w_size, wbuf, 0, NULL, NULL);
+        }
     }
     // TaskArrayの処理
 }
--- a/TaskManager/Gpu/GpuTaskManagerImpl.cc	Mon Apr 23 18:53:35 2012 +0900
+++ b/TaskManager/Gpu/GpuTaskManagerImpl.cc	Mon Apr 23 19:07:41 2012 +0900
@@ -10,7 +10,7 @@
 void GpuTaskManagerImpl::init() {
 
     gpuTaskList = new QueueInfo<TaskList>
-    TaskListInfo = new QueueInfo<TaskList>
+    taskListInfo = new QueueInfo<TaskList>
 
     ppeManager = new FifoTaskManagerImpl(machineNum);
     MainScheduler *mscheduler = new MainScheduler;
@@ -82,8 +82,10 @@
 
 void GpuTaskManagerImpl::mail_check() {
     memaddr data;
-    while (speThreads->has_mail(&data)) {
+    while (gpuThreads->has_mail(&data)) {
         //どのメールが必要かよく考える
+
+        //check_task_finish
     }
 }
 
--- a/TaskManager/Gpu/GpuThreads.cc	Mon Apr 23 18:53:35 2012 +0900
+++ b/TaskManager/Gpu/GpuThreads.cc	Mon Apr 23 19:07:41 2012 +0900
@@ -12,6 +12,9 @@
 {
     delete threads;
     delete args;
+
+    clReleaseCommandQueue(command_queue);
+    clReleaseContext(context);
 }
 
 void