Poplar and PopLibs
|
Interface used during stream copies to produce/consume the data being exchanged between the host and the device. More...
#include <StreamCallback.hpp>
Public Member Functions | |
virtual Result | prefetch (void *p)=0 |
Callback function to fill the host buffer (host-to-device streams only). More... | |
virtual void | fetch (void *)=0 |
Callback function to fill the host buffer. More... | |
Interface used during stream copies to produce/consume the data being exchanged between the host and the device.
The type of the data must not require metadata.
In regular stream copies, fetch() and complete() are called as a result of the device requesting the data transfer. In host-to-device streams, prefetch() may be called after the completion of the last transfer of the same stream.
|
pure virtual |
Callback function to fill the host buffer.
This function is called as a result of a stream copy, unless the last prefetch() invocation was successful.
It must always fill the buffer with more data and it is followed by a call to complete().
|
pure virtual |
Callback function to fill the host buffer (host-to-device streams only).
This function is called speculatively, this means it might still be called even if no additional copies for this stream exist for the remaining execution of the program.
The following situations are possible during the invocation:
The return value indicates if the invocation resulted in the buffer being successfully filled. In the first case (A), the function shall return Result::Success
. A call to complete() will follow if the program ends up transferring the data. Otherwise (scenarios B and C), it must return Result::NotAvailable
. Calls to fetch() and then complete() will follow if the transfer takes place.
Note that when using a buffered data stream (see Graph::addHostToDeviceFIFO(), bufferingDepth
option) there can be multiple calls to prefetch() before a corresponding complete() is called. In some circumstances prefetched data is invalidated and not read, and therefore will have no corresponding complete(), this is notified with invalidatePrefetched().
p | Location of the buffer. It will only be valid for the duration of the function. |
Result::Success
if the function was able to fill the buffer with data, or Result::NotAvailable
otherwise. Implemented in poplar::LegacyStreamCallback.