From 5267cd334b299d88d06301001022b1b766414cb3 Mon Sep 17 00:00:00 2001 From: David Yat Sin <77975354+dayatsin-amd@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:09:56 -0500 Subject: [PATCH] rocr: Refactor SDMA object creation (#2629) Refactor SDMA object creation and add comment to clarify why GCR is not needed on DXG. --- .../hsa-runtime/core/runtime/amd_gpu_agent.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index b20b3edb5b..39b73292d6 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -717,7 +717,13 @@ core::Queue* GpuAgent::CreateInterceptibleQueue(void (*callback)(hsa_status_t st core::Blit* GpuAgent::CreateBlitSdma(bool use_xgmi, int rec_eng) { AMD::BlitSdmaBase* sdma; size_t copy_size_override = 0; - const size_t copy_size_overrides[2] = {0x3fffff, 0x3fffffff}; + constexpr size_t copy_size_overrides[2] = {0x3fffff, 0x3fffffff}; + + /* + * On DXG SDMA packets placed in the queue are wrapped inside GCR packets by + * underlying driver and submitted into another queue. So GCR is not needed. + */ + auto isDXG = core::Runtime::runtime_singleton_->thunkLoader()->IsDXG(); switch (isa_->GetMajorVersion()) { case 9: @@ -726,17 +732,13 @@ core::Blit* GpuAgent::CreateBlitSdma(bool use_xgmi, int rec_eng) { copy_size_overrides[1] : copy_size_overrides[0]; break; case 10: - sdma = new BlitSdmaV5(); + sdma = (isDXG ? static_cast(new BlitSdmaV4()) : static_cast(new BlitSdmaV5())); copy_size_override = isa_->GetMinorVersion() < 3 ? copy_size_overrides[0] : copy_size_overrides[1]; break; case 11: case 12: - if (core::Runtime::runtime_singleton_->thunkLoader()->IsDXG()) { - sdma = new BlitSdmaV4(); - } else { - sdma = new BlitSdmaV5(); - } + sdma = (isDXG ? static_cast(new BlitSdmaV4()) : static_cast(new BlitSdmaV5())); copy_size_override = copy_size_overrides[1]; break; default: