diff --git a/hipamd/src/hip_device.cpp b/hipamd/src/hip_device.cpp index 20889b0fe6..41bfb9efe2 100644 --- a/hipamd/src/hip_device.cpp +++ b/hipamd/src/hip_device.cpp @@ -220,19 +220,19 @@ void Device::WaitActiveStreams(hip::Stream* blocking_stream, bool wait_null_stre // ================================================================================================ void Device::AddStream(Stream* stream) { - amd::ScopedLock lock(streamSetLock); + std::unique_lock lock(streamSetLock); streamSet.insert(stream); } // ================================================================================================ void Device::RemoveStream(Stream* stream){ - amd::ScopedLock lock(streamSetLock); + std::unique_lock lock(streamSetLock); streamSet.erase(stream); } // ================================================================================================ bool Device::StreamExists(Stream* stream){ - amd::ScopedLock lock(streamSetLock); + std::shared_lock lock(streamSetLock); if (streamSet.find(stream) != streamSet.end()) { return true; } @@ -243,7 +243,7 @@ bool Device::StreamExists(Stream* stream){ void Device::destroyAllStreams() { std::vector toBeDeleted; { - amd::ScopedLock lock(streamSetLock); + std::shared_lock lock(streamSetLock); for (auto& it : streamSet) { if (it->Null() == false ) { toBeDeleted.push_back(it); @@ -262,7 +262,7 @@ void Device::SyncAllStreams(bool cpu_wait, bool wait_blocking_streams_only) { std::vector streams; streams.reserve(streamSet.size()); { - amd::ScopedLock lock(streamSetLock); + std::shared_lock lock(streamSetLock); if (wait_blocking_streams_only) { auto null_stream = GetNullStream(); for (auto it : streamSet) { @@ -293,7 +293,7 @@ void Device::SyncAllStreams(bool cpu_wait, bool wait_blocking_streams_only) { // ================================================================================================ bool Device::StreamCaptureBlocking() { - amd::ScopedLock lock(streamSetLock); + std::shared_lock lock(streamSetLock); for (auto& it : streamSet) { if (it->GetCaptureStatus() == hipStreamCaptureStatusActive && it->Flags() != hipStreamNonBlocking) { return true; @@ -304,7 +304,7 @@ bool Device::StreamCaptureBlocking() { // ================================================================================================ bool Device::existsActiveStreamForDevice() { - amd::ScopedLock lock(streamSetLock); + std::shared_lock lock(streamSetLock); for (const auto& active_stream : streamSet) { if (active_stream->GetQueueStatus()) { return true; diff --git a/hipamd/src/hip_internal.hpp b/hipamd/src/hip_internal.hpp index 6a30b19635..a445bb77ad 100644 --- a/hipamd/src/hip_internal.hpp +++ b/hipamd/src/hip_internal.hpp @@ -488,7 +488,7 @@ public: // Device lock amd::Monitor lock_{true}; // Guards device stream set - amd::Monitor streamSetLock{}; + std::shared_mutex streamSetLock; std::unordered_set streamSet; /// ROCclr context amd::Context* context_;