From 0a132499ce9274cd298d7be72bd5ea72e8f22fb2 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Wed, 24 Feb 2021 11:39:28 -0500 Subject: [PATCH] SWDEV-271964 - Revert "SWDEV-264244 Fix StreamSync" This reverts commit a962e2d0b3a39a7d975a9dc467d2ba8e729dcd29. Change-Id: I870c8b71edeb31f587fffe2447762acba61a7938 [ROCm/clr commit: 184b2631d5696187635be2062ef88e5675a456f4] --- projects/clr/rocclr/platform/command.cpp | 65 +++++++++--------------- projects/clr/rocclr/platform/command.hpp | 4 +- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/projects/clr/rocclr/platform/command.cpp b/projects/clr/rocclr/platform/command.cpp index 13f8428e3c..df0673f14a 100644 --- a/projects/clr/rocclr/platform/command.cpp +++ b/projects/clr/rocclr/platform/command.cpp @@ -183,65 +183,50 @@ void Event::processCallbacks(int32_t status) const { } } -void Event::waitForCompletion() { - ClPrint(LOG_DEBUG, LOG_WAIT, "waiting for event %p to complete, current status %d", this, status()); - auto* queue = command().queue(); - if ((queue != nullptr) && queue->vdev()->ActiveWait()) { - while (status() > CL_COMPLETE) { - amd::Os::yield(); - } - } else { - ScopedLock lock(lock_); - - // Wait until the status becomes CL_COMPLETE or negative. - while (status() > CL_COMPLETE) { - lock_.wait(); - } - } - ClPrint(LOG_DEBUG, LOG_WAIT, "event %p wait completed", this); -} - bool Event::awaitCompletion() { if (status() > CL_COMPLETE) { // Notifies current command queue about waiting - Command* command = notifyCmdQueue(true); - if (command == nullptr) { + if (!notifyCmdQueue()) { return false; - } else { - command->waitForCompletion(); - auto status = command->status(); - command->release(); - return status == CL_COMPLETE; } + + ClPrint(LOG_DEBUG, LOG_WAIT, "waiting for event %p to complete, current status %d", this, status()); + auto* queue = command().queue(); + if ((queue != nullptr) && queue->vdev()->ActiveWait()) { + while (status() > CL_COMPLETE) { + amd::Os::yield(); + } + } else { + ScopedLock lock(lock_); + + // Wait until the status becomes CL_COMPLETE or negative. + while (status() > CL_COMPLETE) { + lock_.wait(); + } + } + ClPrint(LOG_DEBUG, LOG_WAIT, "event %p wait completed", this); } - // Command is already completed + return status() == CL_COMPLETE; } -Command* Event::notifyCmdQueue(bool retain) { +bool Event::notifyCmdQueue() { HostQueue* queue = command().queue(); if ((status() > CL_COMPLETE) && // Don't need to send notify for notifications, which have 0 type (command().type() != 0) && (nullptr != queue) && !notified_.test_and_set()) { // Make sure the queue is draining the enqueued commands. - amd::Command* internalCommand = new amd::Marker(*queue, false, nullWaitList, this); - if (internalCommand == NULL) { + amd::Command* command = new amd::Marker(*queue, false, nullWaitList, this); + if (command == NULL) { notified_.clear(); - return nullptr; + return false; } ClPrint(LOG_DEBUG, LOG_CMD, "queue marker to command queue: %p", queue); - internalCommand->enqueue(); - // if retain is false, release the command here, else release in the caller function - if (!retain) { - internalCommand->release(); - } - return internalCommand; + command->enqueue(); + command->release(); } - if (retain) { - this->retain(); - } - return &command(); + return true; } const Event::EventWaitList Event::nullWaitList(0); diff --git a/projects/clr/rocclr/platform/command.hpp b/projects/clr/rocclr/platform/command.hpp index b721583517..4ae045c724 100644 --- a/projects/clr/rocclr/platform/command.hpp +++ b/projects/clr/rocclr/platform/command.hpp @@ -152,8 +152,6 @@ class Event : public RuntimeObject { //! Process the callbacks for the given \a status change. void processCallbacks(int32_t status) const; - void waitForCompletion(); - //! Enable profiling for this command void EnableProfiling() { profilingInfo_.enabled_ = true; @@ -202,7 +200,7 @@ class Event : public RuntimeObject { /*! \brief Notifies current command queue about execution status */ - Command* notifyCmdQueue(bool retain = false); + bool notifyCmdQueue(); //! RTTI internal implementation virtual ObjectType objectType() const { return ObjectTypeEvent; }