Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
BufferEventHandler.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20#include "shambackends/sycl.hpp"
22
23namespace sham::details {
24
41
42 public:
49 std::vector<sycl::event> read_events;
50
57 std::vector<sycl::event> write_events;
58
67 inline void wait_all(SourceLocation src_loc = SourceLocation{}) {
68 sycl::event::wait(read_events);
69 sycl::event::wait(write_events);
70
71 read_events.clear();
72 write_events.clear();
73 }
74
80 inline bool is_empty() { return read_events.empty() && write_events.empty(); }
81
88 enum last_op { READ, WRITE } last_access;
89
97 bool up_to_date_events = true;
98
106
125 void read_access(sham::EventList &depends_list, SourceLocation src_loc = SourceLocation{});
126
145 void write_access(sham::EventList &depends_list, SourceLocation src_loc = SourceLocation{});
146
162 void complete_state(sycl::event e, SourceLocation src_loc = SourceLocation{});
163
178 void complete_state(
179 const std::vector<sycl::event> &events, SourceLocation src_loc = SourceLocation{});
180
186 void filter_events();
187
197 inline void complete_state(sham::EventList &events) {
198 complete_state(events.events);
199 events.consumed = true;
200 }
201 };
202
203} // namespace sham::details
Source location utility.
Class to manage a list of SYCL events.
Definition EventList.hpp:31
Class that manages the event state of a SYCL USM buffer.
std::vector< sycl::event > read_events
Vector of events related to read operations on the buffer.
void wait_all(SourceLocation src_loc=SourceLocation{})
Wait for all the buffer accesses to be completed.
last_op
Enum to represent the last operation performed on the buffer.
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....
bool is_empty()
Check if there if the events lists are empty.
SourceLocation last_access_loc
Source location of the last access to the buffer.
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 filter_events()
Filter the read and write events so that only pending events are stored.
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....
void complete_state(sham::EventList &events)
Completes the state of the buffer event handler using an EventList.
bool up_to_date_events
Flag to indicate if the buffer access events are up to date.
std::vector< sycl::event > write_events
Vector of events related to write operations on the buffer.
This file contains the class definition for BufferEventHandler.
provide information about the source location