|
Celeritas 0.7.0-22+develop.9704a67c5
|
Host copy of a single value that is updated asynchronously from a stream. More...
#include <AsyncSnapshot.hh>
Public Member Functions | |
| AsyncSnapshot (T const &value={}) | |
| Construct with an initial host value. | |
| void | load_async (ObserverPtr< T const, MemSpace::host > src, StreamId) |
| Load a single value from host memory. | |
| void | load_async (ObserverPtr< T const, MemSpace::device > src, StreamId stream) |
| Enqueue a load of a single value from device memory. | |
| bool | ready () const |
| Whether the most recent load has completed. | |
| void | sync () const |
| Block the host until the most recent load has completed. | |
| void | assign (T const &value) |
| Overwrite the host value. | |
| T const & | value () const |
| Access the most recently loaded value. | |
| T const & | wait () const |
| Wait for the most recent load and access its value. | |
Host copy of a single value that is updated asynchronously from a stream.
The value is stored in pinned host memory so that a device-to-host copy enqueued with load_async does not block the host. Each device load records an event on its stream after the copy: ready queries it without blocking and sync waits for it. Because the copy is ordered after the work previously enqueued on that stream, completion of the load also implies completion of that work. A load from host memory completes immediately.
The loaded value must not be read or overwritten until the load has completed, which is checked when CELERITAS_DEBUG is enabled.
|
inlineexplicit |
Construct with an initial host value.
If a device is active, the storage is pinned and the completion event is created. A snapshot that loads from device memory must therefore be constructed after the device is activated.
Overwrite the host value.
The most recent load must have completed.
|
inline |
Enqueue a load of a single value from device memory.
The copy is enqueued on the given stream, followed by the completion event.
|
inline |
Load a single value from host memory.
The load completes immediately. The stream is accepted so that code templated on the memory space can call either overload.
Access the most recently loaded value.
The most recent load must have completed: call sync or check ready first, or use wait instead.
Wait for the most recent load and access its value.
This blocks the host until the load completes.