Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
sham::EventList Class Reference

Class to manage a list of SYCL events. More...

#include <shambackends/include/shambackends/EventList.hpp>

Public Member Functions

void apply_dependency (sycl::handler &h)
 Apply all events in the list as dependancies to a SYCL command group.
 
void wait ()
 Wait for all events in the list to be finished.
 
void wait_and_throw ()
 Wait for all events in the list to be finished and throw an exception if one has occurred.
 
void add_event (sycl::event e)
 Add an event to the list of events.
 
void add_events (std::vector< sycl::event > &e)
 Add multiple events to the list of events.
 
void add_events (sham::EventList &e)
 Add all events from another EventList to this one.
 
std::string get_state ()
 Get a string representation of the EventList's state.
 
 EventList (SourceLocation loc=SourceLocation{})
 Default constructor for EventList with source location.
 
 EventList (std::initializer_list< sycl::event > e, SourceLocation loc=SourceLocation{})
 same constructor but with initializer list
 
 ~EventList () noexcept(false)
 Destructor for EventList.
 
std::vector< sycl::event > & get_events ()
 Get the list of events.
 
const std::vector< sycl::event > & get_events () const
 Get the list of events (const)
 
void set_consumed (bool consumed)
 Set the consumed state of the EventList (to be used with interop)
 

Friends

class DeviceQueue
 
class details::BufferEventHandler
 

Detailed Description

Class to manage a list of SYCL events.

Definition at line 31 of file EventList.hpp.

Constructor & Destructor Documentation

◆ EventList() [1/2]

sham::EventList::EventList ( SourceLocation  loc = SourceLocation{})
inline

Default constructor for EventList with source location.

Definition at line 134 of file EventList.hpp.

◆ EventList() [2/2]

sham::EventList::EventList ( std::initializer_list< sycl::event >  e,
SourceLocation  loc = SourceLocation{} 
)
inline

same constructor but with initializer list

Definition at line 137 of file EventList.hpp.

◆ ~EventList()

sham::EventList::~EventList ( )

Destructor for EventList.

This destructor checks if the EventList has not been consumed and still contains events. If so, it logs an error message and throws a runtime exception after waiting for all events.

Definition at line 19 of file EventList.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ add_event()

void sham::EventList::add_event ( sycl::event  e)
inline

Add an event to the list of events.

Add a SYCL event to the list of events.

Parameters
eThe SYCL event to add.

Definition at line 87 of file EventList.hpp.

◆ add_events() [1/2]

void sham::EventList::add_events ( sham::EventList e)
inline

Add all events from another EventList to this one.

Insert all events from another EventList into this one. The list is marked as not consumed after the insertion. The other list is marked as consumed after the insertion.

Parameters
eThe EventList from which to add all events.

Definition at line 114 of file EventList.hpp.

◆ add_events() [2/2]

void sham::EventList::add_events ( std::vector< sycl::event > &  e)
inline

Add multiple events to the list of events.

Inserts a list of SYCL events into the event list. The list is marked as not consumed after the insertion.

Parameters
eA reference to a vector containing the SYCL events to add.

Definition at line 100 of file EventList.hpp.

◆ apply_dependency()

void sham::EventList::apply_dependency ( sycl::handler &  h)
inline

Apply all events in the list as dependancies to a SYCL command group.

Parameters
hThe SYCL command group handler.

Example of usage:

EventList events;
<... add events ...>
sycl::queue q{};
q.submit([&](sycl::handler &h) {
events.apply_dependency(h);
// ...
});
Class to manage a list of SYCL events.
Definition EventList.hpp:31
void apply_dependency(sycl::handler &h)
Apply all events in the list as dependancies to a SYCL command group.
Definition EventList.hpp:49

Definition at line 49 of file EventList.hpp.

◆ get_events() [1/2]

std::vector< sycl::event > & sham::EventList::get_events ( )
inline

Get the list of events.

Definition at line 150 of file EventList.hpp.

◆ get_events() [2/2]

const std::vector< sycl::event > & sham::EventList::get_events ( ) const
inline

Get the list of events (const)

Definition at line 153 of file EventList.hpp.

◆ get_state()

std::string sham::EventList::get_state ( )
inline

Get a string representation of the EventList's state.

This function returns a string representation of the EventList's state, including the number of events in the list and whether the list is considered consumed.

Returns
A string representation of the EventList's state.

Definition at line 129 of file EventList.hpp.

◆ set_consumed()

void sham::EventList::set_consumed ( bool  consumed)
inline

Set the consumed state of the EventList (to be used with interop)

Definition at line 156 of file EventList.hpp.

◆ wait()

void sham::EventList::wait ( )
inline

Wait for all events in the list to be finished.

Waits for all events in the list to be finished. After calling this function, the list is considered consumed.

Definition at line 57 of file EventList.hpp.

◆ wait_and_throw()

void sham::EventList::wait_and_throw ( )
inline

Wait for all events in the list to be finished and throw an exception if one has occurred.

Waits for all events in the list to be finished. And throws an exception if one has occurred in any of the events.

Definition at line 72 of file EventList.hpp.

Friends And Related Symbol Documentation

◆ details::BufferEventHandler

friend class details::BufferEventHandler
friend

Definition at line 164 of file EventList.hpp.

◆ DeviceQueue

friend class DeviceQueue
friend

Definition at line 163 of file EventList.hpp.


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