Event Management

hipEventCreateWithFlags

hipError_t hipEventCreateWithFlags(hipEvent_t *event, unsigned flags)

Create an event with the specified flags.

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 eevent. 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. On ROCM platform, timing information is always recorded and this flag has no performance benefit.

Parameters
  • [inout] event: Returns the newly created event.

  • [in] flags: Flags to control event behavior. Valid values are hipEventDefault, hipEventBlockingSync, hipEventDisableTiming, hipEventInterprocess

Warning

On HCC platform, hipEventInterprocess support is under development. Use of this flag will return an error.

Return

#hipSuccess, #hipErrorInitializationError, #hipErrorInvalidValue, #hipErrorLaunchFailure, #hipErrorMemoryAllocation

See

hipEventCreate, hipEventSynchronize, hipEventDestroy, hipEventElapsedTime

hipEventCreate

hipError_t hipEventCreate(hipEvent_t *event)

Create an event.

Return

#hipSuccess, #hipErrorInitializationError, #hipErrorInvalidValue, #hipErrorLaunchFailure, #hipErrorMemoryAllocation

See

hipEventCreateWithFlags, hipEventRecord, hipEventQuery, hipEventSynchronize, hipEventDestroy, hipEventElapsedTime

Parameters
  • [inout] event: Returns the newly created event.

hipEventRecord

hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream)

Record an event in the specified stream.

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).

Return

#hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError, #hipErrorInvalidResourceHandle, #hipErrorLaunchFailure

Parameters
  • [in] event: event to record.

  • [in] stream: stream in which to record event.

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.

If hipEventRecord() has been previously called on this event, then this call will overwrite any existing state in event.

If this function is called on a an event that is currently being recorded, results are undefined

  • either outstanding recording may save state into the event, and the order is not guaranteed.

See

hipEventCreate, hipEventCreateWithFlags, hipEventQuery, hipEventSynchronize, hipEventDestroy, hipEventElapsedTime

hipEventDestroy

hipError_t hipEventDestroy(hipEvent_t event)

Destroy the specified event.

Releases memory associated with the event. If the event is recording but has not completed recording when

hipEventDestroy() is called, the function will return immediately and the completion_future resources will be released later, when the hipDevice is synchronized.
Return

#hipSuccess, #hipErrorInitializationError, #hipErrorInvalidValue, #hipErrorLaunchFailure

Parameters
  • [in] event: Event to destroy.

See

hipEventCreate, hipEventCreateWithFlags, hipEventQuery, hipEventSynchronize, hipEventRecord, hipEventElapsedTime

Return

#hipSuccess

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 immediately.

TODO-hcc - This function needs to support hipEventBlockingSync parameter.

Return

#hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError, #hipErrorInvalidResourceHandle, #hipErrorLaunchFailure

See

hipEventCreate, hipEventCreateWithFlags, hipEventQuery, hipEventDestroy, hipEventRecord, hipEventElapsedTime

Parameters
  • [in] event: Event on which to wait.

hipEventElapsedTime

hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop)

Return the elapsed time between two events.

Computes the elapsed time between two events. Time is computed in ms, with a resolution of approximately 1 us.

Return

#hipSuccess, #hipErrorInvalidValue, #hipErrorNotReady, #hipErrorInvalidResourceHandle, #hipErrorInitializationError, #hipErrorLaunchFailure

Parameters
  • [out] ms: : Return time between start and stop in ms.

  • [in] start: : Start event.

  • [in] stop: : Stop event.

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 #hipErrorInvalidResourceHandle 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.

See

hipEventCreate, hipEventCreateWithFlags, hipEventQuery, hipEventDestroy, hipEventRecord, hipEventSynchronize

hipEventQuery S

hipError_t hipEventQuery(hipEvent_t event)

Query event status.

Query the status of the specified event. This function will return #hipErrorNotReady if all commands in the appropriate stream (specified to

hipEventRecord()) have completed. If that work has not completed, or if hipEventRecord() was not called on the event, then #hipSuccess is returned.
Return

#hipSuccess, #hipErrorNotReady, #hipErrorInvalidResourceHandle, #hipErrorInvalidValue, #hipErrorInitializationError, #hipErrorLaunchFailure

Parameters
  • [in] event: Event to query.

See

hipEventCreate, hipEventCreateWithFlags, hipEventRecord, hipEventDestroy, hipEventSynchronize, hipEventElapsedTime