diff --git a/include/rocm_smi/rocm_smi.h b/include/rocm_smi/rocm_smi.h index 6f7850aea8..7203bbde8a 100755 --- a/include/rocm_smi/rocm_smi.h +++ b/include/rocm_smi/rocm_smi.h @@ -784,6 +784,30 @@ rsmi_status_t rsmi_dev_vendor_id_get(uint32_t dv_ind, uint16_t *id); */ rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len); +/** + * @brief Get the brand 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 brand of the device (up to @p len characters) to the buffer + * @p brand. + * + * If the sku associated with the device is not found as one of the values + * contained within rsmi_dev_brand_get, then this function will return the + * device marketing name as a string instead of the brand name. + * + * @param[in] dv_ind a device index + * + * @param[inout] brand a pointer to a caller provided char buffer to which the + * brand 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_brand_get(uint32_t dv_ind, char *brand, size_t len); + /** * @brief Get the name string for a give vendor ID * diff --git a/src/rocm_smi.cc b/src/rocm_smi.cc index 3960e0f53c..873c7b470d 100755 --- a/src/rocm_smi.cc +++ b/src/rocm_smi.cc @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -1421,6 +1422,44 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) { CATCH } +rsmi_status_t +rsmi_dev_brand_get(uint32_t dv_ind, char *brand, size_t len) { + GET_DEV_FROM_INDX + // Return 'invalid args' if arguments are invalid + if (brand == nullptr || len == 0){ + return RSMI_STATUS_INVALID_ARGS; + } + std::map brand_names = + { + {"D05121", "mi25"}, + {"D05131", "mi25"}, + {"D05133", "mi25"}, + {"D05151", "mi25"}, + {"D16304", "mi50"}, + {"D16302", "mi60"} + }; + std::map::iterator it; + std::string vbios_value; + std::string sku_value; + // Retrieve vbios and store in vbios_value string + int ret = dev->readDevInfo(amd::smi::kDevVBiosVer, &vbios_value); + if (ret != 0) { + return errno_to_rsmi_status(ret); + } + if (vbios_value.length() == 16) { + sku_value = vbios_value.substr(4,6); + // Find the brand name using sku_value + it = brand_names.find(sku_value); + if (it != brand_names.end()) { + strcpy(brand, it->second.c_str()); + return RSMI_STATUS_SUCCESS; + } + } + // If there is no SKU match, return marketing name instead + rsmi_dev_name_get(dv_ind, brand, len); + return RSMI_STATUS_SUCCESS; +} + rsmi_status_t rsmi_dev_subsystem_name_get(uint32_t dv_ind, char *name, size_t len) { rsmi_status_t ret; diff --git a/tests/rocm_smi_test/functional/id_info_read.cc b/tests/rocm_smi_test/functional/id_info_read.cc index 92ca8f7d6c..e7e7966204 100755 --- a/tests/rocm_smi_test/functional/id_info_read.cc +++ b/tests/rocm_smi_test/functional/id_info_read.cc @@ -119,6 +119,14 @@ void TestIdInfoRead::Run(void) { std::cout << "\t**Device Marketing name: " << buffer << std::endl; } } + err = rsmi_dev_brand_get(i, buffer, kBufferLen); + if(err != RSMI_STATUS_SUCCESS) { + CHK_ERR_ASRT(err) + } else { + IF_VERB(STANDARD) { + std::cout << "\t**Device Brand name: " << buffer << std::endl; + } + } err = rsmi_dev_vendor_id_get(i, &id); if (err != RSMI_STATUS_SUCCESS) { CHK_ERR_ASRT(err)