From 65722f8ccaf92ceb89fbff8df2ca49647d7905ae Mon Sep 17 00:00:00 2001 From: Saleel Kudchadker Date: Thu, 26 Mar 2020 15:07:41 -0700 Subject: [PATCH] Cleanup stream from hip:Event class. Change-Id: I98de07d33bb7fea8f5e2d32b288c15f10ce58902 --- hipamd/vdi/hip_event.cpp | 16 +++------------- hipamd/vdi/hip_event.hpp | 5 ++++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hipamd/vdi/hip_event.cpp b/hipamd/vdi/hip_event.cpp index 03498c47cf..677becd67e 100644 --- a/hipamd/vdi/hip_event.cpp +++ b/hipamd/vdi/hip_event.cpp @@ -95,16 +95,13 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) { } hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) { - if (stream_ == hostQueue) return hipSuccess; + if ((event_ == nullptr) || (event_->command().queue() == hostQueue)) { + return hipSuccess; + } amd::ScopedLock lock(lock_); bool retain = false; - if (event_ == nullptr) { - event_ = stream_->getLastQueuedCommand(true); - retain = true; - } - if (!event_->notifyCmdQueue()) { return hipErrorLaunchOutOfResources; } @@ -118,19 +115,12 @@ hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) { command->enqueue(); command->release(); - if (retain) { - event_->release(); - event_ = nullptr; - } - return hipSuccess; } void Event::addMarker(amd::HostQueue* queue, amd::Command* command) { amd::ScopedLock lock(lock_); - stream_ = queue; - if (event_ == &command->event()) return; if (event_ != nullptr) { diff --git a/hipamd/vdi/hip_event.hpp b/hipamd/vdi/hip_event.hpp index a9cae92bbb..2360c972bb 100644 --- a/hipamd/vdi/hip_event.hpp +++ b/hipamd/vdi/hip_event.hpp @@ -37,7 +37,10 @@ public: class Event { public: - Event(unsigned int flags) : flags(flags), lock_("hipEvent_t"), stream_(getNullStream()), event_(nullptr) {} + Event(unsigned int flags) : flags(flags), lock_("hipEvent_t"), event_(nullptr) { + // No need to init event_ here as addMarker does that + } + ~Event() { if (event_ != nullptr) { event_->release();