From 31ace540fac9fe714b534b866e68e8d32e771219 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Tue, 26 Mar 2024 16:40:58 -0400 Subject: [PATCH] SWDEV-449922 - Remove per queue residency update alwaysResident setting doesn't require per queue residency tracking. Thus, the logic can be skipped to avoid the lock of queues. Change-Id: Ib5cff5b79d3ecb8c2f2eb2565cf069f9a69438b0 [ROCm/clr commit: 95e39587487ae9b8b3031f0bc525c578bdea47ec] --- .../clr/rocclr/device/pal/palresource.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/projects/clr/rocclr/device/pal/palresource.cpp b/projects/clr/rocclr/device/pal/palresource.cpp index 40c5123648..d0676b2fb6 100644 --- a/projects/clr/rocclr/device/pal/palresource.cpp +++ b/projects/clr/rocclr/device/pal/palresource.cpp @@ -255,23 +255,26 @@ GpuMemoryReference::~GpuMemoryReference() { if (nullptr == iMem()) { return; } - if (gpu_ == nullptr) { - Device::ScopedLockVgpus lock(device_); - // Release all memory objects on all virtual GPUs - for (uint idx = 1; idx < device_.vgpus().size(); ++idx) { - device_.vgpus()[idx]->releaseMemory(this); + // Memory tracking per queue is disabled if alwaysResident is enabled. Thus, runtime can skip + // updating residency state per every queue + if (!device_.settings().alwaysResident_) { + if (gpu_ == nullptr) { + Device::ScopedLockVgpus lock(device_); + // Release all memory objects on all virtual GPUs + for (uint idx = 1; idx < device_.vgpus().size(); ++idx) { + device_.vgpus()[idx]->releaseMemory(this); + } + } else { + amd::ScopedLock l(gpu_->execution()); + gpu_->releaseMemory(this); + } + if (device_.vgpus().size() != 0) { + assert(device_.vgpus()[0] == device_.xferQueue() && "Wrong transfer queue!"); + // Lock the transfer queue, since it's not handled by ScopedLockVgpus + amd::ScopedLock k(device_.xferMgr().lockXfer()); + device_.vgpus()[0]->releaseMemory(this); } - } else { - amd::ScopedLock l(gpu_->execution()); - gpu_->releaseMemory(this); } - if (device_.vgpus().size() != 0) { - assert(device_.vgpus()[0] == device_.xferQueue() && "Wrong transfer queue!"); - // Lock the transfer queue, since it's not handled by ScopedLockVgpus - amd::ScopedLock k(device_.xferMgr().lockXfer()); - device_.vgpus()[0]->releaseMemory(this); - } - // Destroy PAL object if it's not a suballocation if (cpuAddress_ != nullptr) { iMem()->Unmap();