From d6eaf490335cd20ecc0e633fe7494b94edbacbe7 Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Thu, 9 May 2024 01:02:56 +0100 Subject: [PATCH] SWDEV-460925 - Do awaitCompletion before releasing the lastEnqueueCommand Change-Id: I210399dd1bced13c0923fdb1c215e044920c5a4b --- rocclr/platform/commandqueue.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rocclr/platform/commandqueue.cpp b/rocclr/platform/commandqueue.cpp index 960a6d8dbf..91749a5e10 100644 --- a/rocclr/platform/commandqueue.cpp +++ b/rocclr/platform/commandqueue.cpp @@ -146,16 +146,19 @@ void HostQueue::finish(bool cpu_wait) { if (cpu_wait || !device().IsHwEventReady(command->event(), kWaitCompletion)) { ClPrint(LOG_DEBUG, LOG_CMD, "HW Event not ready, awaiting completion instead"); command->awaitCompletion(); - } - if (IS_HIP) { - ScopedLock sl(vdev()->execution()); - ScopedLock l(lastCmdLock_); - // Runtime can clear the last command only if no other submissions occured during finish() - if (command == lastEnqueueCommand_) { - lastEnqueueCommand_->release(); - lastEnqueueCommand_ = nullptr; + + if (IS_HIP) { + ScopedLock sl(vdev()->execution()); + ScopedLock l(lastCmdLock_); + // Runtime can clear the last command only if no other submissions occured + // during finish() + if (command == lastEnqueueCommand_) { + lastEnqueueCommand_->release(); + lastEnqueueCommand_ = nullptr; + } } } + command->release(); ClPrint(LOG_DEBUG, LOG_CMD, "All commands finished"); }