13
13
namespace sycl {
14
14
__SYCL_INLINE_VER_NAMESPACE (_V1) {
15
15
16
- namespace detail {
17
- struct queue_impl ;
18
- using queue_ptr = std::shared_ptr<queue_impl>;
19
- } // namespace detail
20
-
21
16
namespace ext {
22
17
namespace oneapi {
23
18
namespace experimental {
24
19
namespace detail {
25
20
26
- void graph_impl::exec (const sycl::detail::queue_ptr &q) {
21
+ void graph_impl::exec (const std::shared_ptr< sycl::detail::queue_impl> &q) {
27
22
if (MSchedule.empty ()) {
28
23
for (auto n : MRoots) {
29
24
n->topology_sort (MSchedule);
@@ -33,7 +28,8 @@ void graph_impl::exec(const sycl::detail::queue_ptr &q) {
33
28
n->exec (q);
34
29
}
35
30
36
- void graph_impl::exec_and_wait (const sycl::detail::queue_ptr &q) {
31
+ void graph_impl::exec_and_wait (
32
+ const std::shared_ptr<sycl::detail::queue_impl> &q) {
37
33
bool isSubGraph = q->getIsGraphSubmitting ();
38
34
if (!isSubGraph) {
39
35
q->setIsGraphSubmitting (true );
@@ -48,14 +44,14 @@ void graph_impl::exec_and_wait(const sycl::detail::queue_ptr &q) {
48
44
}
49
45
}
50
46
51
- void graph_impl::add_root (node_ptr n) {
47
+ void graph_impl::add_root (const std::shared_ptr<node_impl> & n) {
52
48
MRoots.insert (n);
53
49
for (auto n : MSchedule)
54
50
n->MScheduled = false ;
55
51
MSchedule.clear ();
56
52
}
57
53
58
- void graph_impl::remove_root (node_ptr n) {
54
+ void graph_impl::remove_root (const std::shared_ptr<node_impl> & n) {
59
55
MRoots.erase (n);
60
56
for (auto n : MSchedule)
61
57
n->MScheduled = false ;
@@ -74,8 +70,10 @@ void graph_impl::remove_root(node_ptr n) {
74
70
//
75
71
// @returns True if a dependency was added in this node of any of its
76
72
// successors.
77
- bool check_for_arg (const sycl::detail::ArgDesc &arg, node_ptr currentNode,
78
- std::set<node_ptr> &deps, bool dereferencePtr = false ) {
73
+ bool check_for_arg (const sycl::detail::ArgDesc &arg,
74
+ const std::shared_ptr<node_impl> ¤tNode,
75
+ std::set<std::shared_ptr<node_impl>> &deps,
76
+ bool dereferencePtr = false ) {
79
77
bool successorAddedDep = false ;
80
78
for (auto &successor : currentNode->MSuccessors ) {
81
79
successorAddedDep |= check_for_arg (arg, successor, deps, dereferencePtr);
@@ -90,14 +88,16 @@ bool check_for_arg(const sycl::detail::ArgDesc &arg, node_ptr currentNode,
90
88
}
91
89
92
90
template <typename T>
93
- node_ptr graph_impl::add (graph_ptr impl, T cgf,
94
- const std::vector<sycl::detail::ArgDesc> &args,
95
- const std::vector<node_ptr> &dep) {
96
- node_ptr nodeImpl = std::make_shared<node_impl>(impl, cgf, args);
91
+ std::shared_ptr<node_impl>
92
+ graph_impl::add (const std::shared_ptr<graph_impl> &impl, T cgf,
93
+ const std::vector<sycl::detail::ArgDesc> &args,
94
+ const std::vector<std::shared_ptr<node_impl>> &dep) {
95
+ std::shared_ptr<node_impl> nodeImpl =
96
+ std::make_shared<node_impl>(impl, cgf, args);
97
97
// Copy deps so we can modify them
98
98
auto deps = dep;
99
99
// A unique set of dependencies obtained by checking kernel arguments
100
- std::set<node_ptr > uniqueDeps;
100
+ std::set<std::shared_ptr<node_impl> > uniqueDeps;
101
101
for (auto &arg : args) {
102
102
if (arg.MType != sycl::detail::kernel_param_kind_t ::kind_pointer) {
103
103
continue ;
@@ -133,13 +133,13 @@ bool graph_impl::clear_queues() {
133
133
return anyQueuesCleared;
134
134
}
135
135
136
- void node_impl::exec (sycl::detail::queue_ptr q) {
136
+ void node_impl::exec (const std::shared_ptr<sycl::detail::queue_impl> &q
137
+ _CODELOCPARAMDEF (&CodeLoc)) {
137
138
std::vector<sycl::event> deps;
138
139
for (auto i : MPredecessors)
139
140
deps.push_back (i->get_event ());
140
141
141
- const sycl::detail::code_location CodeLoc;
142
- MEvent = q->submit (wrapper{MBody, deps}, q, CodeLoc);
142
+ MEvent = q->submit (wrapper{MBody, deps}, q _CODELOCFW (CodeLoc));
143
143
}
144
144
} // namespace detail
145
145
@@ -151,23 +151,26 @@ command_graph<graph_state::modifiable>::command_graph(
151
151
template <>
152
152
node command_graph<graph_state::modifiable>::add_impl(
153
153
std::function<void (handler &)> cgf, const std::vector<node> &dep) {
154
- std::vector<detail::node_ptr > depImpls;
154
+ std::vector<std::shared_ptr< detail::node_impl> > depImpls;
155
155
for (auto &d : dep) {
156
156
depImpls.push_back (sycl::detail::getSyclObjImpl (d));
157
157
}
158
158
159
- auto nodeImpl = impl->add (impl, cgf, {}, depImpls);
159
+ std::shared_ptr<detail::node_impl> nodeImpl =
160
+ impl->add (impl, cgf, {}, depImpls);
160
161
return sycl::detail::createSyclObjFromImpl<node>(nodeImpl);
161
162
}
162
163
163
164
template <>
164
165
void command_graph<graph_state::modifiable>::make_edge(node sender,
165
166
node receiver) {
166
- auto sender_impl = sycl::detail::getSyclObjImpl (sender);
167
- auto receiver_impl = sycl::detail::getSyclObjImpl (receiver);
167
+ std::shared_ptr<detail::node_impl> senderImpl =
168
+ sycl::detail::getSyclObjImpl (sender);
169
+ std::shared_ptr<detail::node_impl> receiverImpl =
170
+ sycl::detail::getSyclObjImpl (receiver);
168
171
169
- sender_impl ->register_successor (receiver_impl ); // register successor
170
- impl->remove_root (receiver_impl ); // remove receiver from root node list
172
+ senderImpl ->register_successor (receiverImpl ); // register successor
173
+ impl->remove_root (receiverImpl ); // remove receiver from root node list
171
174
}
172
175
173
176
template <>
0 commit comments