diff --git a/docs/ROCm_SMI_Manual.pdf b/docs/ROCm_SMI_Manual.pdf index b6da2a742c..5869a0e5bb 100644 Binary files a/docs/ROCm_SMI_Manual.pdf and b/docs/ROCm_SMI_Manual.pdf differ diff --git a/include/rocm_smi/rocm_smi.h b/include/rocm_smi/rocm_smi.h index 4311042bfd..fb06bab96b 100755 --- a/include/rocm_smi/rocm_smi.h +++ b/include/rocm_smi/rocm_smi.h @@ -726,6 +726,22 @@ rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len); */ rsmi_status_t rsmi_dev_subsystem_vendor_id_get(uint32_t dv_ind, uint16_t *id); +/** + * @brief Get Unique ID + * + * @details Given a device index @p dv_ind and a pointer to a uint64_t @p + * id, this function will write the unique ID of the GPU pointed to @p + * id. + * + * @param[in] dv_ind a device index + * + * @param[inout] id a pointer to uint64_t to which the unique ID of the GPU + * is written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + */ +rsmi_status_t rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *id); + /** @} */ // end of IDQuer /*****************************************************************************/ diff --git a/include/rocm_smi/rocm_smi_device.h b/include/rocm_smi/rocm_smi_device.h index c7fcad7dc1..a046ff1f87 100755 --- a/include/rocm_smi/rocm_smi_device.h +++ b/include/rocm_smi/rocm_smi_device.h @@ -91,6 +91,7 @@ enum DevInfoTypes { kDevMemUsedVisVRAM, kDevMemUsedVRAM, kDevPCIEReplayCount, + kDevUniqueId, }; class Device { diff --git a/src/rocm_smi.cc b/src/rocm_smi.cc index 7445194d61..abebe01e11 100755 --- a/src/rocm_smi.cc +++ b/src/rocm_smi.cc @@ -2107,3 +2107,14 @@ rsmi_dev_pci_replay_counter_get(uint32_t dv_ind, uint64_t *counter) { CATCH } +rsmi_status_t +rsmi_dev_unique_id_get(uint32_t dv_ind, uint64_t *unique_id) { + TRY + DEVICE_MUTEX + rsmi_status_t ret; + + ret = get_dev_value_int(amd::smi::kDevUniqueId, dv_ind, unique_id); + return ret; + + CATCH +} diff --git a/src/rocm_smi_device.cc b/src/rocm_smi_device.cc index fbbe6fdc97..0b145d1230 100755 --- a/src/rocm_smi_device.cc +++ b/src/rocm_smi_device.cc @@ -97,6 +97,7 @@ static const char *kDevMemUsedGTTFName = "mem_info_gtt_used"; static const char *kDevMemUsedVisVRAMFName = "mem_info_vis_vram_used"; static const char *kDevMemUsedVRAMFName = "mem_info_vram_used"; static const char *kDevPCIEReplayCountFName = "pcie_replay_count"; +static const char *kDevUniqueIdFName = "unique_id"; // Strings that are found within sysfs files static const char *kDevPerfLevelAutoStr = "auto"; @@ -138,6 +139,7 @@ static const std::map kDevAttribNameMap = { {kDevMemUsedVisVRAM, kDevMemUsedVisVRAMFName}, {kDevMemUsedVRAM, kDevMemUsedVRAMFName}, {kDevPCIEReplayCount, kDevPCIEReplayCountFName}, + {kDevUniqueId, kDevUniqueIdFName}, }; static const std::map kDevPerfLvlMap = { @@ -374,6 +376,11 @@ int Device::readDevInfo(DevInfoTypes type, uint64_t *val) { RET_IF_NONZERO(ret); *val = std::stoul(tempStr, 0); break; + case kDevUniqueId: + ret = readDevInfoStr(type, &tempStr); + RET_IF_NONZERO(ret); + *val = std::stoul(tempStr, 0, 16); + break; default: return -1; diff --git a/tests/rocm_smi_test/functional/sys_info_read.cc b/tests/rocm_smi_test/functional/sys_info_read.cc index 50bd97a0bf..143f9fa6a0 100755 --- a/tests/rocm_smi_test/functional/sys_info_read.cc +++ b/tests/rocm_smi_test/functional/sys_info_read.cc @@ -120,6 +120,19 @@ void TestSysInfoRead::Run(void) { std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; } + err = rsmi_dev_unique_id_get(i, &val_ui64); + if (err == RSMI_STATUS_NOT_SUPPORTED) { + std::cout << + "\t**rsmi_dev_unique_id() is not supported" + " on this machine" << std::endl; + } else { + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**GPU Unique ID : " << std::hex << val_ui64 << + std::endl; + } + } + err = rsmi_version_get(&ver); CHK_ERR_ASRT(err)