[−][src]Struct rustacuda::event::Event
An event to track work submitted to a stream.
See the module-level documentation for more information.
Implementations
impl Event
[src]
pub fn new(flags: EventFlags) -> CudaResult<Self>
[src]
Create a new event with the specified flags.
Example
use rustacuda::event::{Event, EventFlags}; // With default settings let event = Event::new(EventFlags::DEFAULT)?;
pub fn record(&self, stream: &Stream) -> CudaResult<()>
[src]
Add the event to the given stream of work. The event will be completed when the stream completes all previously-submitted work and reaches the event in the queue.
This function is used together with query
, synchronize
, and
elapsed_time_f32
. See the respective functions for more information.
If the event is created with EventFlags::BLOCKING_SYNC
, then record
blocks until the event has actually been recorded.
Errors
If the event and stream are not from the same context, an error is returned.
Example
use rustacuda::event::{Event, EventFlags}; let stream = Stream::new(StreamFlags::NON_BLOCKING, None)?; let event = Event::new(EventFlags::DEFAULT)?; // submit some work ... event.record(&stream)?; }
pub fn query(&self) -> CudaResult<EventStatus>
[src]
Return whether the stream this event was recorded on (see record
) has processed this event
yet or not. A return value of EventStatus::Ready
indicates that all work submitted before
the event has been completed.
Example
use rustacuda::event::{Event, EventFlags, EventStatus}; let stream = Stream::new(StreamFlags::NON_BLOCKING, None)?; let event = Event::new(EventFlags::DEFAULT)?; // do some work ... // record an event event.record(&stream)?; // ... wait some time ... // query if the work is finished let status = event.query()?; assert_eq!(status, EventStatus::Ready); }
pub fn synchronize(&self) -> CudaResult<()>
[src]
Wait for an event to complete.
Blocks thread execution until all work submitted before the event was
recorded has completed. EventFlags::BLOCKING_SYNC
controls the mode of
blocking. If the flag is set on event creation, the thread will sleep.
Otherwise, the thread will busy-wait.
Example
use rustacuda::event::{Event, EventFlags}; let stream = Stream::new(StreamFlags::NON_BLOCKING, None)?; let event = Event::new(EventFlags::DEFAULT)?; // do some work ... // record an event event.record(&stream)?; // wait until the work is finished event.synchronize()?; }
pub fn elapsed_time_f32(&self, start: &Self) -> CudaResult<f32>
[src]
Return the duration between two events.
The duration is computed in milliseconds with a resolution of approximately 0.5 microseconds. This can be used to measure the duration of work queued in between the two events.
Errors
CudaError::NotReady
is returned if either event is not yet complete.
CudaError::InvalidHandle
is returned if
- the two events are not from the same context, or if
record
has not been called on either event, or if- the
DISABLE_TIMING
flag is set on either event.
Example
use rustacuda::event::{Event, EventFlags}; let stream = Stream::new(StreamFlags::NON_BLOCKING, None)?; let start_event = Event::new(EventFlags::DEFAULT)?; let stop_event = Event::new(EventFlags::DEFAULT)?; // start recording time start_event.record(&stream)?; // do some work ... // stop recording time stop_event.record(&stream)?; // wait for the work to complete stop_event.synchronize()?; // compute the time elapsed between the start and stop events let time = stop_event.elapsed_time_f32(&start_event)?; }
pub fn drop(event: Event) -> DropResult<Event>
[src]
Destroy an Event
returning an error.
Destroying an event can return errors from previous asynchronous work. This function destroys the given event and returns the error and the un-destroyed event on failure.
Example
use rustacuda::event::{Event, EventFlags}; let event = Event::new(EventFlags::DEFAULT)?; match Event::drop(event) { Ok(()) => println!("Successfully destroyed"), Err((cuda_error, event)) => { println!("Failed to destroy event: {:?}", cuda_error); // Do something with event }, }
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Event
impl !Send for Event
impl !Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,