Skip to content

Commit f40bd4a

Browse files
author
Steffen Larsen
committed
[SYCL] Fixes circular reference between events and queues
Signed-off-by: Steffen Larsen <[email protected]>
1 parent ef68270 commit f40bd4a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

sycl/source/detail/event_impl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ void event_impl::wait_and_throw(
114114
if (Cmd)
115115
Cmd->getQueue()->throw_asynchronous();
116116
}
117-
if (MQueue)
118-
MQueue->throw_asynchronous();
117+
QueueImplPtr Queue = MQueue.lock();
118+
if (Queue)
119+
Queue->throw_asynchronous();
119120
}
120121

121122
template <>

sycl/source/detail/event_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class context_impl;
2525
using ContextImplPtr = std::shared_ptr<cl::sycl::detail::context_impl>;
2626
class queue_impl;
2727
using QueueImplPtr = std::shared_ptr<cl::sycl::detail::queue_impl>;
28+
using QueueImplWPtr = std::weak_ptr<cl::sycl::detail::queue_impl>;
2829

2930
class event_impl {
3031
public:
@@ -147,7 +148,7 @@ class event_impl {
147148
private:
148149
RT::PiEvent MEvent = nullptr;
149150
ContextImplPtr MContext;
150-
QueueImplPtr MQueue;
151+
QueueImplWPtr MQueue;
151152
bool MOpenCLInterop = false;
152153
bool MHostEvent = true;
153154
std::unique_ptr<HostProfilingInfo> MHostProfilingInfo;

0 commit comments

Comments
 (0)