changeset 1498:8034e0212281 draft

run twice, but not return. dead lock?
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Aug 2012 19:09:32 +0900
parents ff842b2d5c23
children 622a7d053537
files TaskManager/Gpu/GpuScheduler.cc TaskManager/kernel/ppe/Task.h
diffstat 2 files changed, 24 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc	Tue Aug 21 17:52:16 2012 +0900
+++ b/TaskManager/Gpu/GpuScheduler.cc	Tue Aug 21 19:09:32 2012 +0900
@@ -66,38 +66,43 @@
 
                 cl_kernel& kernel = *task_list[nextTask->command].kernel;
                 int err = CL_SUCCESS;
+
                 int param = 0;
-                
-                cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_ONLY, 
+                cl_mem memin = 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, 
+                err |= clEnqueueWriteBuffer(command_queue, memin, CL_TRUE, 0, sizeof(memaddr)*nextTask->param_count, 
                                             nextTask->param(0), 0, NULL, NULL);
-                err |= clSetKernelArg(kernel, param, sizeof(memaddr), memobj);
-
+fprintf(stderr,"err1 = %d\n",err);
+                err |= clSetKernelArg(kernel, param, sizeof(memaddr),(void *)&memin);
+fprintf(stderr,"err2 = %d\n",err);
                 
+                param++;
                 for(int i=0;i<nextTask->inData_count;i++) {
-                    cl_mem memobj = clCreateBuffer(context, CL_MEM_READ_ONRY, nextTask->inData(i)->size, NULL, NULL);
-                    err |= clEnqueueWriteBuffer(command_queue, memobj, CL_TRUE, 0, 
+                    cl_mem memin = clCreateBuffer(context, CL_MEM_READ_ONLY, nextTask->inData(i)->size, NULL, NULL);
+                    err |= clEnqueueWriteBuffer(command_queue, memin, CL_TRUE, 0, 
                                                 nextTask->inData(i)->size, nextTask->inData(i)->addr, 0, NULL, NULL);
-                    err |= clSetKernelArg(kernel,  param, sizeof(memaddr), memobj);
+fprintf(stderr,"err3 = %d\n",err);
+                    err |= clSetKernelArg(kernel,  param, sizeof(memaddr), (void *)&memin);
+fprintf(stderr,"err4 = %d\n",err);
+
                     param++;
                 }
                 
-                cl_mem *memobj = new cl_mem[nextTask->outputData_count];
-            
+                cl_mem *memout = new cl_mem[nextTask->outData_count];
+                
                 for(int i=0;i<nextTask->outData_count;i++) {
-                    memobj[i] = clCreateBuffer(context, CL_MEM_WRITE_ONLY, nextTask->outData(i)->size, NULL, NULL);
-                    err |= clSetKernelArg(kernel,  param, sizeof(memaddr[i]), memobj[i]);
+                    memout[i] = clCreateBuffer(context, CL_MEM_WRITE_ONLY, nextTask->outData(i)->size, NULL, NULL);
+                    err |= clSetKernelArg(kernel,  param, sizeof(memaddr), (void *)&memout[i]);
                     param++;
                 }
-                // カーネル引数の設定
-
-                clEnqueueTask(command_queue, kernel, 0, NULL, NULL);
+                // set kernel arg
+                
+                cl_event ev = NULL;
+                clEnqueueTask(command_queue, kernel, 0, NULL, &ev);
                 
                 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);
+                    err |= clEnqueueReadBuffer(command_queue, memout[i], CL_TRUE, 0, 
+                                               nextTask->outData(i)->size, nextTask->outData(i)->addr, 1, &ev, NULL);
                 }
             }
         
--- a/TaskManager/kernel/ppe/Task.h	Tue Aug 21 17:52:16 2012 +0900
+++ b/TaskManager/kernel/ppe/Task.h	Tue Aug 21 19:09:32 2012 +0900
@@ -25,7 +25,7 @@
     void print(Scheduler *s);
 
     memaddr *param(int index) {
-	memaddr p =  (memaddr)data + sizeof(memaddr)*index;
+        memaddr p =  (memaddr)data + sizeof(memaddr)*index;
 	return (memaddr *)p;
     }