21u32 shamalgs::gen_buf_hash() {
23 static std::mt19937 gengine{0};
24 return std::uniform_int_distribution<u32>(0,
u32_max)(gengine);
27void shamalgs::BufferEventHandler::add_read_dependancies(std::vector<sycl::event> &depends_list) {
29 if (!up_to_date_events) {
32 +
"cannot create a read dependency: the event state was not updated after the "
38 up_to_date_events =
false;
39 last_event_create = READ;
41 depends_list.push_back(event_last_write);
43 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"add read dependency");
46void shamalgs::BufferEventHandler::add_read_write_dependancies(
47 std::vector<sycl::event> &depends_list) {
49 if (!up_to_date_events) {
52 +
"cannot create a read-write dependency: the event state was not updated after "
53 "the last event usage";
58 up_to_date_events =
false;
59 last_event_create = READ_WRITE;
61 depends_list.push_back(event_last_write);
62 for (
const sycl::event &e : event_last_read) {
63 depends_list.push_back(e);
65 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"add read write dependency");
68 event_last_write = {};
70 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"reset event list");
73void shamalgs::BufferEventHandler::register_read_event(
const sycl::event &e) {
75 if (up_to_date_events) {
78 +
"cannot register a read event: no dependency was fetched before this "
84 if (last_event_create != READ) {
87 +
"cannot register a read event: the last dependency created was not a read "
93 up_to_date_events =
true;
94 event_last_read.push_back(e);
96 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"append last read");
99void shamalgs::BufferEventHandler::register_read_write_event(
const sycl::event &e) {
100 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"set last write");
101 if (up_to_date_events) {
104 +
"cannot register a read-write event: no dependency was fetched before this "
110 if (last_event_create != READ_WRITE) {
113 +
"cannot register a read-write event: the last dependency created was not a "
114 "read-write dependency");
119 up_to_date_events =
true;
120 event_last_write = e;
123void shamalgs::BufferEventHandler::synchronize() {
125 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"synchronize");
127 if (!up_to_date_events) {
129 = (get_hash_log() +
"cannot synchronize: the event state is not up to date");
134 event_last_write.wait_and_throw();
135 for (sycl::event e : event_last_read) {
139 event_last_read = {};
140 event_last_write = {};
std::uint32_t u32
32 bit unsigned integer
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
constexpr u32 u32_max
u32 max value
void err(std::string module_name, Types... var2)
Prints a log message with multiple arguments.