Skip to content

Commit

Permalink
[SYCL][Graph] Fix memory leak multithreading
Browse files Browse the repository at this point in the history
Fixes memory leak issues that occurred during multithreads graph finalization
  • Loading branch information
mfrancepillois committed Aug 14, 2023
1 parent 71f5314 commit 66f9626
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sycl/source/detail/graph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ void exec_graph_impl::createCommandBuffers(sycl::device Device) {

exec_graph_impl::~exec_graph_impl() {
WriteLock Lock(MMutex);
WriteLock LockImpl(MGraphImpl->MMutex);

// clear all recording queue if not done before (no call to end_recording)
MGraphImpl->clearQueues();
Expand Down Expand Up @@ -729,6 +730,9 @@ void modifiable_command_graph::make_edge(node &Src, node &Dest) {

command_graph<graph_state::executable>
modifiable_command_graph::finalize(const sycl::property_list &) const {
// Graph is read and written in this scope so we lock
// this graph with full priviledges.
graph_impl::WriteLock Lock(impl->MMutex);
return command_graph<graph_state::executable>{this->impl,
this->impl->getContext()};
}
Expand Down Expand Up @@ -813,9 +817,6 @@ executable_command_graph::executable_command_graph(
const std::shared_ptr<detail::graph_impl> &Graph, const sycl::context &Ctx)
: MTag(rand()),
impl(std::make_shared<detail::exec_graph_impl>(Ctx, Graph)) {
// Graph is read and written in this scope so we lock
// this graph with full priviledges.
graph_impl::WriteLock Lock(Graph->MMutex);
finalizeImpl(); // Create backend representation for executable graph
}

Expand Down

0 comments on commit 66f9626

Please sign in to comment.