summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Xionghu <xionghu.luo at intel.com>2016-03-01 07:46:09 +0800
committerYang Rong <rong.r.yang@intel.com>2016-03-15 14:21:00 +0800
commitc372733e43a8ff83ec87d6c093c561557b6ccea5 (patch)
treeeee614094bfba0d42d75077568efebe36ade8c76
parentf02d4fe5a7696b618b697ae059006137c6deba7a (diff)
downloadbeignet-c372733e43a8ff83ec87d6c093c561557b6ccea5.tar.gz
Runtime: Add API clCreateCommandQueueWithProperties
Contributor: Luo Xionghu <xionghu.luo at intel.com> Signed-off-by: Pan Xiuli <xiuli.pan@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--src/cl_api.c70
-rw-r--r--src/cl_khr_icd.c2
-rw-r--r--utests/profiling_exec.cpp3
-rw-r--r--utests/utest_helper.cpp4
4 files changed, 75 insertions, 4 deletions
diff --git a/src/cl_api.c b/src/cl_api.c
index 3bcfed1d..131a84c6 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -429,6 +429,76 @@ error:
return 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;
+ CHECK_CONTEXT (context);
+
+ INVALID_DEVICE_IF (device != context->device);
+ 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:
+ break;
+ default:
+ err = CL_INVALID_VALUE;
+ break;
+ }
+ }
+ }
+ if(prop == 0xFFFFFFFF) prop = 0;
+
+ if((prop & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)||(prop & CL_QUEUE_ON_DEVICE)) {/*not supported now.*/
+ err = CL_INVALID_QUEUE_PROPERTIES;
+ goto error;
+ }
+
+ queue = cl_context_create_queue(context, device, prop, &err);
+error:
+ if (errcode_ret)
+ *errcode_ret = err;
+ return queue;
+}
+
cl_int
clRetainCommandQueue(cl_command_queue command_queue)
{
diff --git a/src/cl_khr_icd.c b/src/cl_khr_icd.c
index 73d1924e..1d0a2f1f 100644
--- a/src/cl_khr_icd.c
+++ b/src/cl_khr_icd.c
@@ -172,7 +172,7 @@ struct _cl_icd_dispatch const cl_khr_icd_dispatch = {
(void *) NULL,
#endif
#ifdef CL_VERSION_2_0
- (void *) NULL /* clCreateCommandQueueWithProperties */,
+ clCreateCommandQueueWithProperties,
(void *) NULL /* clCreatePipe */,
(void *) NULL /* clGetPipeInfo */,
clSVMAlloc,
diff --git a/utests/profiling_exec.cpp b/utests/profiling_exec.cpp
index 437a6285..1859134f 100644
--- a/utests/profiling_exec.cpp
+++ b/utests/profiling_exec.cpp
@@ -52,7 +52,8 @@ static void profiling_exec(void)
/* Because the profiling prop, we can not use default queue. */
- profiling_queue = clCreateCommandQueue(ctx, device, CL_QUEUE_PROFILING_ENABLE, &status);
+ const cl_queue_properties properties[] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE, 0};
+ profiling_queue = clCreateCommandQueueWithProperties(ctx, device, properties, &status);
OCL_ASSERT(status == CL_SUCCESS);
OCL_CREATE_KERNEL("compiler_fabs");
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index 0aab208b..d265d4c0 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -501,9 +501,9 @@ cl_ocl_init(void)
cl_test_channel_type_string(fmt[i].image_channel_data_type));
/* We are going to push NDRange kernels here */
- queue = clCreateCommandQueue(ctx, device, 0, &status);
+ queue = clCreateCommandQueueWithProperties(ctx, device, 0, &status);
if (status != CL_SUCCESS) {
- fprintf(stderr, "error calling clCreateCommandQueue\n");
+ fprintf(stderr, "error calling clCreateCommandQueueWithProperties\n");
goto error;
}