summaryrefslogtreecommitdiff
path: root/src/cl_kernel.c
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@intel.com>2013-11-22 14:09:28 +0800
committerZhigang Gong <zhigang.gong@intel.com>2013-11-27 16:26:52 +0800
commit2b2fe68a424444c901a50a045124be17a7790ac6 (patch)
treec74d4cc045488efc9b55cd7424a41d35d052d466 /src/cl_kernel.c
parent42c39bd96ca8db44e975db729028269cc8cdce22 (diff)
CL/Runtime: workaround the unused sampler_t kernel argument.
Current implementation is to use a normal integer to represent a sampler_t, then later when the sampler is used in read_image or get_sampler_info, the backend will fixup its type to SAMPLER. But some test case in piglit will define a sampler_t kernel argument with an empty kernel budy. Then we will not have a chance to fixup the kernel argument type to sampler, then we will fail at runtime side. To workaround this issue, we change the sampler_t to short type. Then when the user call clSetKernelArg to set a sampler, it will pass in a pointer size with a short value argument type. It will fail the size checking logic, then we fixup its type to sampler there. As this workaround will only take effect when error occur, it will not bring too much side effect to the normal cases. And it can pass the existing test cases. Signed-off-by: Zhigang Gong <zhigang.gong@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_kernel.c')
-rw-r--r--src/cl_kernel.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cl_kernel.c b/src/cl_kernel.c
index 803c9e54..6a0c8e6a 100644
--- a/src/cl_kernel.c
+++ b/src/cl_kernel.c
@@ -105,8 +105,14 @@ cl_kernel_set_arg(cl_kernel k, cl_uint index, size_t sz, const void *value)
arg_type = gbe_kernel_get_arg_type(k->opaque, index);
arg_sz = gbe_kernel_get_arg_size(k->opaque, index);
- if (UNLIKELY(arg_type != GBE_ARG_LOCAL_PTR && arg_sz != sz))
- return CL_INVALID_ARG_SIZE;
+ if (UNLIKELY(arg_type != GBE_ARG_LOCAL_PTR && arg_sz != sz)) {
+ if (arg_sz == 2 && arg_type == GBE_ARG_VALUE && sz == sizeof(cl_sampler)) {
+ /* FIXME, this is a workaround for the case when a kernel arg
+ defined a sampler_t but doesn't use it.*/
+ arg_type = GBE_ARG_SAMPLER;
+ } else
+ return CL_INVALID_ARG_SIZE;
+ }
if(UNLIKELY(arg_type == GBE_ARG_LOCAL_PTR && sz == 0))
return CL_INVALID_ARG_SIZE;