diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index 9876996eb2..b74c574305 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -1008,6 +1008,7 @@ bool VirtualGPU::releaseGpuMemoryFence(bool skip_cpu_wait) { // Dispatch barrier packet into the queue dispatchBarrierPacket(kBarrierPacketHeader); hasPendingDispatch_ = false; + retainExternalSignals_ = false; } // Check if runtime could skip CPU wait @@ -1277,7 +1278,9 @@ void VirtualGPU::profilingBegin(amd::Command& command, bool drmProfiling) { } if (AMD_DIRECT_DISPATCH) { - Barriers().ClearExternalSignals(); + if (!retainExternalSignals_) { + Barriers().ClearExternalSignals(); + } for (auto it = command.eventWaitList().begin(); it < command.eventWaitList().end(); ++it) { void* hw_event = ((*it)->NotifyEvent() != nullptr) ? (*it)->NotifyEvent()->HwEvent() : (*it)->HwEvent(); @@ -1304,10 +1307,12 @@ void VirtualGPU::profilingEnd(amd::Command& command) { if (!timestamp_->HwProfiling()) { timestamp_->end(); } - assert(Barriers().IsExternalSignalListEmpty()); command.setData(timestamp_); timestamp_ = nullptr; } + if (AMD_DIRECT_DISPATCH) { + assert(retainExternalSignals_ || Barriers().IsExternalSignalListEmpty()); + } } // ================================================================================================ @@ -2991,6 +2996,7 @@ void VirtualGPU::submitKernel(amd::NDRangeKernelCommand& vcmd) { // Add a dependency into the current queue on the coop queue Barriers().AddExternalSignal(queue->Barriers().GetLastSignal()); hasPendingDispatch_ = true; + retainExternalSignals_ = true; queue->profilingEnd(vcmd); } else { diff --git a/rocclr/device/rocm/rocvirtual.hpp b/rocclr/device/rocm/rocvirtual.hpp index 5301da8d1c..e8ad55c413 100644 --- a/rocclr/device/rocm/rocvirtual.hpp +++ b/rocclr/device/rocm/rocvirtual.hpp @@ -458,12 +458,13 @@ class VirtualGPU : public device::VirtualDevice { //! Queue state flags union { struct { - uint32_t hasPendingDispatch_ : 1; //!< A kernel dispatch is outstanding - uint32_t profiling_ : 1; //!< Profiling is enabled - uint32_t cooperative_ : 1; //!< Cooperative launch is enabled - uint32_t addSystemScope_ : 1; //!< Insert a system scope to the next aql - uint32_t tracking_created_ : 1; //!< Enabled if tracking object was properly initialized - uint32_t profilerAttached_ : 1; //!< Indicates if profiler is attached + uint32_t hasPendingDispatch_ : 1; //!< A kernel dispatch is outstanding + uint32_t profiling_ : 1; //!< Profiling is enabled + uint32_t cooperative_ : 1; //!< Cooperative launch is enabled + uint32_t addSystemScope_ : 1; //!< Insert a system scope to the next aql + uint32_t tracking_created_ : 1; //!< Enabled if tracking object was properly initialized + uint32_t profilerAttached_ : 1; //!< Indicates if profiler is attached + uint32_t retainExternalSignals_ : 1; //!< Indicate to retain external signal array }; uint32_t state_; };