how to set a buffer's memory to 0

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)

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.

would be a workaround - i will try this - thx