Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using memset in a CUDA kernel

Tags:

c++

cuda

memset

This seems like an obvious issue, but Google turns up nothing interesting. Is it legal to use memset in a CUDA kernel such as:

__device__ void myKernel()
{
    int array[10];
    memset(array, 0, sizeof(array));
    // ...etc...
}

(I know int array[10] = {0}; is probably better, but this is just an example of a more complicated case.)

like image 319
Ken Y-N Avatar asked Jan 14 '16 09:01

Ken Y-N


1 Answers

Yes, as described in Appendix B of the programming manual, memset, as well as memcpy, malloc, and free (the latter two only on Compute capability >= 2.0 devices) are supported in device code.

like image 159
talonmies Avatar answered Sep 27 '22 22:09

talonmies