Keep data on device / fetch interim results from device

Hello folks!

A kernel calculates numerical solutions for differential equations. Now I need to store the results only for certain timesteps. What I want to do is to fetch interim results while the kernel does the calculations. To do so, I’m thinking of a kernel which can stop after a given amount of timesteps, transfer data to host and then fetch new data from host (each time only a few constants) and proceed where it stopped, until another given amount of timesteps elapsed.

Of course I could move ALL data from kernel to host, save interesting data, add a few constants and move ALL data from host to device and run the kernel and so on. But this would cost a lot of unnecessary time, as the interesting data is less than one percent of the data which has to be moved between host and devide.

I hope you understand my concern. I guess this should be possible in opencl, isn’t it? How to do it?

Thank you!

The only synchronisation points possible is at kernel invocation boundaries.

i.e. you have to call the kernel multiple times and read out in between.

If you’re only reading data back to monitor it you only need to read what you’re after, you don’t need to copy the whole data buffer back; and it all stays on the device anyway.

You can use event callbacks or threads to avoid having to make this synchronous.