[Beignet] [PATCH 2/7] Modify clGetEventInfo using cl_get_info_helper.

junyan.he at inbox.com junyan.he at inbox.com
Sat Oct 8 08:47:51 UTC 2016


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 src/cl_api.c       | 32 --------------------------------
 src/cl_api_event.c | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/src/cl_api.c b/src/cl_api.c
index 1d4c5a1..5e2d4e3 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1273,38 +1273,6 @@ clGetKernelSubGroupInfoKHR(cl_kernel                   kernel,
 }
 
 cl_int
-clGetEventInfo(cl_event      event,
-               cl_event_info param_name,
-               size_t        param_value_size,
-               void *        param_value,
-               size_t *      param_value_size_ret)
-{
-  cl_int err = CL_SUCCESS;
-  cl_int status;
-  CHECK_EVENT(event);
-
-  if (param_name == CL_EVENT_COMMAND_QUEUE) {
-    FILL_GETINFO_RET (cl_command_queue, 1, &event->queue, CL_SUCCESS);
-  } else if (param_name == CL_EVENT_CONTEXT) {
-    FILL_GETINFO_RET (cl_context, 1, &event->ctx, CL_SUCCESS);
-  } else if (param_name == CL_EVENT_COMMAND_TYPE) {
-    FILL_GETINFO_RET (cl_command_type, 1, &event->event_type, CL_SUCCESS);
-  } else if (param_name == CL_EVENT_COMMAND_EXECUTION_STATUS) {
-    status = cl_event_get_status(event);
-    FILL_GETINFO_RET (cl_int, 1, &status, CL_SUCCESS);
-  } else if (param_name == CL_EVENT_REFERENCE_COUNT) {
-    cl_uint ref = CL_OBJECT_GET_REF(event);
-    FILL_GETINFO_RET (cl_int, 1, &ref, CL_SUCCESS);
-  } else {
-    return CL_INVALID_VALUE;
-  }
-
-error:
-  return err;
-
-}
-
-cl_int
 clRetainEvent(cl_event  event)
 {
   cl_int err = CL_SUCCESS;
diff --git a/src/cl_api_event.c b/src/cl_api_event.c
index 63bccf2..a5cc114 100644
--- a/src/cl_api_event.c
+++ b/src/cl_api_event.c
@@ -249,3 +249,42 @@ clSetEventCallback(cl_event event,
   err = cl_event_set_callback(event, command_exec_callback_type, pfn_notify, user_data);
   return err;
 }
+
+cl_int
+clGetEventInfo(cl_event event,
+               cl_event_info param_name,
+               size_t param_value_size,
+               void *param_value,
+               size_t *param_value_size_ret)
+{
+  void *src_ptr = NULL;
+  size_t src_size = 0;
+
+  if (!CL_OBJECT_IS_EVENT(event)) {
+    return CL_INVALID_EVENT;
+  }
+
+  if (param_name == CL_EVENT_COMMAND_QUEUE) {
+    src_ptr = &event->queue;
+    src_size = sizeof(cl_command_queue);
+  } else if (param_name == CL_EVENT_CONTEXT) {
+    src_ptr = &event->ctx;
+    src_size = sizeof(cl_context);
+  } else if (param_name == CL_EVENT_COMMAND_TYPE) {
+    src_ptr = &event->event_type;
+    src_size = sizeof(cl_command_type);
+  } else if (param_name == CL_EVENT_COMMAND_EXECUTION_STATUS) {
+    cl_int status = cl_event_get_status(event);
+    src_ptr = &status;
+    src_size = sizeof(cl_int);
+  } else if (param_name == CL_EVENT_REFERENCE_COUNT) {
+    cl_uint ref = CL_OBJECT_GET_REF(event);
+    src_ptr = &ref;
+    src_size = sizeof(cl_int);
+  } else {
+    return CL_INVALID_VALUE;
+  }
+
+  return cl_get_info_helper(src_ptr, src_size,
+                            param_value, param_value_size, param_value_size_ret);
+}
-- 
2.7.4





More information about the Beignet mailing list