From 3ebe99f96d755daea0dbef832e05a0155bc57b96 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Fri, 29 Apr 2022 16:35:49 -0500 Subject: [PATCH] Add experimental option to force discovery of all copy agents. Discards all user provided async copy agent info and relies on pointer info discovery. Change-Id: Ife3e708a49ffccbede4983ab47d5ed0032970857 --- runtime/hsa-runtime/core/runtime/runtime.cpp | 13 +++++++------ runtime/hsa-runtime/core/util/flag.h | 6 ++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 19d23404f8..46bb521ee9 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -469,8 +469,9 @@ hsa_status_t Runtime::CopyMemory(void* dst, core::Agent* dst_agent, const void* core::Agent* src_agent, size_t size, std::vector& dep_signals, core::Signal& completion_signal) { + auto lookupAgent = [this](core::Agent* agent, const void* ptr) { - if (agent == nullptr) { + if (agent == nullptr || flag().discover_copy_agents()) { hsa_amd_pointer_info_t info; PtrInfoBlockData block; info.size = sizeof(info); @@ -628,11 +629,11 @@ hsa_status_t Runtime::GetSystemInfo(hsa_system_info_t attribute, void* value) { break; } case HSA_AMD_SYSTEM_INFO_SVM_SUPPORTED: { - bool ret = true; - for (auto agent : gpu_agents_) { - AMD::GpuAgent* gpu = (AMD::GpuAgent*)agent; - ret &= (gpu->properties().Capability.ui32.SVMAPISupported == 1); - } + bool ret = true; + for (auto agent : gpu_agents_) { + AMD::GpuAgent* gpu = (AMD::GpuAgent*)agent; + ret &= (gpu->properties().Capability.ui32.SVMAPISupported == 1); + } *(bool*)value = ret; break; } diff --git a/runtime/hsa-runtime/core/util/flag.h b/runtime/hsa-runtime/core/util/flag.h index 045a6d0c1a..d90df97289 100644 --- a/runtime/hsa-runtime/core/util/flag.h +++ b/runtime/hsa-runtime/core/util/flag.h @@ -153,6 +153,9 @@ class Flag { // Will become opt-out and possibly removed in future releases. var = os::GetEnvVar("HSA_COOP_CU_COUNT"); coop_cu_count_ = (var == "1") ? true : false; + + var = os::GetEnvVar("HSA_DISCOVER_COPY_AGENTS"); + discover_copy_agents_ = (var == "1") ? true : false; } void parse_masks(uint32_t maxGpu, uint32_t maxCU) { @@ -221,6 +224,8 @@ class Flag { bool coop_cu_count() const { return coop_cu_count_; } + bool discover_copy_agents() const { return discover_copy_agents_; } + private: bool check_flat_scratch_; bool enable_vm_fault_message_; @@ -241,6 +246,7 @@ class Flag { bool debug_; bool cu_mask_skip_init_; bool coop_cu_count_; + bool discover_copy_agents_; SDMA_OVERRIDE enable_sdma_;