Skip to content

[SYCL] Fix hang in deallocateStreams function #2796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ void Scheduler::enqueueLeavesOfReqUnlocked(const Requirement *const Req) {
void Scheduler::allocateStreamBuffers(stream_impl *Impl,
size_t StreamBufferSize,
size_t FlushBufferSize) {
std::lock_guard<std::mutex> lock(StreamBuffersPoolMutex);
std::lock_guard<std::recursive_mutex> lock(StreamBuffersPoolMutex);
StreamBuffersPool.insert(
{Impl, new StreamBuffers(StreamBufferSize, FlushBufferSize)});
}

void Scheduler::deallocateStreamBuffers(stream_impl *Impl) {
std::lock_guard<std::mutex> lock(StreamBuffersPoolMutex);
std::lock_guard<std::recursive_mutex> lock(StreamBuffersPoolMutex);
delete StreamBuffersPool[Impl];
StreamBuffersPool.erase(Impl);
}
Expand All @@ -302,7 +302,7 @@ Scheduler::~Scheduler() {
// the kernel. Otherwise resources for stream will not be released, issue a
// warning in this case.
if (pi::trace(pi::TraceLevel::PI_TRACE_BASIC)) {
std::lock_guard<std::mutex> lock(StreamBuffersPoolMutex);
std::lock_guard<std::recursive_mutex> lock(StreamBuffersPoolMutex);
if (!StreamBuffersPool.empty())
fprintf(
stderr,
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/scheduler/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ class Scheduler {
friend class stream_impl;

// Protects stream buffers pool
std::mutex StreamBuffersPoolMutex;
std::recursive_mutex StreamBuffersPoolMutex;

// We need to store a pointer to the structure with stream buffers because we
// want to avoid a situation when buffers are destructed during destruction of
Expand Down