pub unsafe extern "C" fn cudaStreamAddCallback(
stream: cudaStream_t,
callback: cudaStreamCallback_t,
userData: *mut c_void,
flags: c_uint,
) -> cudaError_tExpand description
Add a callback to a compute stream.
Adds a callback to be called on the host after all currently enqueued items in the stream have completed. For each cudaStreamAddCallback call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished.
The callback may be passed cudaSuccess or an error code. In the event of a device error, all subsequently executed callbacks will receive an appropriate cudaError_t.
Callbacks must not make any CUDA API calls. Attempting to use CUDA APIs may result in cudaErrorNotPermitted. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized.
For the purposes of Unified Memory, callback execution makes a number of guarantees.
ยงParameters
stream: Stream to add callback to.callback: The function to call once preceding stream operations are complete.userData: User specified data to be passed to the callback function.flags: Reserved for future use, must be 0.