Event Management#
Functions | |
| hipError_t | hipEventCreateWithFlags (hipEvent_t *event, unsigned flags) |
| Create an event with the specified flags. | |
| hipError_t | hipEventCreate (hipEvent_t *event) |
| hipError_t | hipEventRecordWithFlags (hipEvent_t event, hipStream_t stream, unsigned int flags) |
| Record an event in the specified stream. | |
| hipError_t | hipEventRecord (hipEvent_t event, hipStream_t stream=NULL) |
| Record an event in the specified stream. | |
| hipError_t | hipEventDestroy (hipEvent_t event) |
| Destroy the specified event. | |
| hipError_t | hipEventSynchronize (hipEvent_t event) |
| Wait for an event to complete. | |
| hipError_t | hipEventElapsedTime (float *ms, hipEvent_t start, hipEvent_t stop) |
| Return the elapsed time between two events. | |
| hipError_t | hipEventQuery (hipEvent_t event) |
| Query event status. | |
Detailed Description
This section describes the event management functions of HIP runtime API.
Function Documentation
◆ hipEventCreate()
| hipError_t hipEventCreate | ( | hipEvent_t * | event | ) |
Create an event
- Parameters
-
[out] event Returns the newly created event.
◆ hipEventCreateWithFlags()
| hipError_t hipEventCreateWithFlags | ( | hipEvent_t * | event, |
| unsigned | flags | ||
| ) |
Create an event with the specified flags.
- Parameters
-
[out] event Returns the newly created event. [in] flags Flags to control event behavior. Valid values are hipEventDefault, hipEventBlockingSync, hipEventDisableTiming, hipEventInterprocess hipEventDefault : Default flag. The event will use active synchronization and will support timing. Blocking synchronization provides lowest possible latency at the expense of dedicating a CPU to poll on the event. hipEventBlockingSync : The event will use blocking synchronization : if hipEventSynchronize is called on this event, the thread will block until the event completes. This can increase latency for the synchroniation but can result in lower power and more resources for other CPU threads. hipEventDisableTiming : Disable recording of timing information. Events created with this flag would not record profiling data and provide best performance if used for synchronization. hipEventInterprocess : The event can be used as an interprocess event. hipEventDisableTiming flag also must be set when hipEventInterprocess flag is set. hipEventDisableSystemFence : Disable acquire and release system scope fence. This may improve performance but device memory may not be visible to the host and other devices if this flag is set.
◆ hipEventDestroy()
| hipError_t hipEventDestroy | ( | hipEvent_t | event | ) |
Destroy the specified event.
- Parameters
-
[in] event Event to destroy.
hipEventDestroy returns immediately. An event may be destroyed before it is complete (i.e., before all work preceding the last hipEventRecord() has finished). Associated resources are automatically released asynchronously at completion. Any hipStreamWaitEvent() waits that were already enqueued on other streams or devices before the event is destroyed will still complete correctly when the recorded work finishes; destroying the event does not break or cancel those pending waits.
- See also
- hipEventCreate, hipEventCreateWithFlags, hipEventQuery, hipEventSynchronize, hipEventRecord, hipEventElapsedTime
- Returns
- hipSuccess
◆ hipEventElapsedTime()
| hipError_t hipEventElapsedTime | ( | float * | ms, |
| hipEvent_t | start, | ||
| hipEvent_t | stop | ||
| ) |
Return the elapsed time between two events.
- Parameters
-
[out] ms : Return time between start and stop in ms. [in] start : Start event. [in] stop : Stop event.
- Returns
- hipSuccess, hipErrorInvalidValue, hipErrorNotReady, hipErrorInvalidHandle, hipErrorNotInitialized, hipErrorLaunchFailure
Computes the elapsed time between two events. Time is computed in ms, with a resolution of approximately 1 us.
Events which are recorded in a NULL stream will block until all commands on all other streams complete execution, and then record the timestamp.
Events which are recorded in a non-NULL stream will record their timestamp when they reach the head of the specified stream, after all previous commands in that stream have completed executing. Thus the time that the event recorded may be significantly after the host calls hipEventRecord().
If hipEventRecord() has not been called on either event, then hipErrorInvalidHandle is returned. If hipEventRecord() has been called on both events, but the timestamp has not yet been recorded on one or both events (that is, hipEventQuery() would return hipErrorNotReady on at least one of the events), then hipErrorNotReady is returned.
◆ hipEventQuery()
| hipError_t hipEventQuery | ( | hipEvent_t | event | ) |
Query event status.
- Parameters
-
[in] event Event to query.
- Returns
- hipSuccess, hipErrorNotReady, hipErrorInvalidHandle, hipErrorInvalidValue, hipErrorNotInitialized, hipErrorLaunchFailure
Query the status of the specified event. This function will return hipSuccess if all commands in the appropriate stream (specified to hipEventRecord()) have completed. If any execution has not completed, then hipErrorNotReady is returned.
- Note
- This API returns hipSuccess, if hipEventRecord() is not called before this API.
◆ hipEventRecord()
| hipError_t hipEventRecord | ( | hipEvent_t | event, |
| hipStream_t | stream = NULL |
||
| ) |
Record an event in the specified stream.
- Parameters
-
[in] event event to record. [in] stream stream in which to record event.
- Returns
- hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized, hipErrorInvalidHandle, hipErrorLaunchFailure
hipEventQuery() or hipEventSynchronize() must be used to determine when the event transitions from "recording" (after hipEventRecord() is called) to "recorded" (when timestamps are set, if requested).
Events which are recorded in a non-NULL stream will transition to from recording to "recorded" state when they reach the head of the specified stream, after all previous commands in that stream have completed executing.
This function can be called multiple times on the same event and will overwrite the previously captured state. The event then refers to the new record. Any hipStreamWaitEvent() calls enqueued after this call will wait on the new record. Calls to hipStreamWaitEvent() that were already enqueued before this call are not affected and will complete when the earlier record completes.
If this function is called on an event whose previous record has not yet completed, the new record replaces the previous one. Timing data from hipEventElapsedTime() may be undefined if the previous record has not completed when this function is called.
- Note
- If this function is not called before use hipEventQuery() or hipEventSynchronize(), hipSuccess is returned, meaning no pending event in the stream.
◆ hipEventRecordWithFlags()
| hipError_t hipEventRecordWithFlags | ( | hipEvent_t | event, |
| hipStream_t | stream, | ||
| unsigned int | flags | ||
| ) |
Record an event in the specified stream.
- Parameters
-
[in] event event to record. [in] stream stream in which to record event. [in] flags parameter for operations
- Returns
- hipSuccess, hipErrorInvalidValue, hipErrorNotInitialized, hipErrorInvalidHandle, hipErrorLaunchFailure
hipEventQuery() or hipEventSynchronize() must be used to determine when the event transitions from "recording" (after hipEventRecord() is called) to "recorded" (when timestamps are set, if requested).
Events which are recorded in a non-NULL stream will transition to from recording to "recorded" state when they reach the head of the specified stream, after all previous commands in that stream have completed executing.
Flags include: hipEventRecordDefault: Default event creation flag. hipEventRecordExternal: Event is captured in the graph as an external event node when performing stream capture
This function can be called multiple times on the same event and will overwrite the previously captured state. The event then refers to the new record. Any hipStreamWaitEvent() calls enqueued after this call will wait on the new record. Calls to hipStreamWaitEvent() that were already enqueued before this call are not affected and will complete when the earlier record completes.
If this function is called on an event whose previous record has not yet completed, the new record replaces the previous one. Timing data from hipEventElapsedTime() may be undefined if the previous record has not completed when this function is called.
- Note
- : If this function is not called before use hipEventQuery() or hipEventSynchronize(), hipSuccess is returned, meaning no pending event in the stream.
◆ hipEventSynchronize()
| hipError_t hipEventSynchronize | ( | hipEvent_t | event | ) |
Wait for an event to complete.
This function will block until the event is ready, waiting for all previous work in the stream specified when event was recorded with hipEventRecord().
If hipEventRecord() has not been called on event, this function returns hipSuccess when no event is captured.
- Parameters
-
[in] event Event on which to wait.