default value stored in cudaMalloc and cudaHostAlloc

i worder what is the defalut value stored in cudaMalloc dan cudaHostAlloc?
i did my own test. the cudaHostAlloc always stores zero value in allocation
however when i tried the cudaMalloc, it is not zero. anyone could confirm this? is there any official documentation about this?

Like malloc() in C, cudaMalloc() only allocates memory, it does not initialize it (see the API reference). By standard naming C/C++ conventions an initializing allocation function would be name cudaCalloc(). I don’t think such a function exists, but it is easily synthesized from cudaMalloc() and cudaMemset().

The behavior of cudaMallocHost() is likely determined directly by the behavior of the underlying operating system APIs, and initialization behavior could therefore differ between operating systems. Personally, I certainly would not rely on zero-initialization taking place for this function, as the CUDA API reference makes no such guarantees.

1 Like