Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
sham::details::BufferEventHandler Class Reference

Class that manages the event state of a SYCL USM buffer. More...

#include <shambackends/include/shambackends/details/BufferEventHandler.hpp>

+ Collaboration diagram for sham::details::BufferEventHandler:

Public Types

enum  last_op { READ , WRITE }
 Enum to represent the last operation performed on the buffer. More...
 

Public Member Functions

void wait_all (SourceLocation src_loc=SourceLocation{})
 Wait for all the buffer accesses to be completed.
 
bool is_empty ()
 Check if there if the events lists are empty.
 
void read_access (sham::EventList &depends_list, SourceLocation src_loc=SourceLocation{})
 Adds events conditioning the validity of a buffer for read access to the dependency list. Also sets the event handler to incomplete state (up_to_date_events = false).
 
void write_access (sham::EventList &depends_list, SourceLocation src_loc=SourceLocation{})
 Adds events conditioning the validity of a buffer for write access to the dependency list. Also sets the event handler to incomplete state (up_to_date_events = false).
 
void complete_state (sycl::event e, SourceLocation src_loc=SourceLocation{})
 Completes the state of the buffer event handler with the event for which the access was queried.
 
void complete_state (const std::vector< sycl::event > &events, SourceLocation src_loc=SourceLocation{})
 Completes the state of the buffer event handler with the specified events.
 
void filter_events ()
 Filter the read and write events so that only pending events are stored.
 
void complete_state (sham::EventList &events)
 Completes the state of the buffer event handler using an EventList.
 

Public Attributes

std::vector< sycl::event > read_events
 Vector of events related to read operations on the buffer.
 
std::vector< sycl::event > write_events
 Vector of events related to write operations on the buffer.
 
enum sham::details::BufferEventHandler::last_op last_access
 
bool up_to_date_events = true
 Flag to indicate if the buffer access events are up to date.
 
SourceLocation last_access_loc
 Source location of the last access to the buffer.
 

Detailed Description

Class that manages the event state of a SYCL USM buffer.

This class is used to manage the accesses to a SYCL USM buffer. It keeps track of the events related to read and write operations of the buffer. The class has two states: incomplete and complete.

The class is designed to work with SYCL USM buffers.

Definition at line 40 of file BufferEventHandler.hpp.

Member Enumeration Documentation

◆ last_op

Enum to represent the last operation performed on the buffer.

This enum is used to represent the last operation on the managed object. It can be either a read operation or a write operation.

Definition at line 88 of file BufferEventHandler.hpp.

Member Function Documentation

◆ complete_state() [1/3]

void sham::details::BufferEventHandler::complete_state ( const std::vector< sycl::event > &  events,
SourceLocation  src_loc = SourceLocation{} 
)

Completes the state of the buffer event handler with the specified events.

This function is used to complete the state of the buffer event handler with the given list of events. Once the state is completed, the buffer event handler is marked as up to date.

Parameters
eventsA vector of events for which the state is completed.
src_locThe source location of the call to this function.
Exceptions
std::runtime_errorif the buffer event handler is already up to date. This exception is thrown when the function is called on a buffer event handler that is already up to date (i.e., up_to_date_events is true).

Definition at line 108 of file BufferEventHandler.cpp.

+ Here is the call graph for this function:

◆ complete_state() [2/3]

void sham::details::BufferEventHandler::complete_state ( sham::EventList events)
inline

Completes the state of the buffer event handler using an EventList.

This function completes the state of the buffer event handler with the events contained in the provided EventList. Once the state is completed, the events in the EventList are marked as consumed.

Parameters
eventsThe EventList containing events for which the state is completed.

Definition at line 197 of file BufferEventHandler.hpp.

+ Here is the call graph for this function:

◆ complete_state() [3/3]

void sham::details::BufferEventHandler::complete_state ( sycl::event  e,
SourceLocation  src_loc = SourceLocation{} 
)

Completes the state of the buffer event handler with the event for which the access was queried.

This function is used to complete the state of the buffer event handler with the event for which the access was queried. Once the state is completed, the buffer event handler is marked as up to date.

Parameters
eThe event for which the access was queried.
src_locThe source location of the call to this function.
Exceptions
std::runtime_errorif the buffer event handler is already up to date. This exception is thrown when the function is called on a buffer event handler that is already up to date (i.e., up_to_date_events is true).

Definition at line 104 of file BufferEventHandler.cpp.

+ Here is the call graph for this function:

◆ filter_events()

void sham::details::BufferEventHandler::filter_events ( )

Filter the read and write events so that only pending events are stored.

Events that are completed are removed from the read and write event lists.

Definition at line 26 of file BufferEventHandler.cpp.

+ Here is the call graph for this function:

◆ is_empty()

bool sham::details::BufferEventHandler::is_empty ( )
inline

Check if there if the events lists are empty.

Returns
true if both buffer events lists are empty, false otherwise

Definition at line 80 of file BufferEventHandler.hpp.

◆ read_access()

void sham::details::BufferEventHandler::read_access ( sham::EventList depends_list,
SourceLocation  src_loc = SourceLocation{} 
)

Adds events conditioning the validity of a buffer for read access to the dependency list. Also sets the event handler to incomplete state (up_to_date_events = false).

This function is used to add events that condition the validity of a buffer for read access to the dependency list. It is typically used when a read operation is about to be performed on the buffer. The function adds the events related to previous write operations on the buffer to the dependency list.

Parameters
depends_listThe vector of events that the read access depends on.
src_locThe source location of the call to this function.
Exceptions
std::runtime_errorif the buffer event handler is in an incomplete state. This exception is thrown when the function is called on a buffer event handler that is in an incomplete state (i.e., up_to_date_events is false).

Definition at line 51 of file BufferEventHandler.cpp.

+ Here is the call graph for this function:

◆ wait_all()

void sham::details::BufferEventHandler::wait_all ( SourceLocation  src_loc = SourceLocation{})
inline

Wait for all the buffer accesses to be completed.

This function waits for all the buffer accesses to be completed. It waits for both read and write events to be completed.

Parameters
src_locSource location of the call to this function

Definition at line 67 of file BufferEventHandler.hpp.

◆ write_access()

void sham::details::BufferEventHandler::write_access ( sham::EventList depends_list,
SourceLocation  src_loc = SourceLocation{} 
)

Adds events conditioning the validity of a buffer for write access to the dependency list. Also sets the event handler to incomplete state (up_to_date_events = false).

This function is used to add events that condition the validity of a buffer for write access to the dependency list. It is typically used when a write operation is about to be performed on the buffer. The function adds the events related to previous read and write operations on the buffer to the dependency list.

Parameters
depends_listThe vector of events that the write access depends on.
src_locThe source location of the call to this function.
Exceptions
std::runtime_errorif the buffer event handler is in an incomplete state. This exception is thrown when the function is called on a buffer event handler that is in an incomplete state (i.e., up_to_date_events is false).

Definition at line 76 of file BufferEventHandler.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ last_access_loc

SourceLocation sham::details::BufferEventHandler::last_access_loc

Source location of the last access to the buffer.

This is the source location of the last access to the buffer. It is used to report an error if the buffer is accessed in an incomplete state.

Definition at line 105 of file BufferEventHandler.hpp.

◆ read_events

std::vector<sycl::event> sham::details::BufferEventHandler::read_events

Vector of events related to read operations on the buffer.

This vector keeps track of the events that correcpond to read operation on the managed object

Definition at line 49 of file BufferEventHandler.hpp.

◆ up_to_date_events

bool sham::details::BufferEventHandler::up_to_date_events = true

Flag to indicate if the buffer access events are up to date.

If it is true, it means that the buffer access events are up to date. If it is false, it means that the buffer access events are not up to date, the event handler is in a incomplete state.

Definition at line 97 of file BufferEventHandler.hpp.

◆ write_events

std::vector<sycl::event> sham::details::BufferEventHandler::write_events

Vector of events related to write operations on the buffer.

This vector keeps track of the events that correcpond to wire operation on the managed object

Definition at line 57 of file BufferEventHandler.hpp.


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