From ec16be77fc67a14abe66896c81f31681efa5758a Mon Sep 17 00:00:00 2001 From: pghafari Date: Mon, 11 Jul 2022 15:19:09 -0400 Subject: [PATCH] SWDEV-342010 - in progress keeping track of events Change-Id: Ic87e4b46d4eebe9922a34af5867e9fc32fcb4066 --- hipamd/src/hip_event.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index 3fff536439..265bd18ee9 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -27,6 +27,9 @@ namespace hip { +static amd::Monitor eventSetLock{"Guards global event set"}; +static std::unordered_set eventSet; + bool Event::ready() { if (event_->status() != CL_COMPLETE) { event_->notifyCmdQueue(); @@ -280,6 +283,8 @@ hipError_t ihipEventCreateWithFlags(hipEvent_t* event, unsigned flags) { return hipErrorOutOfMemory; } *event = reinterpret_cast(e); + amd::ScopedLock lock(hip::eventSetLock); + hip::eventSet.insert(*event); } else { return hipErrorInvalidValue; } @@ -313,6 +318,11 @@ hipError_t hipEventDestroy(hipEvent_t event) { HIP_RETURN(hipErrorInvalidHandle); } + amd::ScopedLock lock(hip::eventSetLock); + if (hip::eventSet.erase(event) == 0 ) { + return hipErrorContextIsDestroyed; + } + hip::Event* e = reinterpret_cast(event); delete e; HIP_RETURN(hipSuccess);