HIP: Heterogenous-computing Interface for Portability
Typedefs | Functions
Stream Management

Typedefs

typedef void(* hipStreamCallback_t) (hipStream_t stream, hipError_t status, void *userData)
 

Functions

hipError_t hipStreamCreate (hipStream_t *stream)
 Create an asynchronous stream. More...
 
hipError_t hipStreamCreateWithFlags (hipStream_t *stream, unsigned int flags)
 Create an asynchronous stream. More...
 
hipError_t hipStreamDestroy (hipStream_t stream)
 Destroys the specified stream. More...
 
hipError_t hipStreamQuery (hipStream_t stream)
 Return hipSuccess if all of the operations in the specified stream have completed, or hipErrorNotReady if not. More...
 
hipError_t hipStreamSynchronize (hipStream_t stream)
 Wait for all commands in stream to complete. More...
 
hipError_t hipStreamWaitEvent (hipStream_t stream, hipEvent_t event, unsigned int flags)
 Make the specified compute stream wait for an event. More...
 
hipError_t hipStreamGetFlags (hipStream_t stream, unsigned int *flags)
 Return flags associated with this stream. More...
 
hipError_t hipStreamAddCallback (hipStream_t stream, hipStreamCallback_t callback, void *userData, unsigned int flags)
 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. More...
 

Detailed Description

----------------------------------------------------------------------------------------------—

The following Stream APIs are not (yet) supported in HIP:

Typedef Documentation

typedef void(* hipStreamCallback_t) (hipStream_t stream, hipError_t status, void *userData)

Stream CallBack struct

Function Documentation

hipError_t hipStreamAddCallback ( hipStream_t  stream,
hipStreamCallback_t  callback,
void *  userData,
unsigned int  flags 
)

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.

Parameters
[in]stream- Stream to add callback to
[in]callback- The function to call once preceding stream operations are complete
[in]userData- User specified data to be passed to the callback function
[in]flags- Reserved for future use, must be 0
Returns
hipSuccess, hipErrorInvalidResourceHandle, #hipErrorNotSupported
See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamQuery, hipStreamSynchronize, hipStreamWaitEvent, hipStreamDestroy
hipError_t hipStreamCreate ( hipStream_t stream)

Create an asynchronous stream.

Parameters
[in,out]streamValid pointer to hipStream_t. This function writes the memory with the newly created stream.
Returns
hipSuccess, hipErrorInvalidValue

Create a new asynchronous stream. stream returns an opaque handle that can be used to reference the newly created stream in subsequent hipStream* commands. The stream is allocated on the heap and will remain allocated even if the handle goes out-of-scope. To release the memory used by the stream, applicaiton must call hipStreamDestroy.

Returns
hipSuccess, hipErrorInvalidValue
See also
hipStreamCreateWithFlags, hipStreamSynchronize, hipStreamWaitEvent, hipStreamDestroy
hipError_t hipStreamCreateWithFlags ( hipStream_t stream,
unsigned int  flags 
)

Create an asynchronous stream.

Parameters
[in,out]streamPointer to new stream
[in]flagsto control stream creation.
Returns
hipSuccess, hipErrorInvalidValue

Create a new asynchronous stream. stream returns an opaque handle that can be used to reference the newly created stream in subsequent hipStream* commands. The stream is allocated on the heap and will remain allocated even if the handle goes out-of-scope. To release the memory used by the stream, applicaiton must call hipStreamDestroy. Flags controls behavior of the stream. See hipStreamDefault, hipStreamNonBlocking.

See also
hipStreamCreate, hipStreamSynchronize, hipStreamWaitEvent, hipStreamDestroy
hipError_t hipStreamDestroy ( hipStream_t  stream)

Destroys the specified stream.

Parameters
[in,out]streamValid pointer to hipStream_t. This function writes the memory with the newly created stream.
Returns
hipSuccess hipErrorInvalidResourceHandle

Destroys the specified stream.

If commands are still executing on the specified stream, some may complete execution before the queue is deleted.

The queue may be destroyed while some commands are still inflight, or may wait for all commands queued to the stream before destroying it.

See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamQuery, hipStreamWaitEvent, hipStreamSynchronize
Returns
hipSuccess, hipErrorInvalidResourceHandle
hipError_t hipStreamGetFlags ( hipStream_t  stream,
unsigned int *  flags 
)

Return flags associated with this stream.

Parameters
[in]streamstream to be queried
[in,out]flagsPointer to an unsigned integer in which the stream's flags are returned
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidResourceHandle
hipSuccess hipErrorInvalidValue hipErrorInvalidResourceHandle

Return flags associated with this stream in *flags.

See also
hipStreamCreateWithFlags
hipError_t hipStreamQuery ( hipStream_t  stream)

Return hipSuccess if all of the operations in the specified stream have completed, or hipErrorNotReady if not.

Parameters
[in]streamstream to query
Returns
hipSuccess, hipErrorNotReady, hipErrorInvalidResourceHandle

This is thread-safe and returns a snapshot of the current state of the queue. However, if other host threads are sending work to the stream, the status may change immediately after the function is called. It is typically used for debug.

See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamWaitEvent, hipStreamSynchronize, hipStreamDestroy
hipError_t hipStreamSynchronize ( hipStream_t  stream)

Wait for all commands in stream to complete.

Parameters
[in]streamstream identifier.
Returns
hipSuccess, hipErrorInvalidResourceHandle

This command is host-synchronous : the host will block until the specified stream is empty.

This command follows standard null-stream semantics. Specifically, specifying the null stream will cause the command to wait for other streams on the same device to complete all pending operations.

This command honors the hipDeviceLaunchBlocking flag, which controls whether the wait is active or blocking.

See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamWaitEvent, hipStreamDestroy
hipError_t hipStreamWaitEvent ( hipStream_t  stream,
hipEvent_t  event,
unsigned int  flags 
)

Make the specified compute stream wait for an event.

Parameters
[in]streamstream to make wait.
[in]eventevent to wait on
[in]flagscontrol operation [must be 0]
Returns
hipSuccess, hipErrorInvalidResourceHandle

This function inserts a wait operation into the specified stream. All future work submitted to stream will wait until event reports completion before beginning execution.

This function only waits for commands in the current stream to complete. Notably,, this function does not impliciy wait for commands in the default stream to complete, even if the specified stream is created with hipStreamNonBlocking = 0.

See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamSynchronize, hipStreamDestroy