Skip to main content

Event

Struct Event 

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

A CUDA event for timing and synchronisation.

Events are lightweight markers that can be recorded into a Stream. They support two primary use-cases:

  1. Timing — measure elapsed GPU time between two recorded events via Event::elapsed_time.
  2. Synchronisation — make one stream wait for work recorded in another stream via Stream::wait_event.

Implementations§

Source§

impl Event

Source

pub fn new() -> CudaResult<Self>

Creates a new event with CU_EVENT_DEFAULT flags.

Default events record timing data. Use Event::with_flags to create events with different characteristics (e.g. disable timing for lower overhead).

§Errors

Returns a CudaError if the driver call fails.

Source

pub fn with_flags(flags: u32) -> CudaResult<Self>

Creates a new event with the specified flags.

Common flag values (from crate::ffi):

ConstantValueDescription
CU_EVENT_DEFAULT0Default (records timing)
CU_EVENT_BLOCKING_SYNC1Use blocking synchronisation
CU_EVENT_DISABLE_TIMING2Disable timing (lower overhead)
CU_EVENT_INTERPROCESS4Usable across processes

Flags can be combined with bitwise OR.

§Errors

Returns a CudaError if the flags are invalid or the driver call otherwise fails.

Source

pub fn record(&self, stream: &Stream) -> CudaResult<()>

Records this event on the given stream.

The event captures the point in the stream’s command queue at which it was recorded. Subsequent calls to Event::synchronize or Event::elapsed_time reference this recorded point.

§Errors

Returns a CudaError if the stream or event handle is invalid.

Source

pub fn query(&self) -> CudaResult<bool>

Queries whether this event has completed.

Returns Ok(true) if the event (and all preceding work in its stream) has completed, Ok(false) if it is still pending.

§Errors

Returns a CudaError if the event was not recorded or an unexpected driver error occurs (errors other than NotReady).

Source

pub fn synchronize(&self) -> CudaResult<()>

Blocks the calling thread until this event has been recorded and all preceding work in its stream has completed.

§Errors

Returns a CudaError if the event was not recorded or the driver reports an error.

Source

pub fn elapsed_time(start: &Event, end: &Event) -> CudaResult<f32>

Computes the elapsed time in milliseconds between two recorded events.

Both start and end must have been previously recorded on a stream, and end must have completed (e.g. via Event::synchronize).

§Errors

Returns a CudaError if either event has not been recorded, or if timing data is not available (e.g. the events were created with CU_EVENT_DISABLE_TIMING).

Source

pub fn raw(&self) -> CUevent

Returns the raw CUevent handle.

§Safety (caller)

The caller must not destroy or otherwise invalidate the handle while this Event is still alive.

Trait Implementations§

Source§

impl Drop for Event

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more