From 4b44183941b5447067d058ef4f00538c74ed0866 Mon Sep 17 00:00:00 2001 From: "Besar Wicaksono (xN/A) TX [TEXT]" Date: Wed, 13 Apr 2016 12:39:25 -0500 Subject: [PATCH] Fix query HSA_AMD_AGENT_MEMORY_POOL_INFO_LINK_INFO Querying HSA_AMD_AGENT_MEMORY_POOL_INFO_LINK_INFO between a gpu agent and its own local memory pool returns a wrong information. Fix: return link with 0 hop count. [git-p4: depot-paths = "//depot/stg/hsa/drivers/hsa/runtime/": change = 1257544] [ROCm/ROCR-Runtime commit: 5a584fa1ab4d1ce9d194c8402c157321f55d7b88] --- .../rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h | 4 +++- .../runtime/hsa-runtime/core/runtime/runtime.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h index 1f6d68b72c..d3c6f8b9f4 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h @@ -87,6 +87,8 @@ class Runtime { public: /// @brief Structure to describe connectivity between agents. struct LinkInfo { + LinkInfo() : num_hop(0), info{0} {} + uint32_t num_hop; hsa_amd_memory_pool_link_info_t info; }; @@ -133,7 +135,7 @@ class Runtime { /// @param [in] node_id_from Node id of the source node. /// @param [in] node_id_to Node id of the destination node. /// @retval The link information between source and destination nodes. - const LinkInfo& GetLinkInfo(uint32_t node_id_from, uint32_t node_id_to); + const LinkInfo GetLinkInfo(uint32_t node_id_from, uint32_t node_id_to); /// @brief Invoke the user provided call back for each agent in the agent /// list. diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp index bccd952145..8449b8e7fe 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -263,9 +263,11 @@ void Runtime::RegisterLinkInfo(uint32_t node_id_from, uint32_t node_id_to, link_matrix_[idx].info = link_info; } -const Runtime::LinkInfo& Runtime::GetLinkInfo(uint32_t node_id_from, - uint32_t node_id_to) { - return link_matrix_[GetIndexLinkInfo(node_id_from, node_id_to)]; +const Runtime::LinkInfo Runtime::GetLinkInfo(uint32_t node_id_from, + uint32_t node_id_to) { + return (node_id_from != node_id_to) + ? link_matrix_[GetIndexLinkInfo(node_id_from, node_id_to)] + : LinkInfo(); // No link. } uint32_t Runtime::GetIndexLinkInfo(uint32_t node_id_from, uint32_t node_id_to) {