changeset 1497:ff842b2d5c23 draft

add twice_result
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Aug 2012 17:52:16 +0900
parents 8b0911f58b70
children 8034e0212281
files TaskManager/Gpu/GpuScheduler.cc TaskManager/test/GpuRunTest/GpuRunTest.cc
diffstat 2 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc	Tue Aug 21 17:34:21 2012 +0900
+++ b/TaskManager/Gpu/GpuScheduler.cc	Tue Aug 21 17:52:16 2012 +0900
@@ -68,7 +68,7 @@
                 int err = CL_SUCCESS;
                 int param = 0;
                 
-                cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, 
+                cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_ONLY, 
                                                sizeof(memaddr)*nextTask->param_count, NULL, NULL);
                 err |= clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, 
                                             sizeof(memaddr)*nextTask->param_count, 
@@ -77,24 +77,28 @@
 
                 
                 for(int i=0;i<nextTask->inData_count;i++) {
-                    cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, nextTask->inData(i)->size, NULL, NULL);
+                    cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_ONRY, nextTask->inData(i)->size, NULL, NULL);
                     err |= clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, 
                                                 nextTask->inData(i)->size, nextTask->inData(i)->addr, 0, NULL, NULL);
                     err |= clSetKernelArg(kernel,  param, sizeof(memaddr), memobj);
                     param++;
                 }
                 
+                cl_mem *memobj = new cl_mem[nextTask->outputData_count];
             
                 for(int i=0;i<nextTask->outData_count;i++) {
-                    cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_WRITE, nextTask->outData(i)->size, NULL, NULL);
-                    err |= clEnqueueReadBuffer(command_queue, memobj, CL_TRUE, 0, 
-                                               nextTask->outData(i)->size, nextTask->outData(i)->addr, 0, NULL, NULL);
-                    err |= clSetKernelArg(kernel,  param, sizeof(memaddr), memobj);
+                    memobj[i] = clCreateBuffer(context, CL_MEM_WRITE_ONLY, nextTask->outData(i)->size, NULL, NULL);
+                    err |= clSetKernelArg(kernel,  param, sizeof(memaddr[i]), memobj[i]);
                     param++;
                 }
                 // カーネル引数の設定
 
                 clEnqueueTask(command_queue, kernel, 0, NULL, NULL);
+                
+                for(int i=0;i<nextTask->outData_count;i++) {
+                    err |= clEnqueueReadBuffer(command_queue, memobj[i], CL_TRUE, 0, 
+                                               nextTask->outData(i)->size, nextTask->outData(i)->addr, 0, NULL, NULL);
+                }
             }
         
             clFlush(command_queue); // waiting for queued task
--- a/TaskManager/test/GpuRunTest/GpuRunTest.cc	Tue Aug 21 17:34:21 2012 +0900
+++ b/TaskManager/test/GpuRunTest/GpuRunTest.cc	Tue Aug 21 17:52:16 2012 +0900
@@ -10,6 +10,7 @@
 char usr_help_str[] = "GpuRun [length]\n";
 extern void task_init(void);
 
+
 void
 print_data(int *data, int size, const char *title)
 {
@@ -20,6 +21,16 @@
     printf("\n");
 }
 
+/**
+ * タスク終了後の data1, data2 の確認
+ */
+void
+twice_result(SchedTask *s, void *a, void *b)
+{
+    int* data = (int*)a;
+    long length = (long)b;
+    print_data(data, length, "after");
+}
 
 
 void
@@ -56,6 +67,12 @@
     twice->set_inData(0, indata, sizeof (int)*length);
     twice->set_outData(0, outdata, sizeof (int)*length);
     twice->set_cpu(GPU_0);
+
+    /*
+     * set_post() で ppe task を渡せるようにしたい
+     */
+    twice->set_post(twice_result, (void*)outdata, (void*)length);
+
     twice->spawn();
     
 }