diff --git a/rocclr/platform/commandqueue.cpp b/rocclr/platform/commandqueue.cpp index 9ecd870e19..8eddcfa72f 100644 --- a/rocclr/platform/commandqueue.cpp +++ b/rocclr/platform/commandqueue.cpp @@ -113,7 +113,7 @@ void HostQueue::finish() { Command* command = nullptr; if (IS_HIP) { command = getLastQueuedCommand(true); - if (AMD_DIRECT_DISPATCH && command == nullptr) { + if (command == nullptr) { return; } } @@ -233,9 +233,12 @@ void HostQueue::append(Command& command) { } // Set last submitted command - Command* prevLastEnqueueCommand; - command.retain(); - { + Command* prevLastEnqueueCommand = nullptr; + + // Attach only real commands and skip internal notifications for CPU queue + if (command.waitingEvent() == nullptr) { + command.retain(); + // lastCmdLock_ ensures that lastEnqueueCommand() can retain the command before it is swapped // out. We want to keep this critical section as short as possible, so the command should be // released outside this section.