[Beignet] [PATCH OCL20 V2 4/4] Runtime: Add support for queue size and fix error handling

Xiuli Pan xiuli.pan at intel.com
Fri Apr 29 03:25:20 UTC 2016


From: Pan Xiuli <xiuli.pan at intel.com>

V2: Remove check for device queue and add device queue flag.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 src/cl_api.c           | 24 +++++++++++++++++-------
 src/cl_command_queue.h |  1 +
 src/cl_gt_device.h     |  2 +-
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index bb9b02b..254c029 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -439,6 +439,7 @@ clCreateCommandQueueWithProperties(cl_context                         context,
   cl_command_queue queue = NULL;
   cl_int err = CL_SUCCESS;
   cl_command_queue_properties prop = 0xFFFFFFFF;
+  cl_uint queue_sz = 0xFFFFFFFF;
   CHECK_CONTEXT (context);
 
   INVALID_DEVICE_IF (device != context->device);
@@ -470,8 +471,8 @@ clCreateCommandQueueWithProperties(cl_context                         context,
             case CL_QUEUE_PROFILING_ENABLE |
                 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE |
                 CL_QUEUE_ON_DEVICE_DEFAULT:
-                prop = que_val;
-                break;
+              prop = que_val;
+              break;
             default:
               err = CL_INVALID_VALUE;
               break;
@@ -479,6 +480,7 @@ clCreateCommandQueueWithProperties(cl_context                         context,
           }
           break;
         case CL_QUEUE_SIZE:
+          queue_sz = que_val;
           break;
         default:
           err = CL_INVALID_VALUE;
@@ -486,14 +488,18 @@ clCreateCommandQueueWithProperties(cl_context                         context,
       }
     }
   }
+  if(err) goto error;
   if(prop == 0xFFFFFFFF) prop = 0;
-
-  if((prop & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)||(prop & CL_QUEUE_ON_DEVICE)) {/*not supported now.*/
-    err = CL_INVALID_QUEUE_PROPERTIES;
-    goto error;
-  }
+  if(queue_sz != 0xFFFFFFFF)
+    if(!(prop & CL_QUEUE_ON_DEVICE)) {
+      err = CL_INVALID_VALUE;
+      goto error;
+    }
+  if(queue_sz == 0xFFFFFFFF) queue_sz = device->queue_on_device_preferred_size;
+  INVALID_VALUE_IF (queue_sz > device->queue_on_device_max_size);
 
   queue = cl_context_create_queue(context, device, prop, &err);
+  queue->size = queue_sz;
 error:
   if (errcode_ret)
     *errcode_ret = err;
@@ -539,6 +545,8 @@ clGetCommandQueueInfo(cl_command_queue       command_queue,
     FILL_GETINFO_RET (cl_uint, 1, &ref, CL_SUCCESS);
   } else if (param_name == CL_QUEUE_PROPERTIES) {
     FILL_GETINFO_RET (cl_command_queue_properties, 1, &command_queue->props, CL_SUCCESS);
+  } else if (param_name == CL_QUEUE_SIZE) {
+    FILL_GETINFO_RET (cl_uint, 1, &command_queue->size, CL_SUCCESS);
   } else {
     return CL_INVALID_VALUE;
   }
@@ -1125,6 +1133,8 @@ clCreateSamplerWithProperties(cl_context                  context,
       }
     }
   }
+  if(err)
+    goto error;
   if(normalized == 0xFFFFFFFF) normalized = CL_TRUE;
   if(addressing == 0xFFFFFFFF) addressing = CL_ADDRESS_CLAMP;
   if(filter == 0xFFFFFFFF) filter = CL_FILTER_NEAREST;
diff --git a/src/cl_command_queue.h b/src/cl_command_queue.h
index bdf1a43..ad56129 100644
--- a/src/cl_command_queue.h
+++ b/src/cl_command_queue.h
@@ -44,6 +44,7 @@ struct _cl_command_queue {
   cl_command_queue prev, next;         /* We chain the command queues together */
   void *thread_data;                   /* Used to store thread context data */
   cl_mem perf;                         /* Where to put the perf counters */
+  cl_uint size;                        /* Store the specified size for queueu */
 };
 
 /* The macro to get the thread specified gpgpu struct. */
diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
index 35a6ff5..6da2154 100644
--- a/src/cl_gt_device.h
+++ b/src/cl_gt_device.h
@@ -82,7 +82,7 @@
 .execution_capabilities = CL_EXEC_KERNEL | CL_EXEC_NATIVE_KERNEL,
 .queue_properties = CL_QUEUE_PROFILING_ENABLE,
 .queue_on_host_properties = CL_QUEUE_PROFILING_ENABLE,
-.queue_on_device_properties = CL_QUEUE_PROFILING_ENABLE,
+.queue_on_device_properties = CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
 .queue_on_device_preferred_size = 16 * 1024,
 .queue_on_device_max_size = 256 * 1024,
 .max_on_device_queues = 1,
-- 
2.5.0



More information about the Beignet mailing list