diff --git a/src/rocm_smi.cc b/src/rocm_smi.cc index 60d59c20db..2e5094470a 100755 --- a/src/rocm_smi.cc +++ b/src/rocm_smi.cc @@ -4011,11 +4011,47 @@ rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *unique_id) { CHK_SUPPORT_NAME_ONLY(unique_id) DEVICE_MUTEX + if (unique_id == nullptr) { + return RSMI_STATUS_INVALID_ARGS; + } + *unique_id = std::numeric_limits::max(); ret = get_dev_value_int(amd::smi::kDevUniqueId, dv_ind, unique_id); + + ss << __PRETTY_FUNCTION__ + << (ret == RSMI_STATUS_SUCCESS ? + " | No fall back needed retrieved from KGD" : " | fall back needed") + << " | Device #: " << std::to_string(dv_ind) + << " | Data: unique_id = " << std::to_string(*unique_id) + << " | ret = " << getRSMIStatusString(ret, false); + LOG_DEBUG(ss); + // If the unique ID is not supported, use KFD's unique ID + if (ret != RSMI_STATUS_SUCCESS) { + GET_DEV_AND_KFDNODE_FROM_INDX + uint32_t node_id; + uint64_t kfd_unique_id; + int ret_kfd = kfd_node->get_node_id(&node_id); + ret_kfd = amd::smi::read_node_properties(node_id, "unique_id", &kfd_unique_id); + if (ret_kfd == 0) { + *unique_id = kfd_unique_id; + ret = RSMI_STATUS_SUCCESS; + } else { + *unique_id = std::numeric_limits::max(); + ret = RSMI_STATUS_NOT_SUPPORTED; + } + ss << __PRETTY_FUNCTION__ + << " | Issue: Could not read unique_id from sysfs, falling back to KFD" << "\n" + << " ; Device #: " << std::to_string(dv_ind) << "\n" + << " ; ret_kfd: " << std::to_string(ret_kfd) << "\n" + << " ; node: " << std::to_string(node_id) << "\n" + << " ; Data: unique_id (from KFD)= " << std::to_string(*unique_id) << "\n" + << " ; ret = " << getRSMIStatusString(ret, false); + LOG_DEBUG(ss); + } return ret; CATCH } + rsmi_status_t rsmi_dev_counter_create(uint32_t dv_ind, rsmi_event_type_t type, rsmi_event_handle_t *evnt_handle) { diff --git a/src/rocm_smi_kfd.cc b/src/rocm_smi_kfd.cc index ae1f9bc25a..98100b933b 100755 --- a/src/rocm_smi_kfd.cc +++ b/src/rocm_smi_kfd.cc @@ -1051,6 +1051,7 @@ int KFDNode::get_node_id(uint32_t *node_id) { int ret = 0; std::string nodeid_path = "/sys/class/kfd/kfd/topology/nodes/" + std::to_string(this->node_indx_); + *node_id = this->node_indx_; ss << __PRETTY_FUNCTION__ << " | File: " << nodeid_path << " | Read node #: " << std::to_string(this->node_indx_) @@ -1058,7 +1059,6 @@ int KFDNode::get_node_id(uint32_t *node_id) { << " | Return: " << getRSMIStatusString(amd::smi::ErrnoToRsmiStatus(ret), false) << " | "; - *node_id = this->node_indx_; LOG_DEBUG(ss); return ret; }