Stream management#
-
typedef void (*hipStreamCallback_t)(hipStream_t stream, hipError_t status, void *userData)#
Stream CallBack struct
-
hipError_t hipStreamCreate(hipStream_t *stream)#
Creates an asynchronous stream.
Creates a new asynchronous stream with its associated current device. The
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, the application must call hipStreamDestroy.See also
hipStreamCreateWithFlags, hipStreamCreateWithPriority, hipStreamSynchronize, hipStreamWaitEvent, hipStreamDestroy
- Parameters:
stream – [inout] Valid pointer to hipStream_t. This function writes the memory with the newly created stream.
- Returns:
hipSuccess, hipErrorInvalidValue
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipStreamCreateWithFlags(hipStream_t *stream, unsigned int flags)#
Creates an asynchronous stream with flag.
Creates a new asynchronous stream with its associated current device.
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, application must call hipStreamDestroy.The
flags
parameter controls behavior of the stream. The valid values are hipStreamDefault and hipStreamNonBlocking.See also
hipStreamCreate, hipStreamCreateWithPriority, hipStreamSynchronize, hipStreamWaitEvent, hipStreamDestroy.
- Parameters:
stream – [inout] Pointer to new stream
flags – [in] Parameters to control stream creation
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipStreamCreateWithPriority(hipStream_t *stream, unsigned int flags, int priority)#
Creates an asynchronous stream with the specified priority.
Creates a new asynchronous stream with the specified priority, with its associated current device.
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, application must call hipStreamDestroy.The
flags
parameter controls behavior of the stream. The valid values are hipStreamDefault and hipStreamNonBlocking.- Parameters:
stream – [inout] Pointer to new stream
flags – [in] Parameters to control stream creation
priority – [in] Priority of the stream. Lower numbers represent higher priorities.
- Returns:
hipSuccess, hipErrorInvalidValue
-
hipError_t hipDeviceGetStreamPriorityRange(int *leastPriority, int *greatestPriority)#
Returns numerical values that correspond to the least and greatest stream priority.
Returns in *leastPriority and *greatestPriority the numerical values that correspond to the least and greatest stream priority respectively. Stream priorities follow a convention where lower numbers imply greater priorities. The range of meaningful stream priorities is given by [*leastPriority,*greatestPriority]. If the user attempts to create a stream with a priority value that is outside the meaningful range as specified by this API, the priority is automatically clamped to within the valid range.
Warning
This API is under development on AMD GPUs and simply returns hipSuccess.
- Parameters:
leastPriority – [inout] Pointer in which a value corresponding to least priority is returned.
greatestPriority – [inout] Pointer in which a value corresponding to greatest priority is returned.
- Returns:
hipSuccess
-
hipError_t hipStreamDestroy(hipStream_t stream)#
Destroys the specified stream.
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, hipStreamCreateWithPriority, hipStreamQuery, hipStreamWaitEvent, hipStreamSynchronize
- Parameters:
stream – [in] Stream identifier
- Returns:
hipSuccess hipErrorInvalidHandle
-
hipError_t hipStreamQuery(hipStream_t stream)#
Returns hipSuccess if all of the operations in the specified
stream
have completed, or hipErrorNotReady if not.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, hipStreamCreateWithPriority, hipStreamWaitEvent, hipStreamSynchronize, hipStreamDestroy
- Parameters:
stream – [in] Stream to query
- Returns:
hipSuccess, hipErrorNotReady, hipErrorInvalidHandle
-
hipError_t hipStreamSynchronize(hipStream_t stream)#
Waits for all commands in the stream to complete.
This command is host-synchronous : the host will block until all operations on the specified stream with its associated device are completed. On multiple device systems, the
stream
is associated with its device, no need to call hipSetDevice before this API.This command follows standard null-stream semantics. 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 hipDeviceScheduleBlockingSync flag, which controls whether the wait is active or blocking.
See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamCreateWithPriority, hipStreamWaitEvent, hipStreamDestroy
- Parameters:
stream – [in] Stream identifier.
- Returns:
hipSuccess, hipErrorInvalidHandle
-
hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags)#
Makes the specified compute stream wait for the specified event.
This function inserts a wait operation into the specified stream. All future work submitted to
stream
will wait untilevent
reports completion before beginning execution.This function only waits for commands in the current stream to complete. Notably, this function does not implicitly wait for commands in the default stream to complete, even if the specified stream is created with hipStreamNonBlocking = 0.
See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamCreateWithPriority, hipStreamSynchronize, hipStreamDestroy
- Parameters:
stream – [in] Stream to make wait
event – [in] Event to wait on
flags – [in] Parameters to control the operation [must be 0]
- Returns:
hipSuccess, hipErrorInvalidHandle
-
hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int *flags)#
Returns flags associated with this stream.
See also
- Parameters:
stream – [in] Stream to be queried
flags – [inout] Pointer to an unsigned integer in which the stream’s flags are returned
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidHandle.
-
hipError_t hipStreamGetId(hipStream_t stream, unsigned long long *streamId)#
Queries the Id of a stream.
See also
hipStreamCreateWithFlags, hipStreamGetFlags, hipStreamCreateWithPriority, hipStreamGetPriority
- Parameters:
stream – [in] Stream to be queried
flags – [inout] Pointer to an unsigned long long in which the stream’s id is returned
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidHandle.
-
hipError_t hipStreamGetPriority(hipStream_t stream, int *priority)#
Queries the priority of a stream.
See also
- Parameters:
stream – [in] Stream to be queried
priority – [inout] Pointer to an unsigned integer in which the stream’s priority is returned
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidHandle.
-
hipError_t hipStreamGetDevice(hipStream_t stream, hipDevice_t *device)#
Gets the device associated with the stream.
- Parameters:
stream – [in] Stream to be queried
device – [out] Device associated with the stream
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorContextIsDestroyed, hipErrorInvalidHandle, hipErrorNotInitialized, hipErrorDeinitialized, hipErrorInvalidContext
-
hipError_t hipExtStreamCreateWithCUMask(hipStream_t *stream, uint32_t cuMaskSize, const uint32_t *cuMask)#
Creates an asynchronous stream with the specified CU mask.
Creates a new asynchronous stream with the specified CU mask.
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, application must call hipStreamDestroy.- Parameters:
stream – [inout] Pointer to new stream
cuMaskSize – [in] Size of CU mask bit array passed in.
cuMask – [in] Bit-vector representing the CU mask. Each active bit represents using one CU. The first 32 bits represent the first 32 CUs, and so on. If its size is greater than physical CU number (i.e., multiProcessorCount member of hipDeviceProp_t), the extra elements are ignored. It is user’s responsibility to make sure the input is meaningful.
- Returns:
hipSuccess, hipErrorInvalidHandle, hipErrorInvalidValue
-
hipError_t hipExtStreamGetCUMask(hipStream_t stream, uint32_t cuMaskSize, uint32_t *cuMask)#
Gets CU mask associated with an asynchronous stream.
- Parameters:
stream – [in] Stream to be queried
cuMaskSize – [in] Number of the block of memories (uint32_t *) allocated by user
cuMask – [out] Pointer to a pre-allocated block of memories (uint32_t *) in which the stream’s CU mask is returned. The CU mask is returned in a chunck of 32 bits where each active bit represents one active CU.
- Returns:
hipSuccess, hipErrorInvalidHandle, hipErrorInvalidValue
-
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 hipStreamAddCallback call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished.
See also
hipStreamCreate, hipStreamCreateWithFlags, hipStreamQuery, hipStreamSynchronize, hipStreamWaitEvent, hipStreamDestroy, hipStreamCreateWithPriority
- Parameters:
stream – [in] - Stream to add callback to
callback – [in] - The function to call once preceding stream operations are complete
userData – [in] - User specified data to be passed to the callback function
flags – [in] - Reserved for future use, must be 0
- Returns:
hipSuccess, hipErrorInvalidHandle, hipErrorNotSupported
-
hipError_t hipStreamSetAttribute(hipStream_t stream, hipStreamAttrID attr, const hipStreamAttrValue *value)#
Sets stream attribute. Updated attribute is applied to work submitted to the stream.
- Parameters:
stream – [in] - Stream to set attributes to
attr – [in] - Attribute ID for the attribute to set
value – [in] - Attribute value for the attribute to set
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidResourceHandle
-
hipError_t hipStreamGetAttribute(hipStream_t stream, hipStreamAttrID attr, hipStreamAttrValue *value_out)#
queries stream attribute.
- Parameters:
stream – [in] - Stream to geet attributes from
attr – [in] - Attribute ID for the attribute to query
value – [out] - Attribute value output
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidResourceHandle