Skip to main content

Event

Struct Event 

Source
pub struct Event { /* private fields */ }

Implementations§

Source§

impl Event

Source

pub unsafe fn from_raw(handle: cudaEvent_t, ctx: Arc<Context>) -> Result<Self>

Wraps an existing CUDA event handle.

§Safety

handle must be a valid CUDA event owned by ctx, and ownership of the handle is transferred to the returned Event. The handle must not be destroyed elsewhere after calling this function.

Source

pub fn record(&self, stream: &Stream, flags: EventRecordFlags) -> Result<()>

Source

pub fn record_borrowed( &self, stream: &BorrowedStream, flags: EventRecordFlags, ) -> Result<()>

Source

pub fn record_on( &self, stream: &StreamBinding, flags: EventRecordFlags, ) -> Result<()>

Source

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.

Source

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.

Source

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.

Source

pub fn context(&self) -> &Context

Source

pub const fn as_raw(&self) -> cudaEvent_t

Source

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.

Source§

impl Event

Trait Implementations§

Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Event

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Event

Source§

impl Ord for Event

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Event

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Send for Event

Source§

impl Sync for Event

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.