diff options
author | Junyan He <junyan.he@intel.com> | 2016-12-19 14:06:57 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-12-19 16:42:35 +0800 |
commit | a5e24e2fac09974138c715f685d5322b1f81758d (patch) | |
tree | b016666de20b193376776cb4f6750bf77d517af2 /src/cl_api_command_queue.c | |
parent | 494081299ac3f6970b906cb4d7d1eb1fc2fb23c8 (diff) |
Move clCreateCommandQueueWithProperties API to command_queue file.
Signed-off-by: Junyan He <junyan.he@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_api_command_queue.c')
-rw-r--r-- | src/cl_api_command_queue.c | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/src/cl_api_command_queue.c b/src/cl_api_command_queue.c index 34b5789a..b1aee128 100644 --- a/src/cl_api_command_queue.c +++ b/src/cl_api_command_queue.c @@ -20,6 +20,7 @@ #include "CL/cl.h" #include <stdio.h> +/* Depreciated in 2.0 later */ cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, @@ -49,7 +50,99 @@ clCreateCommandQueue(cl_context context, break; } - queue = cl_create_command_queue(context, device, properties, &err); + queue = cl_create_command_queue(context, device, properties, 0, &err); + } while (0); + + if (errcode_ret) + *errcode_ret = err; + return queue; +} + +/* 2.0 new API for create command queue. */ +cl_command_queue +clCreateCommandQueueWithProperties(cl_context context, + cl_device_id device, + const cl_queue_properties *properties, + cl_int *errcode_ret) +{ + cl_command_queue queue = NULL; + cl_int err = CL_SUCCESS; + cl_command_queue_properties prop = 0xFFFFFFFF; + cl_uint queue_sz = 0xFFFFFFFF; + + do { + if (!CL_OBJECT_IS_CONTEXT(context)) { + err = CL_INVALID_CONTEXT; + break; + } + + err = cl_devices_list_include_check(context->device_num, context->devices, 1, &device); + if (err) + break; + + if (properties) { + cl_ulong que_type; + cl_ulong que_val; + cl_uint i; + for (i = 0; (que_type = properties[i++]) != 0; i++) { + que_val = properties[i]; + switch (que_type) { + case CL_QUEUE_PROPERTIES: + if (prop != 0xFFFFFFFF) + err = CL_INVALID_VALUE; + else { + switch (que_val) { + case 0: + case CL_QUEUE_PROFILING_ENABLE: + case CL_QUEUE_PROFILING_ENABLE | + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE: + case CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE: + case CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE: + case CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE | + CL_QUEUE_ON_DEVICE_DEFAULT: + case CL_QUEUE_PROFILING_ENABLE | + CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_ON_DEVICE: + 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; + default: + err = CL_INVALID_VALUE; + break; + } + } + break; + case CL_QUEUE_SIZE: + queue_sz = que_val; + break; + default: + err = CL_INVALID_VALUE; + break; + } + } + + if (err) /* break the while and return some err. */ + break; + } + + /* Set some paramters to default val. */ + if (prop == 0xFFFFFFFF) + prop = 0; + if (queue_sz != 0xFFFFFFFF) + if (!(prop & CL_QUEUE_ON_DEVICE)) { + err = CL_INVALID_VALUE; + break; + } + if (queue_sz == 0xFFFFFFFF) + queue_sz = device->queue_on_device_preferred_size; + + if (queue_sz > device->queue_on_device_max_size) { + err = CL_INVALID_VALUE; + break; + } + + queue = cl_create_command_queue(context, device, prop, queue_sz, &err); } while (0); if (errcode_ret) |