c++ - cudaMalloc()是否将数组初始化为0?

标签 c++ c cuda malloc memset

或者,如果我想确保数组包含全0,是否需要执行cudaMemset()?我在文档中找不到它。
谢谢。

最佳答案

cudaMalloc documentation说:

Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The allocated memory is suitably aligned for any kind of variable. The memory is not cleared.



因此,您将需要cudaMemset来初始化内存。

关于c++ - cudaMalloc()是否将数组初始化为0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62055890/

相关文章:

c++ - 无法更改 CMake 中的默认链接器

c - 加权随机数生成

c - C 中的辛普森法则 - 错误答案

c - fwrite 似乎工作,memcpy 失败

opengl - 深度组件的 Cuda 渲染缓冲区互操作

c++ - 结构、CUDA C/C++ 和 VS 2008 的问题

cuda - cuda-gdb需要root权限吗?

C++虚函数重新实现

C++ 动态数组 "losing"数据

c++ - LAPACK 函数在第一次迭代后变慢