[Beignet] [PATCH OCL20 4/11 v2] Runtime: Add clCreateSamplerWithProperties
Xiuli Pan
xiuli.pan at intel.com
Wed Mar 9 00:46:52 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
Add api clCreateSamplerWithProperties
v2: fix bug
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
src/cl_api.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/cl_device_id.c | 2 +-
src/cl_khr_icd.c | 12 +++++------
3 files changed, 70 insertions(+), 7 deletions(-)
diff --git a/src/cl_api.c b/src/cl_api.c
index 2faafdf..ec5cf4d 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -1070,6 +1070,69 @@ error:
return sampler;
}
+cl_sampler
+clCreateSamplerWithProperties(cl_context context,
+ const cl_sampler_properties *sampler_properties,
+ cl_int * errcode_ret)
+{
+ cl_sampler sampler = NULL;
+ cl_int err = CL_SUCCESS;
+ CHECK_CONTEXT (context);
+ cl_bool normalized = 0xFFFFFFFF;
+ cl_addressing_mode addressing = 0xFFFFFFFF;
+ cl_filter_mode filter = 0xFFFFFFFF;
+ if(sampler_properties)
+ {
+ cl_ulong sam_type;
+ cl_ulong sam_val;
+ cl_uint i;
+ for(i = 0;(sam_type = sampler_properties[i++])!=0;i++)
+ {
+ sam_val = sampler_properties[i];
+ switch(sam_type)
+ {
+ case CL_SAMPLER_NORMALIZED_COORDS:
+ if(normalized != 0xFFFFFFFF)
+ err = CL_INVALID_VALUE;
+ else if(sam_val == CL_TRUE || sam_val == CL_FALSE)
+ normalized = sam_val;
+ else
+ err = CL_INVALID_VALUE;
+ break;
+ case CL_SAMPLER_ADDRESSING_MODE:
+ if(addressing != 0xFFFFFFFF)
+ err = CL_INVALID_VALUE;
+ else if(sam_val == CL_ADDRESS_MIRRORED_REPEAT || sam_val == CL_ADDRESS_REPEAT ||
+ sam_val == CL_ADDRESS_CLAMP_TO_EDGE || sam_val == CL_ADDRESS_CLAMP ||
+ sam_val == CL_ADDRESS_NONE)
+ addressing = sam_val;
+ else
+ err = CL_INVALID_VALUE;
+ break;
+ case CL_SAMPLER_FILTER_MODE:
+ if(filter != 0xFFFFFFFF)
+ err = CL_INVALID_VALUE;
+ else if(sam_val == CL_FILTER_LINEAR || sam_val == CL_FILTER_NEAREST)
+ filter = sam_val;
+ else
+ err = CL_INVALID_VALUE;
+ break;
+ default:
+ err = CL_INVALID_VALUE;
+ break;
+ }
+ }
+ }
+ if(normalized == 0xFFFFFFFF) normalized = CL_TRUE;
+ if(addressing == 0xFFFFFFFF) addressing = CL_ADDRESS_CLAMP;
+ if(filter == 0xFFFFFFFF) filter = CL_FILTER_NEAREST;
+ sampler = cl_sampler_new(context, normalized, addressing, filter, &err);
+error:
+ if (errcode_ret)
+ *errcode_ret = err;
+ return sampler;
+}
+
cl_int
clRetainSampler(cl_sampler sampler)
{
diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index b518d48..99320be 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -613,7 +613,7 @@ cl_self_test(cl_device_id device, cl_self_test_res atomic_in_l3_flag)
ctx = clCreateContext(NULL, 1, &device, NULL, NULL, &status);
cl_driver_set_atomic_flag(ctx->drv, atomic_in_l3_flag);
if (status == CL_SUCCESS) {
- queue = clCreateCommandQueue(ctx, device, 0, &status);
+ queue = clCreateCommandQueueWithProperties(ctx, device, 0, &status);
if (status == CL_SUCCESS) {
program = clCreateProgramWithSource(ctx, 1, &kernel_source, NULL, &status);
if (status == CL_SUCCESS) {
diff --git a/src/cl_khr_icd.c b/src/cl_khr_icd.c
index 1e63b73..a9b7a6d 100644
--- a/src/cl_khr_icd.c
+++ b/src/cl_khr_icd.c
@@ -181,12 +181,12 @@ struct _cl_icd_dispatch const cl_khr_icd_dispatch = {
(void *) NULL /* clGetPipeInfo */,
clSVMAlloc,
clSVMFree,
- (void *) clEnqueueSVMFree,
- (void *) clEnqueueSVMMemcpy,
- (void *) clEnqueueSVMMemFill,
- (void *) clEnqueueSVMMap,
- (void *) clEnqueueSVMUnmap,
- (void *) NULL /* clCreateSamplerWithProperties */,
+ clEnqueueSVMFree,
+ clEnqueueSVMMemcpy,
+ clEnqueueSVMMemFill,
+ clEnqueueSVMMap,
+ clEnqueueSVMUnmap,
+ clCreateSamplerWithProperties,
clSetKernelArgSVMPointer,
clSetKernelExecInfo,
#endif
--
2.5.0
More information about the Beignet
mailing list