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) {