[Beignet] [PATCH 5/7] Modify clGetCommandQueueInfo using cl_get_info_helper.
junyan.he at inbox.com
junyan.he at inbox.com
Sat Oct 8 08:47:54 UTC 2016
From: Junyan He <junyan.he at intel.com>
Signed-off-by: Junyan He <junyan.he at intel.com>
---
src/cl_api.c | 27 ---------------------------
src/cl_api_command_queue.c | 37 +++++++++++++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/src/cl_api.c b/src/cl_api.c
index 0ab03ea..0a69aca 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -343,33 +343,6 @@ error:
return err;
}
-cl_int
-clGetCommandQueueInfo(cl_command_queue command_queue,
- cl_command_queue_info param_name,
- size_t param_value_size,
- void * param_value,
- size_t * param_value_size_ret)
-{
- cl_int err = CL_SUCCESS;
- CHECK_QUEUE (command_queue);
-
- if (param_name == CL_QUEUE_CONTEXT) {
- FILL_GETINFO_RET (cl_context, 1, &command_queue->ctx, CL_SUCCESS);
- } else if (param_name == CL_QUEUE_DEVICE) {
- FILL_GETINFO_RET (cl_device_id, 1, &command_queue->ctx->device, CL_SUCCESS);
- } else if (param_name == CL_QUEUE_REFERENCE_COUNT) {
- cl_uint ref = CL_OBJECT_GET_REF(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 {
- return CL_INVALID_VALUE;
- }
-
-error:
- return err;
-}
-
cl_mem
clCreateBuffer(cl_context context,
cl_mem_flags flags,
diff --git a/src/cl_api_command_queue.c b/src/cl_api_command_queue.c
index 9f06deb..426b9a0 100644
--- a/src/cl_api_command_queue.c
+++ b/src/cl_api_command_queue.c
@@ -20,6 +20,41 @@
#include <stdio.h>
cl_int
+clGetCommandQueueInfo(cl_command_queue command_queue,
+ cl_command_queue_info param_name,
+ size_t param_value_size,
+ void *param_value,
+ size_t *param_value_size_ret)
+{
+ const void *src_ptr = NULL;
+ size_t src_size = 0;
+
+ if (!CL_OBJECT_IS_COMMAND_QUEUE(command_queue)) {
+ return CL_INVALID_COMMAND_QUEUE;
+ }
+
+ if (param_name == CL_QUEUE_CONTEXT) {
+ src_ptr = &command_queue->ctx;
+ src_size = sizeof(cl_context);
+ } else if (param_name == CL_QUEUE_DEVICE) {
+ src_ptr = &command_queue->ctx->device;
+ src_size = sizeof(cl_device_id);
+ } else if (param_name == CL_QUEUE_REFERENCE_COUNT) {
+ cl_int ref = CL_OBJECT_GET_REF(command_queue);
+ src_ptr = &ref;
+ src_size = sizeof(cl_int);
+ } else if (param_name == CL_QUEUE_PROPERTIES) {
+ src_ptr = &command_queue->props;
+ src_size = sizeof(cl_command_queue_properties);
+ } else {
+ return CL_INVALID_VALUE;
+ }
+
+ return cl_get_info_helper(src_ptr, src_size,
+ param_value, param_value_size, param_value_size_ret);
+}
+
+cl_int
clFlush(cl_command_queue command_queue)
{
if (!CL_OBJECT_IS_COMMAND_QUEUE(command_queue)) {
@@ -39,7 +74,6 @@ clFinish(cl_command_queue command_queue)
return cl_command_queue_wait_finish(command_queue);
}
-
cl_int
clReleaseCommandQueue(cl_command_queue command_queue)
{
@@ -52,4 +86,3 @@ clReleaseCommandQueue(cl_command_queue command_queue)
cl_command_queue_delete(command_queue);
return CL_SUCCESS;
}
-
--
2.7.4
More information about the Beignet
mailing list