changeset 1613:0d368b575bb5 draft

fix not working yet
author Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
date Fri, 10 May 2013 00:41:58 +0900
parents 42f260639cc0
children 93569219173e
files TaskManager/Gpu/GpuScheduler.cc TaskManager/kernel/ppe/CpuThreads.cc TaskManager/kernel/ppe/TaskList.h example/multiply/main.cc
diffstat 4 files changed, 25 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Gpu/GpuScheduler.cc	Thu May 09 20:51:22 2013 +0900
+++ b/TaskManager/Gpu/GpuScheduler.cc	Fri May 10 00:41:58 2013 +0900
@@ -72,8 +72,8 @@
 {
     int cur = 0;
     memaddr reply[2];
-    cl_kernel *kernel = new cl_kernel[2];
-    cl_event *event = new cl_event[2];
+    cl_kernel kernel[2];
+    cl_event event[2];
     event[0]=NULL;event[1]=NULL;
 
     cl_mem *memin[2];
@@ -88,6 +88,10 @@
 
         if ((memaddr)params_addr == (memaddr)MY_SPE_COMMAND_EXIT) {
             clFinish(command_queue);
+            clReleaseKernel(kernel[0]);
+            // clReleaseKernel(kernel[1]);
+            clReleaseEvent(event[0]);
+            clReleaseEvent(event[1]);
             return ;
         }
 
@@ -206,12 +210,9 @@
                     param++;
                 }
                 
-                if (flag.nd_range){
-                    int dimension = tasklist->dim;
-                    size_t gws[3];
-                    gws[0]=tasklist->x; gws[1]=tasklist->y;gws[2]=tasklist->z;
-                    ret = clEnqueueNDRangeKernel(command_queue, kernel[cur], dimension,
-                                                 NULL, gws, 0, 0, NULL, NULL);
+                if (tasklist->dim > 0) {
+                    ret = clEnqueueNDRangeKernel(command_queue, kernel[cur], tasklist->dim,
+                                                 NULL, &tasklist->x, 0, 0, NULL, NULL);
                 } else {
                     ret = clEnqueueTask(command_queue, kernel[cur], 0, NULL, NULL);
                 }
@@ -240,12 +241,16 @@
                 //clFlush(command_queue); // waiting for queued task
                 if (event[1-cur] != NULL) {
                     ret=clWaitForEvents(1,&event[1-cur]);
+                    if (ret<0) {
+                        const char *msg=convert_error_status(ret);
+                        error(msg);
+                    }
+                    if(reply[1-cur]) {
+                        connector->mail_write(reply[1-cur]);
+                    }
                     event[1-cur]=NULL;
                 }
-                if (ret<0) {
-                    const char *msg=convert_error_status(ret);
-                    error(msg);
-                }
+
                 // clFlush(command_queue);
                 // pipeline    : 1-cur
                 // no pipeline : cur
@@ -253,9 +258,6 @@
                  *  clReleaseMemObject(memin[1-cur]);
                  *  clReleaseMemObject(memout[1-cur]);
                  */
-                if(reply[1-cur]) {
-                    connector->mail_write(reply[1-cur]);
-                }
                 
                 params_addr = (memaddr)tasklist->next;
                 cur = 1 - cur;
@@ -264,10 +266,12 @@
         if (event[1-cur] != NULL) {
             ret=clWaitForEvents(1,&event[1-cur]);
             event[1-cur]=NULL;
+            if(reply[1-cur]) {
+                connector->mail_write(reply[1-cur]);
+            }
         }
         //clFlush(command_queue); // waiting for queued task
         //clFinish(command_queue); // waiting for queued task
-        connector->mail_write(reply[1-cur]);
         connector->mail_write((memaddr)MY_SPE_STATUS_READY);
     }
     // TaskArrayの処理
--- a/TaskManager/kernel/ppe/CpuThreads.cc	Thu May 09 20:51:22 2013 +0900
+++ b/TaskManager/kernel/ppe/CpuThreads.cc	Fri May 10 00:41:58 2013 +0900
@@ -191,7 +191,7 @@
 int
 CpuThreads::is_gpu(int cpuid)
 {
-    if ( cpuid < id_offset ) {
+    if ( (cpuid-id_offset) < id_offset) {
         return 1;
     } else {
         return 0;
--- a/TaskManager/kernel/ppe/TaskList.h	Thu May 09 20:51:22 2013 +0900
+++ b/TaskManager/kernel/ppe/TaskList.h	Fri May 10 00:41:58 2013 +0900
@@ -17,7 +17,8 @@
     TaskList *prev; // 4 byte
     TaskList *waiter; // 4 byte
     HTask *self; // 4 byte
-    int dim,x,y,z; // 16 byte
+    int dim;
+    size_t x,y,z;
     Task tasks[TASK_MAX_SIZE]; // 32*TASK_MAX_SIZE
     
 
--- a/example/multiply/main.cc	Thu May 09 20:51:22 2013 +0900
+++ b/example/multiply/main.cc	Fri May 10 00:41:58 2013 +0900
@@ -39,11 +39,11 @@
         
 static void
 print_result() {
-    /*    printf("---\n");
+    printf("---\n");
     for (int i =0;i<length;i++) {
         printf("%f * %f = %f \n",A[i],B[i],C[i]);
     }
-    printf("---\n");*/
+    printf("---\n");
 }