PDA

View Full Version : Copying memory of zero size



DP007
11-20-2009, 01:44 AM
Hi,

I have a kernel that gets some lightsource arrays as input parameters (directional, point and spot). The number of each light source array could also be 0. If the size is zero, I get an error when allocating mem on the gpu for that array. Since that doesn't work, I tried to pass the kernel NULL as the light source array if the ammount is 0. But then I also get an error from the clSetKernelArg-function. How to avoid that and make the programm run properly?

Thanks.

affie
11-20-2009, 10:17 AM
You should be able to pass a NULL value for a kernel argument declared as a __global pointer to a type. Another option would be to pass a count variable as an argument which could be set to 0. The kernel could check this value to see if it is non-zero.