cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Fuxianjun
Journeyman III

About recursion

Can kernel call itself ?

On section 6.8 of OpenCL specification, it says "Recursion is not supported.".Dose it means kernel can not call itself? If so, how to  implement the logic like recursion. For example, calculate a square matrix's 10000-th power.

0 Likes
3 Replies
LeeHowes
Staff

Convert it to a loop and build your own stack in private memory?

0 Likes

All functions run on the device in OpenCL are inlined at compile time and cannot call themselves. You can recurse on the CPU and call GPU kernels during each CPU call. For your example, you don't even want to use matrix multiply to compute A^k where A is mxn. You should create an eigenvalue decomposition, compute the powers on the eigenvalues, and recombine the eigenvector matrices.

0 Likes

How?Please teach me in detail, thanks !

0 Likes