No recursion, No function pointer, Inline function Why??! that's crazy talk!

I know that cuda wont allow recursion, function pointer, nor non-inline device functions. For this project that i am working on, that made me do a lot more work.

So my question is, Whyyyyyyyyy?? arent’ cuda supposed to be aiming for general purpose computing?

I want recursions, function pointers, and non-inline functions!!! :devil:

This is no longer true in the CUDA 1.1 toolkit. See the noinline modifier in the programming guide (section 4.2.5).

Nevertheless, CUDA is not designed for general purpose computing. It is designed for data-parallel computing. Minimal branching and function inlining are good optimizations for that scenario, so it is a reasonable assumption to make for a first pass at the tools. Now that limit has been lifted, but proceed with caution. :)

Edit: I realize this only answers part of your question. I assume that with noinline recursion is possible. I have no idea if function pointers are supported…

‘no inlining’ doesn’t means recursive functions are supported. There’s no stack; you can’t do recursion (or any of the other things that the original poster wanted) without one.

The compiler depends on having a call graph that can be predicted entirely in advance so that locals can be assigned to registers. Off-chip memory is too slow, and on-chip memory is too small to have a traditional ‘stack per thread’ (even a small one).

seibert is otherwise completely correct. It’s better to learn data-parallel programming from scratch than to imagine that you can just port your existing C code across. Those of us who came to CUDA via GPGPU on GLSL/HLSL have very different impressions about CUDA’s ‘ease of use’ and generality, incidentally.

if you want to do recursive used CUDA,may be that you should execute more times the kernel which the output data of previous as input of current as shader recursive through by FBO