1

In renderscript I call a kernel like this

foo.forEach_bar(out_array);

And transfer parameters to an allocation as follows:

in_array.copyFromUnchecked(array);

I am working an a program in which I call multiple different kernels. Is it possible to overlap data transfer for a kernel with the computation of previous kernel? (i.e., while GPU works an the previous kernel, we manage to transfer the data for the next kernel)

mmotamedi144
  • 115
  • 1
  • 10

1 Answers1

0

When you work with kernels over an allocation, you can just use the output allocation of one kernel as the input one for another kernel.

When you invoke multiple kernels sequentially, you don't have to worry about them "overlapping" because theirs is not a "real" asynchronicity. They're going to be executed one after the other, so you can just reuse a previous allocation (which e.g. you used as the ouput of a kernel) to be the input of a new kernel.

Your concept of "overlapping" is not exactly correct: since allocations are stored inside RAM memory, they're not going anywhere beside there. This means that another kernel can access the same memory allocation without any need for its contents to be transferred somewhere else.

Reference: RenderScript: parallel computing on Android, the easy way

cmaster11
  • 527
  • 3
  • 6
  • There is possibly overlap due to moving the buffers between GPU and non-GPU memory. It isn't always completely shared. However, the real answer is that computation/copying are overlapped so long as the buffers are no longer in use (i.e. you can't be writing to an Allocation in a kernel at the same time that you are reading it back into Java memory with copyTo). – Stephen Hines Aug 01 '16 at 19:12
  • Thank you very much, Stephen, for the notice about the non-shared architectures. Can you make an example of mobile devices with a non-shared architecture? – cmaster11 Aug 01 '16 at 23:02
  • Unfortunately, I don't think I am allowed to. Sorry. – Stephen Hines Aug 02 '16 at 02:17