Any quick way to set an array to zeros?

I am writing a program that needs quite a lot of zeros padding in float array.

Is cudaMemset only for integer?
Any alternative?


It will work just fine for setting to zero.


Write a kernel that does this:

__global__ void myclear(float *array, int n)


  for(i=blockIdx.x*blockDim.x; i<n; i+=blockDim.x*gridDim.x)


     array[i+threadIdx.x] = 0;



Spawn appropriate blocks and threads as per your GPU limits.

Profile this with cudaMemset and see who wins.

Thanks for the tips!


Yes, Dont forget to unroll the FOR loop to achieve da best performance.