From 1dd4a7dc182749a6161f5b6df3fa2af6bf5e613b Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Wed, 7 Feb 2024 08:04:59 -0500 Subject: [PATCH] Fix copy logic on devices with no xgmi SDMAs Fix gang factor overwrite of 0 if there are no xGMI SDMAs on the device and gang factor is 1. Change-Id: I041d4b4ae87fb68f224ee4dedb758c6f06c022a9 --- runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index a88bd5e7c7..2f44353c47 100644 --- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -910,14 +910,16 @@ hsa_status_t GpuAgent::DmaCopy(void* dst, core::Agent& dst_agent, if (core::Runtime::runtime_singleton_->flag().enable_sdma_gang() != Flag::SDMA_DISABLE && size >= 4096 && dst_agent.device_type() == core::Agent::kAmdGpuDevice) gang_factor = gang_peers_info_[dst_agent.public_handle().handle]; - // Use non-D2D (auxillary) SDMA engines in the event of xGMI D2D support // when xGMI SDMA context is not available. - bool has_aux_gang = gang_factor >= properties_.NumSdmaEngines && + bool has_aux_gang = gang_factor > 1 && + gang_factor >= properties_.NumSdmaEngines && !!!properties_.NumSdmaXgmiEngines; - gang_factor = has_aux_gang ? + if (gang_factor > 1) { + gang_factor = has_aux_gang ? std::min(gang_factor, properties_.NumSdmaEngines) : std::min(gang_factor, properties_.NumSdmaXgmiEngines); + } ScopedAcquire lock(&sdma_gang_lock_); if (gang_factor == 1) sdma_gang_lock_.Release();