There is something wrong with utest and for, will send another patch. -----Original Message----- From: Pan, Xiuli Sent: Wednesday, March 2, 2016 5:15 AM To: [email protected] Cc: Pan, Xiuli <[email protected]> Subject: [PATCH OCL20] Runtime: Add API clCreateCommandQueueWithProperties
From: Luo Xionghu <xionghu.luo at intel.com> Contributor: Luo Xionghu <xionghu.luo at intel.com> Signed-off-by: Pan Xiuli <[email protected]> --- src/cl_api.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ src/cl_khr_icd.c | 22 ++++++++------- utests/profiling_exec.cpp | 3 ++- utests/utest_helper.cpp | 4 +-- 4 files changed, 86 insertions(+), 12 deletions(-) diff --git a/src/cl_api.c b/src/cl_api.c index a283a37..6f430ae 100644 --- a/src/cl_api.c +++ b/src/cl_api.c @@ -429,6 +429,75 @@ 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; + for(cl_uint 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 cc73453..a9b7a6d 100644 --- a/src/cl_khr_icd.c +++ b/src/cl_khr_icd.c @@ -55,7 +55,11 @@ struct _cl_icd_dispatch const cl_khr_icd_dispatch = { clRetainContext, clReleaseContext, clGetContextInfo, +#ifdef CL_VERSION_2_0 + (void *) NULL, /* clCreateCommandQueue deprecated.*/ #else clCreateCommandQueue, +#endif clRetainCommandQueue, clReleaseCommandQueue, clGetCommandQueueInfo, @@ -172,19 +176,19 @@ 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, clSVMFree, - (void *) clEnqueueSVMFree, - (void *) clEnqueueSVMMemcpy, - (void *) clEnqueueSVMMemFill, - (void *) clEnqueueSVMMap, - (void *) clEnqueueSVMUnmap, - (void *) clCreateSamplerWithProperties, - (void *) clSetKernelArgSVMPointer, - (void *) clSetKernelExecInfo, + clEnqueueSVMFree, + clEnqueueSVMMemcpy, + clEnqueueSVMMemFill, + clEnqueueSVMMap, + clEnqueueSVMUnmap, + clCreateSamplerWithProperties, + clSetKernelArgSVMPointer, + clSetKernelExecInfo, #endif }; diff --git a/utests/profiling_exec.cpp b/utests/profiling_exec.cpp index 437a628..7a6e286 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_PROFILING_ENABLE; + 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 0aab208..d265d4c 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; } -- 2.5.0 _______________________________________________ Beignet mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/beignet
