From 44e600b701ff246e6a1e4a48cdfdcd4937388c41 Mon Sep 17 00:00:00 2001 From: Anusha GodavarthySurya Date: Wed, 14 Apr 2021 07:18:03 -0700 Subject: [PATCH] SWDEV-240806 - [hip-graph] Added functions updateEventWaitList and resetStatus Change-Id: I6a753e9584bdacd39ee676466a884ec6b7859879 [ROCm/clr commit: c9c6bed02291e3f536894b43a4d602b4b20ed79b] --- projects/clr/rocclr/platform/command.cpp | 13 +++++++++++++ projects/clr/rocclr/platform/command.hpp | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/projects/clr/rocclr/platform/command.cpp b/projects/clr/rocclr/platform/command.cpp index effb6ed913..4e0cad1caf 100644 --- a/projects/clr/rocclr/platform/command.cpp +++ b/projects/clr/rocclr/platform/command.cpp @@ -157,6 +157,19 @@ bool Event::setStatus(int32_t status, uint64_t timeStamp) { return true; } +bool Event::resetStatus(int32_t status) { + int32_t currentStatus = this->status(); + if (currentStatus != CL_COMPLETE) { + ClPrint(LOG_ERROR, LOG_CMD, "command is reset before complete current status :%d", + currentStatus); + } + if (!status_.compare_exchange_strong(currentStatus, status, std::memory_order_relaxed)) { + ClPrint(LOG_ERROR, LOG_CMD, "Failed to reset command status"); + return false; + } + notified_.clear(); + return true; +} bool Event::setCallback(int32_t status, Event::CallBackFunction callback, void* data) { assert(status >= CL_COMPLETE && status <= CL_QUEUED && "invalid status"); diff --git a/projects/clr/rocclr/platform/command.hpp b/projects/clr/rocclr/platform/command.hpp index 4a377ce52c..f27feb2bf9 100644 --- a/projects/clr/rocclr/platform/command.hpp +++ b/projects/clr/rocclr/platform/command.hpp @@ -186,6 +186,9 @@ class Event : public RuntimeObject { */ bool setStatus(int32_t status, uint64_t timeStamp = 0); + //! Reset the status of the command for reuse + bool resetStatus(int32_t status); + //! Signal all threads waiting on this event. void signal() { ScopedLock lock(lock_); @@ -269,6 +272,13 @@ class Command : public Event { //! Return the list of events this command needs to wait on before dispatch const EventWaitList& eventWaitList() const { return eventWaitList_; } + //! Update with the list of events this command needs to wait on before dispatch + void updateEventWaitList(const EventWaitList& waitList) { + for (auto event : waitList) { + eventWaitList_.push_back(event); + } + } + //! Return this command's OpenCL type. cl_command_type type() const { return type_; }