NULL pointers in OpenCL kernels

The OpenCL specification (1.0.43) seems to indicate that it’s legal to pass a NULL pointer to an OpenCL kernel:

“A NULL value can also be specified if the argument is a buffer object in which case a NULL value will be used as the value for the argument declared as a pointer to __global or __constant memory in the kernel.” and “The memory object specified as argument value must be a buffer object (or NULL) if the argument is declared to be a pointer of a built-in or user defined type with the __global or __constant qualifier.”

However, if I call clSetKernelArg with the 3rd argument set to sizeof(cl_mem) or 0, and the 4th argument to NULL, then I get the CL_INVALID_VALUE error when I call clEnqueueNDRangeKernel (this happens with nvdrivers_2.3_linux_64_190.29.run).

Have I misunderstood the specification, or is it a bug in the OpenCL drivers?

I see the same thing on Windows Xp. I have to create a dummy buffer object to use as NULL.

Hi Griffin,

I have the same issue, so how have you create a ‘dummy’ buffer ? and on the kernel side, how do you recognize it as NULL ?

Thx

Hi Griffin,

I have the same issue, so how have you create a ‘dummy’ buffer ? and on the kernel side, how do you recognize it as NULL ?

Thx