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 | |
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>
-rw-r--r-- | src/cl_api.c | 79 | ||||
-rw-r--r-- | src/cl_api_command_queue.c | 95 | ||||
-rw-r--r-- | src/cl_command_queue.c | 5 | ||||
-rw-r--r-- | src/cl_command_queue.h | 14 |
4 files changed, 99 insertions, 94 deletions
diff --git a/src/cl_api.c b/src/cl_api.c index 41c6c067..943e5877 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -80,85 +80,6 @@ clGetPlatformIDs(cl_uint num_entries, return cl_get_platform_ids(num_entries, platforms, num_platforms); } -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; - CHECK_CONTEXT (context); - - err = cl_devices_list_include_check(context->device_num, context->devices, 1, &device); - if (err) - goto error; - - 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) goto error; - if(prop == 0xFFFFFFFF) prop = 0; - if(queue_sz != 0xFFFFFFFF) - if(!(prop & CL_QUEUE_ON_DEVICE)) { - err = CL_INVALID_VALUE; - goto error; - } - if(queue_sz == 0xFFFFFFFF) queue_sz = device->queue_on_device_preferred_size; - INVALID_VALUE_IF (queue_sz > device->queue_on_device_max_size); - - queue = cl_create_command_queue(context, device, prop, &err); - queue->size = queue_sz; -error: - if (errcode_ret) - *errcode_ret = err; - return queue; -} - 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 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) diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c index 30e918b3..cab0c19d 100644 --- a/src/cl_command_queue.c +++ b/src/cl_command_queue.c @@ -58,8 +58,8 @@ cl_command_queue_new(cl_context ctx) } LOCAL cl_command_queue -cl_create_command_queue(cl_context ctx, cl_device_id device, - cl_command_queue_properties properties, cl_int *errcode_ret) +cl_create_command_queue(cl_context ctx, cl_device_id device, cl_command_queue_properties properties, + cl_uint queue_size, cl_int *errcode_ret) { cl_command_queue queue = cl_command_queue_new(ctx); if (queue == NULL) { @@ -68,6 +68,7 @@ cl_create_command_queue(cl_context ctx, cl_device_id device, queue->props = properties; queue->device = device; + queue->size = queue_size; *errcode_ret = CL_SUCCESS; return queue; diff --git a/src/cl_command_queue.h b/src/cl_command_queue.h index dbcca434..d9f6b0db 100644 --- a/src/cl_command_queue.h +++ b/src/cl_command_queue.h @@ -60,14 +60,12 @@ typedef struct _cl_command_queue { /* Allocate and initialize a new command queue. Also insert it in the list of * command queue in the associated context */ -extern cl_command_queue cl_create_command_queue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*); - +extern cl_command_queue cl_create_command_queue(cl_context, cl_device_id, + cl_command_queue_properties, cl_uint, cl_int*); /* Destroy and deallocate the command queue */ extern void cl_command_queue_delete(cl_command_queue); - /* Keep one more reference on the queue */ extern void cl_command_queue_add_ref(cl_command_queue); - /* Map ND range kernel from OCL API */ extern cl_int cl_command_queue_ND_range(cl_command_queue queue, cl_kernel ker, @@ -76,28 +74,20 @@ extern cl_int cl_command_queue_ND_range(cl_command_queue queue, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size); - /* The memory object where to report the performance */ extern cl_int cl_command_queue_set_report_buffer(cl_command_queue, cl_mem); - /* Flush for the specified gpgpu */ extern int cl_command_queue_flush_gpgpu(cl_gpgpu); - /* Bind all the surfaces in the GPGPU state */ extern cl_int cl_command_queue_bind_surface(cl_command_queue, cl_kernel, cl_gpgpu, uint32_t *); - /* Bind all the image surfaces in the GPGPU state */ extern cl_int cl_command_queue_bind_image(cl_command_queue, cl_kernel, cl_gpgpu, uint32_t *); - /* Bind all exec info to bind table */ extern cl_int cl_command_queue_bind_exec_info(cl_command_queue, cl_kernel, cl_gpgpu, uint32_t); - /* Insert a user event to command's wait_events */ extern void cl_command_queue_insert_event(cl_command_queue, cl_event); - /* Remove a user event from command's wait_events */ extern void cl_command_queue_remove_event(cl_command_queue, cl_event); - extern void cl_command_queue_insert_barrier_event(cl_command_queue queue, cl_event event); extern void cl_command_queue_remove_barrier_event(cl_command_queue queue, cl_event event); extern void cl_command_queue_notify(cl_command_queue queue); |