OpenCL - iterative update of a resident GPU buffer?

I need the OpenCL kernel to iteratively update the buffer and return the results. To clarify:

  • Send source buffer to kernel content
  • Kernel / worker updates every item in the buffer
  • The host code reads the results. HOPEFULLY asynchronously, although I'm not sure how to do this without blocking the kernel.
  • The kernel starts again, updating each element again, but the new value depends on the previous value.
  • Repeat for some fixed number of iterations.

So far, I have been able to fake this by providing an input and output buffer, copying the output back to the input when the kernel finishes execution, and restarting the kernel. This seems like a huge waste of time and abuse of limited memory bandwidth, as the buffer is quite large (~ 1 GB).

Any suggestions / examples? I am new to OpenCL, so this may have a very simple answer.

If that matters, I use Cloo / OpenCL.NET for the NVidia GTX460 and two GTX295s.

+3
source share
2 answers

You can write your source data to the device and change its contents using the kernel. Once the kernel finishes its iteration, you can read the same memory buffer and restart the kernel for your next iteration. Data may remain on the OpenCL device. There is no need to send it again to the device.

, . . . , .

+2

cl_mem . . . , , .

cl_mem . .

, . , usign- OUT_OF_ORDER_QUEUE. , ​​ .

+3

All Articles