CUDA 新删除 [英] CUDA new delete
问题描述
如果从 CUDA 4.2 中的 __device__
或 __global__
代码调用 new 和 delete 关键字的行为,有人能给出清楚的解释吗?
Can someone give a clear explanation of how the new and delete keywords would behave if called from __device__
or __global__
code in CUDA 4.2?
内存在哪里分配,如果它在设备上是本地的还是全局的?
Where does the memory get allocated, if its on the device is it local or global?
我试图在 GPU 上创建神经网络的问题的上下文,我想要一个链接表示(就像一个链接列表,但每个神经元都存储一个链接的链接列表,其中包含权重和指向另一个的指针神经元),我知道我可以在内核启动之前使用 cudaMalloc
进行分配,但我希望内核控制网络的创建方式和时间.
It terms of context of the problem I am trying to create neural networks on the GPU, I want a linked representation (Like a linked list, but each neuron stores a linked list of connections that hold weights, and pointers to the other neurons), I know I could allocate using cudaMalloc
before the kernel launch but I want the kernel to control how and when the networks are created.
谢谢!
推荐答案
C++ new
和 delete
对设备堆内存进行操作.该设备允许以这种方式分配一部分全局(即板载)内存.new
和 delete
的工作方式类似于 设备 malloc
和 free
.
C++ new
and delete
operate on device heap memory. The device allows for a portion of the global (i.e. on-board) memory to be allocated in this fashion. new
and delete
work in a similar fashion to device malloc
and free
.
您可以使用 运行时 API 调用.
您可能还对 C++ new/delete 示例代码感兴趣.
这些功能需要 CC 2.0 或更高版本.
CC 2.0 or greater is required for these capabilities.
这篇关于CUDA 新删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!