0
votes

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?

1

1 Answers

2
votes

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.