cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
Public Member Functions | List of all members
cuda::event_t Class Reference

Proxy class for a CUDA event. More...

#include <event.hpp>

Public Member Functions

event::id_t id () const noexcept
 The CUDA runtime API ID this object is wrapping.
 
device::id_t device_id () const noexcept
 The device with which this event is associated (i.e. More...
 
device_t device () const noexcept
 
bool is_owning () const noexcept
 Is this wrapper responsible for having the CUDA Runtime API destroy the event when it destructs?
 
bool has_occurred () const
 Has this event already occurred, or is it still pending on a stream? More...
 
bool query () const
 An alias for {event_t::has_occurred()} - to conform to how the CUDA runtime API names this functionality.
 
void record ()
 Schedule a specified event to occur (= to fire) when all activities already scheduled on the event's device's default stream have concluded. More...
 
void record (const stream_t &stream)
 Schedule a specified event to occur (= to fire) when all activities already scheduled on the stream have concluded. More...
 
void fire (const stream_t &stream)
 Records the event and ensures it has occurred before returning (by synchronizing the stream). More...
 
void synchronize ()
 Have the calling thread wait - either busy-waiting or blocking - and return only after this event has occurred (see has_occurred() ).
 
 event_t (const event_t &other) noexcept
 
 event_t (event_t &&other) noexcept
 
event_toperator= (const event_t &other)=delete
 
event_toperator= (event_t &&other)=delete
 

Detailed Description

Proxy class for a CUDA event.

Use this class - built around an event id - to perform almost, if not all, event-related operations the CUDA Runtime API is capable of.

Note
By default this class has RAII semantics, i.e. it has the runtime create an event on construction and destroy it on destruction, and isn't merely an ephemeral wrapper one could apply and discard; but this second kind of semantics is also (sort of) supported, through the event_t::owning field.
this is one of the three main classes in the Runtime API wrapper library, together with cuda::device_t and cuda::stream_t

Member Function Documentation

◆ device_id()

device::id_t cuda::event_t::device_id ( ) const
inlinenoexcept

The device with which this event is associated (i.e.

on whose stream this event can be enqueued)

◆ fire()

void cuda::event_t::fire ( const stream_t stream)
inline

Records the event and ensures it has occurred before returning (by synchronizing the stream).

Note
No protection against repeated calls.

◆ has_occurred()

bool cuda::event_t::has_occurred ( ) const
inline

Has this event already occurred, or is it still pending on a stream?

Note
an event can occur multiple times, but in the context of this method, it only has two states: pending (on a stream) and has_occured.
Returns
if all work on the stream with which the event was recorded has been completed, returns true; if there is pending work on that stream before the point of recording, returns false; if the event has not been recorded at all, returns true.

◆ record() [1/2]

void cuda::event_t::record ( )
inline

Schedule a specified event to occur (= to fire) when all activities already scheduled on the event's device's default stream have concluded.

Note
No protection against repeated calls.

◆ record() [2/2]

void cuda::event_t::record ( const stream_t stream)
inline

Schedule a specified event to occur (= to fire) when all activities already scheduled on the stream have concluded.

Note
No protection against repeated calls.

The documentation for this class was generated from the following files: