Is it possible to call some function(device kernel) from kernel which is already running?
For example:
__global kernel1
for (i=1;i<10;i++)
call kernel2 (i)
.
.
.
.
.
. device kernel2 (i)
something doing…
So I call from host kernel 1 which iterates through ‘for’ and calls kernel2…
On a normal CPU, this is how function calls are implemented. It makes binaries much smaller, and allows for recursion.
For the GPU, the compiler instead inlines every function call. This means that a copy of the function body is inserted in every location where you call the function. You don’t have to do anything special, but you should be aware of it. Inline functions cannot be called recursively.