Add table for GPU name look to give better name than just "amdgpu"

[ROCm/rocm_smi_lib commit: d39752cee7]
This commit is contained in:
Chris Freehill
2019-03-10 17:56:06 -05:00
parent 5d91dac776
commit da2abd9adc
4 changed files with 32 additions and 9 deletions
+2
View File
@@ -113,6 +113,7 @@ set(SMI_SRC_LIST ${SMI_SRC_LIST} "${SRC_DIR}/rocm_smi_monitor.cc")
set(SMI_SRC_LIST ${SMI_SRC_LIST} "${SRC_DIR}/rocm_smi.cc")
set(SMI_SRC_LIST ${SMI_SRC_LIST} "${SRC_DIR}/rocm_smi_power_mon.cc")
set(SMI_SRC_LIST ${SMI_SRC_LIST} "${SRC_DIR}/rocm_smi_utils.cc")
set(SMI_SRC_LIST ${SMI_SRC_LIST} "${SRC_DIR}/rocm_smi_dev_names.cc")
set(SMI_INC_LIST "${INC_DIR}/rocm_smi_device.h")
set(SMI_INC_LIST ${SMI_INC_LIST} "${INC_DIR}/rocm_smi_main.h")
@@ -121,6 +122,7 @@ set(SMI_INC_LIST ${SMI_INC_LIST} "${INC_DIR}/rocm_smi_power_mon.h")
set(SMI_INC_LIST ${SMI_INC_LIST} "${INC_DIR}/rocm_smi_utils.h")
set(SMI_INC_LIST ${SMI_INC_LIST} "${INC_DIR}/rocm_smi_common.h")
set(SMI_INC_LIST ${SMI_INC_LIST} "${INC_DIR}/rocm_smi_exception.h")
set(SMI_INC_LIST ${SMI_INC_LIST} "${INC_DIR}/rocm_smi_dev_names.h")
set(SMI_EXAMPLE_EXE "rocm_smi_ex")
@@ -1,6 +1,4 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
@@ -108,6 +106,10 @@ typedef enum {
//!< yet been implemented in the
//!< current system for the current
//!< devices
RSMI_STATUS_NOT_FOUND, //!< An item was searched for but not
//!< found
RSMI_STATUS_INSUFFICIENT_SIZE, //!< Not enough resources were
//!< for the operation
RSMI_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF, //!< An unknown error occurred
} rsmi_status_t;
@@ -515,6 +517,9 @@ rsmi_status_t rsmi_dev_id_get(uint32_t dv_ind, uint64_t *id);
* @param[in] len the length of the caller provided buffer @p name.
*
* @retval ::RSMI_STATUS_SUCCESS is returned upon successful call.
* @retval ::RSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not
* large enough to hold the entire name. In this case, only @len bytes will
* be written.
*
*/
rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len);
@@ -808,7 +813,7 @@ rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type,
/** @} */ // end of MemQuer
/** @defgroup PhysQuer Physcial State Queries
/** @defgroup PhysQuer Physical State Queries
* These functions provide information about the physical characteristics of
* the device.
* @{
+19 -3
View File
@@ -57,6 +57,8 @@
#include "rocm_smi/rocm_smi_device.h"
#include "rocm_smi/rocm_smi_utils.h"
#include "rocm_smi/rocm_smi_exception.h"
#include "rocm_smi/rocm_smi_dev_names.h"
#include "rocm_smi/rocm_smi64Config.h"
static const uint32_t kMaxOverdriveLevel = 20;
@@ -403,8 +405,6 @@ static rsmi_status_t get_dev_value_vec(amd::smi::DevInfoTypes type,
return errno_to_rsmi_status(ret);
}
// A call to rsmi_init is not technically necessary at this time, but may be
// in the future.
rsmi_status_t
rsmi_init(uint64_t init_flags) {
TRY
@@ -959,15 +959,31 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) {
std::string val_str;
rsmi_status_t ret;
uint64_t id;
ret = rsmi_dev_id_get(dv_ind, &id);
ret = get_dev_mon_value_str(amd::smi::kMonName, dv_ind, -1, &val_str);
if (ret != RSMI_STATUS_SUCCESS) {
return ret;
}
val_str = get_dev_id_name_map(id);
if (val_str.size() == 0) {
ret = get_dev_mon_value_str(amd::smi::kMonName, dv_ind, -1, &val_str);
if (ret != RSMI_STATUS_SUCCESS) {
return ret;
}
}
size_t ln = val_str.copy(name, len);
name[std::min(len - 1, ln)] = '\0';
if (len < val_str.size()) {
return RSMI_STATUS_INSUFFICIENT_SIZE;
}
return RSMI_STATUS_SUCCESS;
CATCH
}
@@ -112,11 +112,11 @@ void TestBase::PrintDeviceHeader(uint32_t dv_ind) {
}
std::cout << std::setbase(10);
char name[20];
err = rsmi_dev_name_get(dv_ind, name, 20);
char name[128];
err = rsmi_dev_name_get(dv_ind, name, 128);
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Monitor name: " << name << std::endl;
std::cout << "\t**Device name: " << name << std::endl;
}
}
void TestBase::Run(void) {