View Full Version : how to set a buffer's memory to 0

11-13-2009, 01:34 AM
how can i set a buffer's associated memory of a buffer which was created with clCreateBuffer to zero. I mean without copying a host memory block with zeros to device memory. Is there an api-function or something - i haven't found any (i mean like cudaMemSet in CUDA)

11-13-2009, 01:38 AM
I did this by writing a kernel that simply writes a given value to the buffer. Something like.

__kernel void setMem(__global float *buffer, float value, uint numFloats)
if(get_global_id(0) < numFloats)
buffer[get_global_id(0)] = value;

Not sure if this is the best way though.

11-13-2009, 01:45 AM
would be a workaround - i will try this - thx