问题描述
有人可以清楚地解释如果从 __ device __
或 __ global __
调用新的和删除关键字的行为,代码在CUDA 4.2?
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
和 code>在设备堆内存上操作。该设备允许以这种方式分配全局(即,板上)存储器的一部分。
new
和 delete
的工作方式与。
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调用。
您可能还会对
这些功能需要CC 2.0或更高版本。
CC 2.0 or greater is required for these capabilities.
这篇关于CUDA新删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!