From 6525bb1a5daba190fe81236af4250b21d4089b61 Mon Sep 17 00:00:00 2001 From: Yiannis Papadopoulos Date: Wed, 23 Oct 2024 01:16:44 +0000 Subject: [PATCH] rocr/aie: Remove unused set container and error when using AIE agents in MemoryRegion Change-Id: Icf1e56412c840810a679f376293a616068841b8c [ROCm/ROCR-Runtime commit: c7785a6da1c10c25bc8d527c00b1fe79bfbd84c9] --- .../core/runtime/amd_memory_region.cpp | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp index 5bce5c7991..efe40d4ac9 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp @@ -43,7 +43,6 @@ #include "core/inc/amd_memory_region.h" #include -#include #include "core/inc/runtime.h" #include "core/inc/amd_cpu_agent.h" @@ -507,7 +506,6 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents, bool cpu_in_list = false; - std::set whitelist_gpus; std::vector whitelist_nodes; for (uint32_t i = 0; i < num_agents; ++i) { core::Agent* agent = core::Agent::Convert(agents[i]); @@ -515,11 +513,16 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents, return HSA_STATUS_ERROR_INVALID_AGENT; } - if (agent->device_type() == core::Agent::kAmdGpuDevice) { + switch (agent->device_type()) { + case core::Agent::kAmdGpuDevice: whitelist_nodes.push_back(agent->node_id()); - whitelist_gpus.insert(reinterpret_cast(agent)); - } else { + break; + case core::Agent::kAmdCpuDevice: cpu_in_list = true; + break; + case core::Agent::kAmdAieDevice: + default: + return HSA_STATUS_ERROR_INVALID_AGENT; } } @@ -537,7 +540,6 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents, std::find(whitelist_nodes.begin(), whitelist_nodes.end(), owner()->node_id()) == whitelist_nodes.end()) { whitelist_nodes.push_back(owner()->node_id()); - whitelist_gpus.insert(reinterpret_cast(owner())); } HsaMemMapFlags map_flag = map_flag_; @@ -583,15 +585,10 @@ hsa_status_t MemoryRegion::Lock(uint32_t num_agents, const hsa_agent_t* agents, return HSA_STATUS_SUCCESS; } - std::set whitelist_gpus; std::vector whitelist_nodes; if (num_agents == 0 || agents == NULL) { // Map to all GPU agents. whitelist_nodes = core::Runtime::runtime_singleton_->gpu_ids(); - - whitelist_gpus.insert( - core::Runtime::runtime_singleton_->gpu_agents().begin(), - core::Runtime::runtime_singleton_->gpu_agents().end()); } else { for (uint32_t i = 0; i < num_agents; ++i) { core::Agent* agent = core::Agent::Convert(agents[i]); @@ -599,9 +596,16 @@ hsa_status_t MemoryRegion::Lock(uint32_t num_agents, const hsa_agent_t* agents, return HSA_STATUS_ERROR_INVALID_AGENT; } - if (agent->device_type() == core::Agent::kAmdGpuDevice) { + switch (agent->device_type()) { + case core::Agent::kAmdGpuDevice: whitelist_nodes.push_back(agent->node_id()); - whitelist_gpus.insert(agent); + break; + case core::Agent::kAmdCpuDevice: + // Do nothing. + break; + case core::Agent::kAmdAieDevice: + default: + return HSA_STATUS_ERROR_INVALID_AGENT; } } }