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

Wrapper class for a CUDA event. More...

#include <event.hpp>

Public Member Functions

device::id_t device_id () const noexcept
 The raw CUDA ID for the device w.r.t. which the event is defined.
 
context::handle_t context_handle () const noexcept
 The raw CUDA handle for the context in which the represented stream is defined.
 
event::handle_t handle () const noexcept
 The raw CUDA handle for this event.
 
bool is_owning () const noexcept
 True if this wrapper is responsible for telling CUDA to destroy the event upon the wrapper's own destruction.
 
bool holds_primary_context_reference () const noexcept
 True if this wrapper has been associated with an increase of the device's primary context's reference count.
 
device_t device () const
 The device w.r.t. which the event is defined.
 
context_t context () const
 The context in which this stream was defined.
 
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 () const
 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) const
 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) const
 Records the event and ensures it has occurred before returning (by synchronizing the stream). More...
 
void synchronize () const
 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 &)=delete
 
event_toperator= (event_t &&other) noexcept
 

Friends

event_t event::wrap (device::id_t device, context::handle_t context_handle, event::handle_t event_handle, bool take_ownership, bool hold_pc_refcount_unit) noexcept
 

Detailed Description

Wrapper class for a CUDA event.

Use this class - built around an event handle - 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
This class is a "reference type", not a "value type". Therefore, making changes to the event is a const-respecting operation on this class.

Member Function Documentation

◆ fire()

void cuda::event_t::fire ( const stream_t stream) const
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 ( ) const
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) const
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 file: