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?

Thanks.

It will work just fine for setting to zero.

OR

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!

:haha:

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