AnsweredAssumed Answered

Passing a NULL buffer to a kernel

Question asked by adm271828 on Apr 30, 2011
Latest reply on Jun 4, 2014 by dipak

According to OpenCL 1.1 (§ 5.7.2) it is possible to pass a null buffer to a kernel: "If the argument is a buffer object, the arg_value pointer can be NULL or point to a NULL value 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."

However, I can't see it working. Here is what I get for various attempts (SDK 2.4).




err = clSetKernelArg (k, 0, 0, 0); // -> err = CL_INVALID_ARG_VALUE cl_mem buf = 0; err = clSetKernelArg (k, 0, sizeof(cl_mem), &buf); // -> err = CL_INVALID_MEM_OBJECT err = clSetKernelArg (k, 0, 0, &buf); // -> err = CL_INVALID_ARG_SIZE