Hacker News new | ask | show | jobs
by ohf 2954 days ago
> Yep. I bet this changes relatively soon, since you can sometimes use recursion in OpenCL & CUDA.

Am I correct in assuming you can only recurse when the recursion can be "unrolled" into a simple loop? In other words, no program flow structures.

1 comments

You can do real recursion sometimes, and real program flow. It does depend on CUDA version & chipset, but most modern ones support flow control. (https://stackoverflow.com/questions/3644809/does-cuda-suppor...)

I think there are still cases where it won’t work right due to other libraries that might be involved, I’ve had recursion fail even on a new GPU with cuda 9.

Even if you can use recursion, it’s not usually a good idea since you’ll run into thread divergence problems.