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 +
"you want to create a event depedancy, but the event state was not updated "
33 "after last event usage";
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 +
"you want to create a event depedancy, but the event state was not updated "
53 "after 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 +
"you are trying to register an event without having fetched one previously");
83 if (last_event_create != READ) {
86 +
"you want to register a read event but the last dependency was not in read mode");
91 up_to_date_events =
true;
92 event_last_read.push_back(e);
94 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"append last read");
97void shamalgs::BufferEventHandler::register_read_write_event(
const sycl::event &e) {
98 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"set last write");
99 if (up_to_date_events) {
102 +
"you are trying to register an event without having fetched one previously");
107 if (last_event_create != READ_WRITE) {
110 +
"you want to register a read-write event but the last dependency was not in "
116 up_to_date_events =
true;
117 event_last_write = e;
120void shamalgs::BufferEventHandler::synchronize() {
122 shamlog_debug_sycl_ln(
"[USMBuffer]", get_hash_log(),
"synchronize");
124 if (!up_to_date_events) {
125 std::string
err = (get_hash_log() +
"the events are not up to date");
130 event_last_write.wait_and_throw();
131 for (sycl::event e : event_last_read) {
135 event_last_read = {};
136 event_last_write = {};
std::uint32_t u32
32 bit unsigned integer
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
constexpr u32 u32_max
u32 max value
void err(std::string module_name, Types... var2)
Prints a log message with multiple arguments.