From 7364a93b98e13020befa3af833f89247532eb6d7 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Fri, 3 Mar 2023 16:16:20 -0500 Subject: [PATCH] Fix Engine Offsetting for Copy on Engine Forgot SDMA blit engine indices are offset by DevToDev 0-position in a couple of places. Change-Id: Ie811d8281bc812738ed0107694f3dffde5e93685 --- runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 6 +++--- runtime/hsa-runtime/core/runtime/runtime.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index c4acfa6d02..528beb1eff 100644 --- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -807,9 +807,9 @@ hsa_status_t GpuAgent::DmaCopyOnEngine(void* dst, core::Agent& dst_agent, bool limit_h2d_blit = isa_->GetVersion() == core::Isa::Version(9, 0, 10); // Ensure engine selection is within proper range based on transfer type - if ((is_xgmi && engine_offset < properties_.NumSdmaEngines) || - (!is_xgmi && engine_offset >= properties_.NumSdmaEngines) || - (!is_h2d_blit && !is_same_gpu && limit_h2d_blit && !engine_offset)) { + if ((is_xgmi && engine_offset <= properties_.NumSdmaEngines) || + (!is_xgmi && engine_offset > properties_.NumSdmaEngines) || + (!is_h2d_blit && !is_same_gpu && limit_h2d_blit && engine_offset == BlitHostToDev)) { return HSA_STATUS_ERROR_INVALID_ARGUMENT; } diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 2ebe62bdea..4fb212691e 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -511,8 +511,8 @@ hsa_status_t Runtime::CopyMemoryOnEngine(void* dst, core::Agent* dst_agent, cons core::Agent* copy_agent = (src_gpu) ? src_agent : dst_agent; // engine_id is single bitset unique. - int engine_offset = ffs(engine_id) - 1; - if (!engine_id || !!((engine_id >> (engine_offset + 1)))) { + int engine_offset = ffs(engine_id); + if (!engine_id || !!((engine_id >> engine_offset))) { return HSA_STATUS_ERROR_INVALID_ARGUMENT; }