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();