enable clGetContextInfo with CL_CONTEXT_DEVICES
authorMario Kicherer <dev@kicherer.org>
Mon, 6 May 2013 15:49:50 +0000 (17:49 +0200)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Tue, 7 May 2013 07:59:01 +0000 (15:59 +0800)
The following patch enables the clGetContextInfo query with CL_CONTEXT_DEVICES.
Applications can query the required size of the result buffer and then request
the cl_device_id of the available devices in this context.

Signed-off-by: Mario Kicherer <dev@kicherer.org>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
src/cl_api.c

index 03cc0e6..c9aba20 100644 (file)
@@ -159,7 +159,24 @@ clGetContextInfo(cl_context      context,
                  void *          param_value,
                  size_t *        param_value_size_ret)
 {
-  NOT_IMPLEMENTED;
+  switch (param_name) {
+    case CL_CONTEXT_DEVICES:
+      if (param_value) {
+        if (param_value_size < sizeof(cl_device_id))
+          return CL_INVALID_VALUE;
+          cl_device_id *device_list = (cl_device_id*)param_value;
+          device_list[0] = context->device;
+          if (param_value_size_ret)
+            *param_value_size_ret = sizeof(cl_device_id);
+          return CL_SUCCESS;
+        }
+        if (param_value_size_ret) {
+          *param_value_size_ret = sizeof(cl_device_id);
+          return CL_SUCCESS;
+        }
+    default:
+      NOT_IMPLEMENTED;
+  }
   return 0;
 }