diff --git a/rocclr/runtime/device/gpu/gpuvirtual.cpp b/rocclr/runtime/device/gpu/gpuvirtual.cpp index 2dc6337196..92fb2ec7ba 100644 --- a/rocclr/runtime/device/gpu/gpuvirtual.cpp +++ b/rocclr/runtime/device/gpu/gpuvirtual.cpp @@ -642,7 +642,8 @@ VirtualGPU::~VirtualGPU() gslKernels_.clear(); // Destroy all memories - releaseMemObjects(); + static const bool SkipScratch = false; + releaseMemObjects(SkipScratch); // Destroy printf object delete printfDbg_; @@ -2885,7 +2886,7 @@ VirtualGPU::enableSyncedBlit() const } void -VirtualGPU::releaseMemObjects() +VirtualGPU::releaseMemObjects(bool scratch) { for (GpuEvents::const_iterator it = gpuEvents_.begin(); it != gpuEvents_.end(); ++it) { @@ -2916,16 +2917,13 @@ VirtualGPU::releaseMemObjects() setConstantBuffer(SC_INFO_CONSTANTBUFFER, NULL, 0, 0); } - if ((dev().scratch(hwRing()) != NULL) && - (dev().scratch(hwRing())->regNum_ > 0)) { - // Unbind scratch memory - const std::vector& mems = dev().scratch(hwRing())->memObjs_; - for (uint i = 0; i < mems.size(); ++i) { - if (mems[i] != NULL) { - setScratchBuffer(NULL, i); - } + if (scratch) { + uint numBufs = (dev().settings().siPlus_) ? 1 : dev().info().numberOfShaderEngines; + for (uint i = 0; i < numBufs; ++i) { + setScratchBuffer(NULL, i); } } + gpuEvents_.clear(); } diff --git a/rocclr/runtime/device/gpu/gpuvirtual.hpp b/rocclr/runtime/device/gpu/gpuvirtual.hpp index 76d156cfac..ec7b03919e 100644 --- a/rocclr/runtime/device/gpu/gpuvirtual.hpp +++ b/rocclr/runtime/device/gpu/gpuvirtual.hpp @@ -382,7 +382,7 @@ public: const DmaFlushMgmt& dmaFlushMgmt() const { return dmaFlushMgmt_; } //! Releases GSL memory objects allocated on this queue - void releaseMemObjects(); + void releaseMemObjects(bool scratch = true); //! Returns the HW ring used on this virtual device uint hwRing() const { return hwRing_; }