[Beignet] [PATCH] enable clGetContextInfo with CL_CONTEXT_DEVICES

Mario Kicherer dev at kicherer.org
Mon May 6 08:49:50 PDT 2013


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 at kicherer.org>
---
 src/cl_api.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 03cc0e6..570ba7d 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -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;
 }
 
-- 
1.8.1.5



More information about the Beignet mailing list