Reputation: 1321
For following kernel, I am first allocating OpenCL memory buffer using clCreateBuffer. Then, I use clSetKernelArg with argsize set to sizeof(cl_mem).
float ExampleKernel (__global unsigned char* arg1)
{
// some code
}
My question is even if kernel's argument is of pointer to unsigned char, why do I need to set argsize to sizeof(cl_mem)? Is it because for OpenCL data is allocated always in cl_mem format (sizeof(cl_mem) per element)? And when kernel is called, dynamic type casting to respective argument type is handled by OpenCL?
Upvotes: 0
Views: 194
Reputation: 23438
The kernel's argument is not of type unsigned char: it's a pointer to global memory containing unsigned chars. And the way such buffers are represented on the host side happens to be via the cl_mem
type. On the kernel side they're represented by global
pointers.
Upvotes: 2