kernel arguments restrction

Hi forum,

In the manual it is mentioned that

“Arguments to __kernel functions in a program cannot be declared with the built-in scalar types bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t”. I need the pitch value to be passed to the kernel of type size_t.

Is there any other way to get around this issue?

Thanks

I usually just use the cl_ulong type in kernel code to represent a size_t.

Make sure you cast the value to cl_ulong before passing it to the kernel in the off-chance that size_t is greater than 64-bits.

Thanks for the hint.

I am replacing every instant of the size_t with ulong and using ulong type in the kernel argument as well. But i am getting a new error as follows:


Error in setting kernel arguments for the pitch value: CL_INVALID_ARG_SIZE

I am setting the kernel argument as follows:


 errNum = clSetKernelArg(updateVelocityKernel,7,sizeof(ulong),(void*)&tPitch);

Any hint where to look into to debug this issue?

Thanks

CL_INVALID_ARG_SIZE indicates that the size declared with clSetKernelArg() (i.e. sizeof(cl_ulong)) does not match the size of the corresponding argument in the declaration of your kernel.