There’s no standard way to check before setting the argument as far as I’m aware, but the
clSetKernelArg call will return
CL_INVALID_ARG_SIZE if the sizes don’t match properly, so that should allow you to detect and handle errors accordingly:
CL_INVALID_ARG_SIZE if arg_size does not match the size of the data type for an argument that is not a memory object or if the argument is a memory object and arg_size != sizeof(cl_mem) or if arg_size is zero and the argument is declared with the __local qualifier or if the argument is a sampler and arg_size != sizeof(cl_sampler).
CLICK HERE to find out more related problems solutions.