gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 09:53:50 28 4
gpt4 key购买 nike

或者,如果我想确保数组包含全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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com