From f0078707928cefed9a6ea8137843c03696bb309e Mon Sep 17 00:00:00 2001 From: Ramesh Errabolu Date: Tue, 28 Aug 2018 16:20:03 -0500 Subject: [PATCH] ROCr changes to enable small BAR P2P over xGMI Change-Id: I6aaa3fe2565cdf7e15d58a7484d6bd5916ffff64 --- runtime/hsa-runtime/core/runtime/amd_memory_region.cpp | 4 ++-- runtime/hsa-runtime/core/runtime/amd_topology.cpp | 6 ++++++ runtime/hsa-runtime/core/runtime/runtime.cpp | 9 +++------ runtime/hsa-runtime/inc/hsa_ext_amd.h | 7 ++++++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp b/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp index 4ed0f627b0..a293f383cd 100644 --- a/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_memory_region.cpp @@ -408,7 +408,7 @@ hsa_status_t MemoryRegion::GetAgentPoolInfo( ((IsSystem() && (agent.device_type() == core::Agent::kAmdCpuDevice)) || (agent.node_id() == owner()->node_id())) ? HSA_AMD_MEMORY_POOL_ACCESS_ALLOWED_BY_DEFAULT - : (IsSystem() || (IsPublic() && link_info.num_hop > 0)) + : (IsSystem() || (IsLocalMemory() && link_info.num_hop > 0)) ? HSA_AMD_MEMORY_POOL_ACCESS_DISALLOWED_BY_DEFAULT : HSA_AMD_MEMORY_POOL_ACCESS_NEVER_ALLOWED; @@ -502,7 +502,7 @@ hsa_status_t MemoryRegion::AllowAccess(uint32_t num_agents, // If this is a local memory region, the owning gpu always needs to be in // the whitelist. - if (IsPublic() && + if (IsLocalMemory() && std::find(whitelist_nodes.begin(), whitelist_nodes.end(), owner()->node_id()) == whitelist_nodes.end()) { whitelist_nodes.push_back(owner()->node_id()); diff --git a/runtime/hsa-runtime/core/runtime/amd_topology.cpp b/runtime/hsa-runtime/core/runtime/amd_topology.cpp index 3f60d6034c..bf41ebfc57 100644 --- a/runtime/hsa-runtime/core/runtime/amd_topology.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_topology.cpp @@ -120,6 +120,12 @@ void RegisterLinkInfo(uint32_t node_id, uint32_t num_link) { link_info.link_type = HSA_AMD_LINK_INFO_TYPE_INFINBAND; debug_print("IOLINK is missing atomic and coherency defaults.\n"); break; + case HSA_IOLINK_TYPE_XGMI: + link_info.link_type = HSA_AMD_LINK_INFO_TYPE_XGMI; + link_info.atomic_support_32bit = true; + link_info.atomic_support_64bit = true; + link_info.coherent_support = true; + break; default: debug_print("Unrecognized IOLINK type.\n"); break; diff --git a/runtime/hsa-runtime/core/runtime/runtime.cpp b/runtime/hsa-runtime/core/runtime/runtime.cpp index 00d52b9f1f..9444edcc8f 100644 --- a/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -252,9 +252,8 @@ void Runtime::DestroyAgents() { system_regions_coarse_.clear(); } -void Runtime::SetLinkCount(size_t num_link) { - const size_t last_index = GetIndexLinkInfo(0, num_link); - link_matrix_.resize(last_index); +void Runtime::SetLinkCount(size_t num_nodes) { + link_matrix_.resize(num_nodes * num_nodes); } void Runtime::RegisterLinkInfo(uint32_t node_id_from, uint32_t node_id_to, @@ -277,9 +276,7 @@ const Runtime::LinkInfo Runtime::GetLinkInfo(uint32_t node_id_from, } uint32_t Runtime::GetIndexLinkInfo(uint32_t node_id_from, uint32_t node_id_to) { - const uint32_t node_id_max = std::max(node_id_from, node_id_to) - 1; - const uint32_t node_id_min = std::min(node_id_from, node_id_to); - return ((node_id_max * (node_id_max + 1) / 2) + node_id_min); + return ((node_id_from * agents_by_node_.size()) + node_id_to); } hsa_status_t Runtime::IterateAgent(hsa_status_t (*callback)(hsa_agent_t agent, diff --git a/runtime/hsa-runtime/inc/hsa_ext_amd.h b/runtime/hsa-runtime/inc/hsa_ext_amd.h index bcde6ba390..2e5f75cda2 100644 --- a/runtime/hsa-runtime/inc/hsa_ext_amd.h +++ b/runtime/hsa-runtime/inc/hsa_ext_amd.h @@ -962,7 +962,12 @@ typedef enum { /** * Infiniband bus type. */ - HSA_AMD_LINK_INFO_TYPE_INFINBAND = 3 + HSA_AMD_LINK_INFO_TYPE_INFINBAND = 3, + + /** + * xGMI link type. + */ + HSA_AMD_LINK_INFO_TYPE_XGMI = 4 } hsa_amd_link_info_type_t;