From ecea27eb2d935e467ce47b430fa8ef29dfce5f58 Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 12 Jan 2023 17:55:43 +0000 Subject: [PATCH] SWDEV-372757 - thread check workaround for windows hang Change-Id: Ie9f87b88dd0f3078ad1919edc336f297f6b40373 --- rocclr/platform/commandqueue.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rocclr/platform/commandqueue.cpp b/rocclr/platform/commandqueue.cpp index 8eddcfa72f..e9e56cb80b 100644 --- a/rocclr/platform/commandqueue.cpp +++ b/rocclr/platform/commandqueue.cpp @@ -71,9 +71,8 @@ bool HostQueue::terminate() { } else { if (Os::isThreadAlive(thread_)) { Command* marker = nullptr; - // Send a finish if the queue is still accepting commands. - { + if (lastEnqueueCommand_ != nullptr || !amd::IS_HIP) { ScopedLock sl(queueLock_); if (thread_.acceptingCommands_) { marker = new Marker(*this, false); @@ -84,7 +83,11 @@ bool HostQueue::terminate() { } } if (marker != nullptr) { - marker->awaitCompletion(); + if (marker->notifyCmdQueue()) { + while (marker->status() > CL_COMPLETE && Os::isThreadAlive(thread_)) { + amd::Os::yield(); + } + } marker->release(); } @@ -96,7 +99,7 @@ bool HostQueue::terminate() { } // FIXME_lmoriche: fix termination handshake - while (thread_.state() < Thread::FINISHED) { + while (thread_.state() < Thread::FINISHED && Os::isThreadAlive(thread_)) { Os::yield(); } }