In OpenCL, how can we send addresses of the memory objects or other arguments in the kernel (while setting the kernel argument) and not accept them as pointers during kernel declaration? how can addresses be assigned to non-pointer datatypes like in the following eg:
//setting the kernel args in host code:
errNum = clSetKernelArg(kernel, 0, sizeof(cl_mem), &imageObjects[0]);
errNum |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &imageObjects[1]);
errNum |= clSetKernelArg(kernel, 2, sizeof(cl_sampler), &sampler);
errNum |= clSetKernelArg(kernel, 3, sizeof(cl_int), &width);
errNum |= clSetKernelArg(kernel, 4, sizeof(cl_int), &height);
// kernel declaration:
__kernel void gaussian_filter(__read_only image2d_t srcImg, __write_only image2d_t dstImg, sampler_t sampler, int width, int height)
The code is a part of "ImageFilter" code given in OpenCl Book Sample on Google Code.
I have two doubts:
1) Here imageObjects[0] already contains the address of input image, So why is there a need to pass &imageObjects[0] to the kernel? also if the addresses are passed, why aren't they accepted as pointers
2) addresses of the args height and width are passed, but none of the args are accepted as pointers, moreover if they are accepted as pointers error is given at the compile time. Why such happens.