pub struct Event { /* private fields */ }Implementations§
Source§impl Event
impl Event
pub fn record(&self, stream: &Stream, flags: EventRecordFlags) -> Result<()>
pub fn record_borrowed( &self, stream: &BorrowedStream, flags: EventRecordFlags, ) -> Result<()>
pub fn record_on( &self, stream: &StreamBinding, flags: EventRecordFlags, ) -> Result<()>
Sourcepub fn query(&self) -> Result<bool>
pub fn query(&self) -> Result<bool>
Queries the status of all work currently captured by event.
See sys::cudaEventRecord for details on what is captured by an event.
Returns true if all captured work has been completed, or false if any captured work is incomplete.
For the purposes of Unified Memory, a return value of true is equivalent to having called Event::synchronize.
§Errors
Returns an error if CUDA cannot query the event. CUDA may also report
errors from previous asynchronous launches, internal runtime
initialization errors such as crate::error::Status::NotInitialized,
crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice, and
callback diagnostics such as crate::error::Status::NotPermitted.
Sourcepub fn synchronize(&self) -> Result<()>
pub fn synchronize(&self) -> Result<()>
Waits until the completion of all work currently captured in event.
See sys::cudaEventRecord for details on what is captured by an event.
Waiting for an event created with EventFlags::BLOCKING_SYNC causes the calling CPU thread to block until the event has been completed by the device.
Without EventFlags::BLOCKING_SYNC, the CPU thread will busy-wait until the event has been completed by the device.
§Errors
Returns an error if CUDA cannot wait for the event. CUDA may also report
errors from previous asynchronous launches, internal runtime
initialization errors such as crate::error::Status::NotInitialized,
crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice, and
callback diagnostics such as crate::error::Status::NotPermitted.
Sourcepub fn elapsed_time_since(&self, start: &Event) -> Result<f32>
pub fn elapsed_time_since(&self, start: &Event) -> Result<f32>
Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds).
Note this call is not guaranteed to return the latest errors for pending work.
Use it only for elapsed-time calculation; poll for completion on the events to be compared with Event::query instead.
If either event was last recorded in a non-default stream, the resulting time may be greater than expected, even if both used the same stream handle.
This happens because the sys::cudaEventRecord operation takes place asynchronously and there is no guarantee that the measured latency is actually just between the two events.
Any number of other different stream operations could execute in between the two measured events, thus altering the timing in a significant way.
If sys::cudaEventRecord has not been called on either event, then crate::error::Status::InvalidHandle is returned.
If sys::cudaEventRecord has been called on both events but one or both of them has not yet been completed (that is, Event::query would return crate::error::Status::NotReady on at least one of the events), crate::error::Status::NotReady is returned.
If either event was created with EventFlags::DISABLE_TIMING, this returns crate::error::Status::InvalidHandle.
§Errors
Returns an error if the events belong to different contexts, either
event has not been recorded, either event is incomplete, timing was
disabled on either event, or CUDA rejects the elapsed-time query. CUDA
may also report errors from previous asynchronous launches, internal
runtime initialization errors such as crate::error::Status::NotInitialized,
crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice, and
callback diagnostics such as crate::error::Status::NotPermitted.
pub fn context(&self) -> &Context
pub const fn as_raw(&self) -> cudaEvent_t
Sourcepub fn into_raw(self) -> cudaEvent_t
pub fn into_raw(self) -> cudaEvent_t
Consumes the event and returns the raw CUDA event handle without destroying it.
The caller becomes responsible for eventually destroying the returned handle with CUDA.