diff --git a/projects/rocm-smi-lib/include/rocm_smi/rocm_smi.h b/projects/rocm-smi-lib/include/rocm_smi/rocm_smi.h index ec57bf7c78..a2ce6f5f21 100755 --- a/projects/rocm-smi-lib/include/rocm_smi/rocm_smi.h +++ b/projects/rocm-smi-lib/include/rocm_smi/rocm_smi.h @@ -878,6 +878,31 @@ rsmi_status_t rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len); rsmi_status_t rsmi_dev_vendor_name_get(uint32_t dv_ind, char *name, size_t len); +/** + * @brief Get the vram vendor string of a gpu device. + * + * @details Given a device index @p dv_ind, a pointer to a caller provided + * char buffer @p brand, and a length of this buffer @p len, this function + * will write the vram vendor of the device (up to @p len characters) to the + * buffer @p brand. + * + * If the vram vendor for the device is not found as one of the values + * contained within rsmi_dev_vram_vendor_get, then this function will return + * the string 'unknown' instead of the vram vendor. + * + * @param[in] dv_ind a device index + * + * @param[inout] brand a pointer to a caller provided char buffer to which the + * vram vendor will be written + * + * @param[in] len the length of the caller provided buffer @p brand. + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_vram_vendor_get(uint32_t dv_ind, char *brand, + uint32_t len); + /** * @brief Get the serial number string for a device * diff --git a/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_device.h b/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_device.h index f9d700b38a..cc9ff84f39 100755 --- a/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_device.h +++ b/projects/rocm-smi-lib/include/rocm_smi/rocm_smi_device.h @@ -125,6 +125,7 @@ enum DevInfoTypes { kDevMemUsedGTT, kDevMemUsedVisVRAM, kDevMemUsedVRAM, + kDevVramVendor, kDevPCIEReplayCount, kDevUniqueId, kDevDFCountersAvailable, diff --git a/projects/rocm-smi-lib/src/rocm_smi.cc b/projects/rocm-smi-lib/src/rocm_smi.cc index ef3faa5fc2..c7449c144e 100755 --- a/projects/rocm-smi-lib/src/rocm_smi.cc +++ b/projects/rocm-smi-lib/src/rocm_smi.cc @@ -1494,6 +1494,35 @@ rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len) { return RSMI_STATUS_SUCCESS; } +rsmi_status_t +rsmi_dev_vram_vendor_get(uint32_t dv_ind, char *brand, uint32_t len) { + if (brand == nullptr || len == 0) { + return RSMI_STATUS_INVALID_ARGS; + } + + TRY + GET_DEV_FROM_INDX + std::string val_str; + + DEVICE_MUTEX + int ret = dev->readDevInfo(amd::smi::kDevVramVendor, &val_str); + + if (ret != 0) { + return errno_to_rsmi_status(ret); + } + + uint32_t ln = val_str.copy(brand, len); + + brand[std::min(len - 1, ln)] = '\0'; + + if (len < (val_str.size() + 1)) { + return RSMI_STATUS_INSUFFICIENT_SIZE; + } + return RSMI_STATUS_SUCCESS; + + CATCH +} + rsmi_status_t rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t ret; diff --git a/projects/rocm-smi-lib/src/rocm_smi_device.cc b/projects/rocm-smi-lib/src/rocm_smi_device.cc index 64c4efd78b..5e55886b8a 100755 --- a/projects/rocm-smi-lib/src/rocm_smi_device.cc +++ b/projects/rocm-smi-lib/src/rocm_smi_device.cc @@ -100,6 +100,7 @@ static const char *kDevMemTotVRAMFName = "mem_info_vram_total"; 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 *kDevVramVendorFName = "mem_info_vram_vendor"; static const char *kDevPCIEReplayCountFName = "pcie_replay_count"; static const char *kDevUniqueIdFName = "unique_id"; static const char *kDevDFCountersAvailableFName = "df_cntr_avail"; @@ -236,6 +237,7 @@ static const std::map kDevAttribNameMap = { {kDevMemUsedGTT, kDevMemUsedGTTFName}, {kDevMemUsedVisVRAM, kDevMemUsedVisVRAMFName}, {kDevMemUsedVRAM, kDevMemUsedVRAMFName}, + {kDevVramVendor, kDevVramVendorFName}, {kDevPCIEReplayCount, kDevPCIEReplayCountFName}, {kDevUniqueId, kDevUniqueIdFName}, {kDevDFCountersAvailable, kDevDFCountersAvailableFName}, @@ -328,6 +330,7 @@ static std::map kDevInfoVarTypeToRSMIVariant = { static const std::map kDevFuncDependsMap = { // Functions with only mandatory dependencies + {"rsmi_dev_vram_vendor_get", {{kDevVramVendorFName}, {}}}, {"rsmi_dev_id_get", {{kDevDevIDFName}, {}}}, {"rsmi_dev_vendor_id_get", {{kDevVendorIDFName}, {}}}, @@ -747,6 +750,7 @@ int Device::readDevInfo(DevInfoTypes type, std::string *val) { case kDevSubSysDevID: case kDevSubSysVendorID: case kDevVendorID: + case kDevVramVendor: case kDevVBiosVer: case kDevPCIEThruPut: case kDevSerialNumber: diff --git a/projects/rocm-smi-lib/tests/rocm_smi_test/functional/id_info_read.cc b/projects/rocm-smi-lib/tests/rocm_smi_test/functional/id_info_read.cc index 14321fac11..95bf7bc0dc 100755 --- a/projects/rocm-smi-lib/tests/rocm_smi_test/functional/id_info_read.cc +++ b/projects/rocm-smi-lib/tests/rocm_smi_test/functional/id_info_read.cc @@ -127,6 +127,17 @@ void TestIdInfoRead::Run(void) { std::cout << "\t**Device Brand name: " << buffer << std::endl; } } + err = rsmi_dev_vram_vendor_get(i, buffer, kBufferLen); + if (err == RSMI_STATUS_NOT_SUPPORTED) { + std::cout << + "\t**Vram Vendor string not supported on this system." << std::endl; + } else if (err != RSMI_STATUS_SUCCESS) { + CHK_ERR_ASRT(err) + } else { + IF_VERB(STANDARD) { + std::cout << "\t**Device Vram Vendor name: " << buffer << std::endl; + } + } err = rsmi_dev_vendor_id_get(i, &id); if (err != RSMI_STATUS_SUCCESS) { CHK_ERR_ASRT(err)