As far as i know, only latest Kepler GK110 supports dynamic parallelism, which allow this kind of recursive call and spawning of new threads within the kernel. Before Kepler GK110, it was not possible. And note that not all Kepler architecture supports this, only GK110 does.
If you need recursion, you probably need the Tesla K20. I'm not sure if Fermi does supports it,never read of it. :\ But Kepler sure does. =)
If your algorithm invovles alot of recursions, then support or not, it is not designed for GPUs, either redesign your algorthims or get a better CPU, either way it will be better (I bet in many cases, maginitudes better) then do recurisons on GPUs.
Yeah, it is supported on the actual version. But despite the fact it is possible to execute recursive functions, you must have in mind that the memory allocation from the execution stack cannot be predicted (the recursive function must be executed in order to know the true depth of the recursion), so your stack could result being not enough for your purposes and it could need a manual increment of the default stack size
Tried just now on my pc with a NVIDIA GPU with 1.1 Compute capability. It says recursion not yet supported. So its not got anything to do with the runtime but the hardware itself
发布评论
评论(12)
它在支持计算能力 2.0 和 CUDA 3.1 的 NVIDIA 硬件上执行:
http://developer.nvidia.com/object/cuda_3_1_downloads.html
函数指针:
http://developer.download.nvidia.com/compute /cuda/sdk/website/CUDA_Advanced_Topics.html#FunctionPointers
递归:
我在 NVIDIA 的网站上找不到代码示例,但在 论坛 上有人找到发布此内容:
It does on NVIDIA hardware supporting compute capability 2.0 and CUDA 3.1:
http://developer.nvidia.com/object/cuda_3_1_downloads.html
Function pointers:
http://developer.download.nvidia.com/compute/cuda/sdk/website/CUDA_Advanced_Topics.html#FunctionPointers
Recursion:
I can't find a code sample on NVIDIA's website, but on the forum someone post this:
是的,请参阅NVIDIA CUDA 编程指南:
您需要一张费米卡才能使用它们。
Yes, see the NVIDIA CUDA Programming Guide:
You need a Fermi card to use them.
尽管它仅支持特定芯片的递归,但有时您可以摆脱“模拟”递归:了解我如何对 CUDA 光线追踪器使用编译时递归。
Even though it only supports recursion for specific chips, you can sometimes get away with "emulated" recursion: see how I used compile-time recursion for my CUDA raytracer.
在 CUDA 4.1 版本中,CUDA 仅支持 __device__ 函数的递归,但不支持 __global__ 函数。
In CUDA 4.1 release CUDA supports recursion only for __device__ function but not for __global__ function.
仅在兼容设备上具有 2.0 计算能力之后
Only after 2.0 compute capability on compatible devices
任何递归算法都可以用堆栈和循环来实现。这更痛苦,但如果你真的需要递归,这可以工作。
Any recursive algorithm can be implemented with a stack and a loop. It's way more of a pain, but if you really need recursion, this can work.
当然可以,但它需要开普勒架构才能做到这一点。
查看他们关于经典快速排序的最新示例。
http: //blogs.nvidia.com/2012/09/how-tesla-k20-speeds-up-quicksort-a-familiar-comp-sci-code/
据我所知,只有最新的 Kepler GK110 支持动态并行性,允许这种递归调用并在内核中生成新线程。在开普勒 GK110 之前,这是不可能的。请注意,并非所有 Kepler 架构都支持此功能,只有 GK110 支持。
如果您需要递归,您可能需要 Tesla K20。
我不确定费米是否支持它,从来没有读过它。 :\
但开普勒确实如此。 =)
Sure it does, but it requires the Kepler architecture to do so.
Check out their latest example on the classic quick sort.
http://blogs.nvidia.com/2012/09/how-tesla-k20-speeds-up-quicksort-a-familiar-comp-sci-code/
As far as i know, only latest Kepler GK110 supports dynamic parallelism, which allow this kind of recursive call and spawning of new threads within the kernel. Before Kepler GK110, it was not possible. And note that not all Kepler architecture supports this, only GK110 does.
If you need recursion, you probably need the Tesla K20.
I'm not sure if Fermi does supports it,never read of it. :\
But Kepler sure does. =)
CUDA 3.1支持递归
CUDA 3.1 supports recursion
如果你的算法涉及大量递归,那么支持与否,它不是为 GPU 设计的,要么重新设计你的算法,要么获得更好的 CPU,无论哪种方式都会更好(我敢打赌,在很多情况下,幅度会更好),然后在GPU。
If your algorithm invovles alot of recursions, then support or not, it is not designed for GPUs, either redesign your algorthims or get a better CPU, either way it will be better (I bet in many cases, maginitudes better) then do recurisons on GPUs.
是的,实际版本是支持的。但是,尽管事实上可以执行递归函数,但您必须记住,执行堆栈中的内存分配是无法预测的(必须执行递归函数才能知道递归的真实深度),因此您的堆栈可能会导致不足以满足您的目的,并且可能需要手动增加默认堆栈大小
Yeah, it is supported on the actual version. But despite the fact it is possible to execute recursive functions, you must have in mind that the memory allocation from the execution stack cannot be predicted (the recursive function must be executed in order to know the true depth of the recursion), so your stack could result being not enough for your purposes and it could need a manual increment of the default stack size
是的,它确实支持递归。然而,在 GPU 上进行递归并不是一个好主意。因为每个线程都会这样做。
Yes, it does support recursion. However, it is not a good idea to do recursion on GPU. Because each thread is going to do it.
刚刚在我的电脑上尝试了具有 1.1 计算能力的 NVIDIA GPU。它说尚不支持递归。所以它与运行时没有任何关系,而是与硬件本身有关
Tried just now on my pc with a NVIDIA GPU with 1.1 Compute capability. It says recursion not yet supported. So its not got anything to do with the runtime but the hardware itself