Does CUDA support recursion?
Not according to http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?tp=&arnumber=5403843 and http://forums.nvidia.com/lofiversion/index.php?t65244.html
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.
Yes, see the NVIDIA CUDA Programming Guide:
device functions only support recursion in device code compiled for devices of compute capability 2.0.
You need a Fermi card to use them.
It does on NVIDIA hardware supporting compute capability 2.0 and CUDA 3.1:
New language features added to CUDA C / C++ include:
Support for function pointers and recursion make it easier to port many existing algorithms to Fermi GPUs
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:
__device__ int fact(int f)
{
if (f == 0)
return 1;
else
return f * fact(f - 1);
}