From e3efce20be8f6623014778e1dcccb41f81906bbd Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Fri, 13 Dec 2024 17:34:56 -0500 Subject: [PATCH] SWDEV-504650 - Switch to shared_mutex for events Use shared mutex for events validation Change-Id: Iff291c758d9edd65717c506150f3b9d39e5306ba --- hipamd/src/hip_event.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index 78e1605fa2..28574c2753 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -28,7 +28,7 @@ namespace hip { // Guards global event set -static amd::Monitor eventSetLock{}; +static std::shared_mutex eventSetLock{}; static std::unordered_set eventSet; bool Event::ready() { @@ -268,7 +268,7 @@ bool isValid(hipEvent_t event) { return true; } - amd::ScopedLock lock(eventSetLock); + std::shared_lock lock(eventSetLock); if (eventSet.find(event) == eventSet.end()) { return false; } @@ -315,7 +315,7 @@ hipError_t ihipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { return hipErrorOutOfMemory; } *event = reinterpret_cast(e); - amd::ScopedLock lock(hip::eventSetLock); + std::unique_lock lock(hip::eventSetLock); hip::eventSet.insert(*event); } else { return hipErrorInvalidValue; @@ -350,7 +350,7 @@ hipError_t hipEventDestroy(hipEvent_t event) { HIP_RETURN(hipErrorInvalidHandle); } - amd::ScopedLock lock(hip::eventSetLock); + std::unique_lock lock(hip::eventSetLock); if (hip::eventSet.erase(event) == 0 ) { return hipErrorContextIsDestroyed; }