From 433c25eab06a7518c3b02630ddf59e9646fe4428 Mon Sep 17 00:00:00 2001 From: "Kudchadker, Saleel" Date: Tue, 8 Jul 2025 12:02:01 -0700 Subject: [PATCH] SWDEV-539378 - Use agent of IPC memory owner (#570) - Currently runtime just uses the local agent as it did not check for IPCShared() - With this fix we query hsa_amd_pointer_info and get the right agent for the memory to pass it to the HSA copy api [ROCm/clr commit: 46d766e4e2658dbbb95a046a564cb0312c92f5db] --- projects/clr/rocclr/device/rocm/rocblit.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/clr/rocclr/device/rocm/rocblit.cpp b/projects/clr/rocclr/device/rocm/rocblit.cpp index e61e33c136..81a8eab29b 100644 --- a/projects/clr/rocclr/device/rocm/rocblit.cpp +++ b/projects/clr/rocclr/device/rocm/rocblit.cpp @@ -603,6 +603,24 @@ bool DmaBlitManager::hsaCopy(const Memory& srcMemory, const Memory& dstMemory, (srcMemory.isHostMemDirectAccess()) ? dev().getCpuAgent() : dev().getBackendDevice(); dstAgent = (dstMemory.isHostMemDirectAccess()) ? dev().getCpuAgent() : dev().getBackendDevice(); + + // When a memory is opened as IPCBuffer, the runtime is not aware of the agent that + // owns the memory, thus query the pointer info here. + if (static_cast(srcMemory.owner())->ipcShared()) { + hsa_amd_pointer_info_t info = {sizeof(hsa_amd_pointer_info_t)}; + if (HSA_STATUS_SUCCESS == + hsa_amd_pointer_info(const_cast
(src), &info, nullptr, nullptr, nullptr)) { + srcAgent = info.agentOwner; + } + } + + if (static_cast(dstMemory.owner())->ipcShared()) { + hsa_amd_pointer_info_t info = {sizeof(hsa_amd_pointer_info_t)}; + if (HSA_STATUS_SUCCESS == + hsa_amd_pointer_info(dst, &info, nullptr, nullptr, nullptr)) { + dstAgent = info.agentOwner; + } + } } else { srcAgent = srcMemory.dev().getBackendDevice();