-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathon_queue.h
More file actions
65 lines (54 loc) · 1.79 KB
/
on_queue.h
File metadata and controls
65 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Copyright (C) 2024 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef ISHMEM_ON_QUEUE_H
#define ISHMEM_ON_QUEUE_H
#include "accelerator.h"
#include <map>
struct ishmemi_on_queue_map_entry_t {
const size_t max_work_group_size;
sycl::event event;
ishmemi_on_queue_map_entry_t(sycl::queue q)
: max_work_group_size(q.get_device().get_info<sycl::info::device::max_work_group_size>())
{
}
};
inline void set_cmd_grp_dependencies(sycl::handler &cgh, bool entry_already_exists, sycl::event &e,
const std::vector<sycl::event> &deps)
{
if (entry_already_exists) {
cgh.depends_on(e);
}
cgh.depends_on(deps);
}
class ishmemi_on_queue_map : public std::map<sycl::queue *, ishmemi_on_queue_map_entry_t *> {
public:
ishmemi_on_queue_map() {};
~ishmemi_on_queue_map()
{
for (auto iter = begin(); iter != end(); ++iter) {
delete iter->second;
}
}
inline ishmemi_on_queue_map::iterator get_entry_info(sycl::queue &q, bool &entry_already_exists)
{
ishmemi_validate_queue_device(q);
auto iter = find(&q);
if (iter != end()) {
entry_already_exists = true;
} else {
auto entry = new ishmemi_on_queue_map_entry_t(q);
auto [entry_iter, insert_succeeded] =
insert(std::pair<sycl::queue *, ishmemi_on_queue_map_entry_t *>(&q, entry));
if (!insert_succeeded) {
RAISE_ERROR_MSG("Failed to insert entry into on_queue API event map\n");
}
iter = entry_iter;
entry_already_exists = false;
}
return iter;
}
std::mutex map_mtx;
};
extern ishmemi_on_queue_map ishmemi_on_queue_events_map;
#endif // ISHMEM_ON_QUEUE_H