[SWDEV-529483] Get Vram Vendor Name from Driver (#323)

* Update to remove vram enum and instead use the string directly from the driver.

Signed-off-by: Narlo, Joseph <Joseph.Narlo@amd.com>
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Tento commit je obsažen v:
Narlo, Joseph
2025-05-28 17:57:49 -05:00
odevzdal GitHub
rodič cebc512b1a
revize f71ae88956
9 změnil soubory, kde provedl 74 přidání a 123 odebrání
+54
Zobrazit soubor
@@ -4,10 +4,64 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
***All information listed below is for reference and subject to change.***
## amd_smi_lib for ROCm 7.0.0
### Added
- N/A
### Changed
- **The `amdsmi_get_gpu_vram_info` command gets the vendor name from the driver instead of using an emun to identify vendor.**
- `amdsmi_vram_info_t` member named `amdsmi_vram_vendor_type_t` was changed to a character string
- `amdsmi_vram_vendor_type_t` enum structure was removed
### Removed
- N/A
### Optimized
- N/A
### Resolved issues
- N/A
### Upcoming changes
- N/A
### Known issues
- N/A
## amd_smi_lib for ROCm 6.5.0
### Added
- **Added bad page threshold count**.
- Added `amdsmi_get_gpu_bad_page_threshold` to Python API and CLI; root/sudo permissions required to display the count.
### Changed
- **The `amd-smi topology` command has been enabled for Guest environments**.
- `amd-smi topology` is now availabe in Guest environments. This includes full functionality so users can use the command just as they would in Bare Metal environments.
- **Updated `amdsmi_get_clock_info` in `amdsmi_interface.py`**.
- The `clk_deep_sleep` field now returns the sleep integer value.
### Removed
### Optimized
### Resolved issues
### Upcoming changes
### Known issues
- **Added cpu model name for RDC**.
- Added new C and Python API `amdsmi_get_cpu_model_name`
- Not sourced from esmi library.
+1 -5
Zobrazit soubor
@@ -869,13 +869,9 @@ class AMDSMICommands():
vram_type = vram_type.replace('AMDSMI_VRAM_TYPE_', '').replace('_', '')
# Get vram vendor string
vram_vendor_enum = vram_info['vram_vendor']
vram_vendor = amdsmi_interface.amdsmi_wrapper.amdsmi_vram_vendor_type_t__enumvalues[vram_vendor_enum]
vram_vendor = vram_info['vram_vendor']
if "PLACEHOLDER" in vram_vendor:
vram_vendor = "N/A"
else:
# Remove amdsmi enum prefix
vram_vendor = vram_vendor.replace('AMDSMI_VRAM_VENDOR_', '')
# Assign cleaned values to vram_info_dict
vram_info_dict['type'] = vram_type
+1 -20
Zobrazit soubor
@@ -580,25 +580,6 @@ typedef enum {
AMDSMI_VRAM_TYPE__MAX = AMDSMI_VRAM_TYPE_GDDR7
} amdsmi_vram_type_t;
/**
* @brief VRam Vendor Types
*
* @cond @tag{gpu_bm_linux} @tag{host} @endcond
*/
typedef enum {
AMDSMI_VRAM_VENDOR_SAMSUNG,
AMDSMI_VRAM_VENDOR_INFINEON,
AMDSMI_VRAM_VENDOR_ELPIDA,
AMDSMI_VRAM_VENDOR_ETRON,
AMDSMI_VRAM_VENDOR_NANYA,
AMDSMI_VRAM_VENDOR_HYNIX,
AMDSMI_VRAM_VENDOR_MOSEL,
AMDSMI_VRAM_VENDOR_WINBOND,
AMDSMI_VRAM_VENDOR_ESMT,
AMDSMI_VRAM_VENDOR_MICRON,
AMDSMI_VRAM_VENDOR_UNKNOWN
} amdsmi_vram_vendor_type_t;
/**
* @brief This structure represents a range (e.g., frequencies or voltages).
*
@@ -979,7 +960,7 @@ typedef struct {
*/
typedef struct {
amdsmi_vram_type_t vram_type;
amdsmi_vram_vendor_type_t vram_vendor;
char vram_vendor[AMDSMI_MAX_STRING_LENGTH];
uint64_t vram_size; //!< vram size in MB
uint32_t vram_bit_width; //!< In bits
uint64_t vram_max_bandwidth; //!< The VRAM max bandwidth at current memory clock (GB/s)
-1
Zobrazit soubor
@@ -282,7 +282,6 @@ from .amdsmi_interface import AmdSmiUtilizationCounterType
from .amdsmi_interface import AmdSmiProcessorType
from .amdsmi_interface import AmdSmiVirtualizationMode
from .amdsmi_interface import AmdSmiVramType
from .amdsmi_interface import AmdSmiVramVendor
from .amdsmi_interface import AmdSmiAffinityScope
# Exceptions
+1 -15
Zobrazit soubor
@@ -507,20 +507,6 @@ class AmdSmiVramType(IntEnum):
GDDR7 = amdsmi_wrapper.AMDSMI_VRAM_TYPE_GDDR7
MAX = amdsmi_wrapper.AMDSMI_VRAM_TYPE__MAX
class AmdSmiVramVendor(IntEnum):
SAMSUNG = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_SAMSUNG
INFINEON = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_INFINEON
ELPIDA = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_ELPIDA
ETRON = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_ETRON
NANYA = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_NANYA
HYNIX = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_HYNIX
MOSEL = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_MOSEL
WINBOND = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_WINBOND
ESMT = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_ESMT
MICRON = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_MICRON
UNKNOWN = amdsmi_wrapper.AMDSMI_VRAM_VENDOR_UNKNOWN
class AmdSmiAffinityScope(IntEnum):
NUMA_SCOPE = amdsmi_wrapper.AMDSMI_AFFINITY_SCOPE_NODE
SOCKET_SCOPE = amdsmi_wrapper.AMDSMI_AFFINITY_SCOPE_SOCKET
@@ -2071,7 +2057,7 @@ def amdsmi_get_gpu_vram_info(
)
return {
"vram_type": vram_info.vram_type,
"vram_vendor": vram_info.vram_vendor,
"vram_vendor": vram_info.vram_vendor.decode("utf-8"),
"vram_size": vram_info.vram_size,
"vram_bit_width": _validate_if_max_uint(vram_info.vram_bit_width, MaxUIntegerTypes.UINT32_T),
"vram_max_bandwidth": _validate_if_max_uint(vram_info.vram_max_bandwidth, MaxUIntegerTypes.UINT64_T),
+9 -40
Zobrazit soubor
@@ -704,33 +704,6 @@ AMDSMI_VRAM_TYPE_GDDR6 = 22
AMDSMI_VRAM_TYPE_GDDR7 = 23
AMDSMI_VRAM_TYPE__MAX = 23
amdsmi_vram_type_t = ctypes.c_uint32 # enum
# values for enumeration 'amdsmi_vram_vendor_type_t'
amdsmi_vram_vendor_type_t__enumvalues = {
0: 'AMDSMI_VRAM_VENDOR_SAMSUNG',
1: 'AMDSMI_VRAM_VENDOR_INFINEON',
2: 'AMDSMI_VRAM_VENDOR_ELPIDA',
3: 'AMDSMI_VRAM_VENDOR_ETRON',
4: 'AMDSMI_VRAM_VENDOR_NANYA',
5: 'AMDSMI_VRAM_VENDOR_HYNIX',
6: 'AMDSMI_VRAM_VENDOR_MOSEL',
7: 'AMDSMI_VRAM_VENDOR_WINBOND',
8: 'AMDSMI_VRAM_VENDOR_ESMT',
9: 'AMDSMI_VRAM_VENDOR_MICRON',
10: 'AMDSMI_VRAM_VENDOR_UNKNOWN',
}
AMDSMI_VRAM_VENDOR_SAMSUNG = 0
AMDSMI_VRAM_VENDOR_INFINEON = 1
AMDSMI_VRAM_VENDOR_ELPIDA = 2
AMDSMI_VRAM_VENDOR_ETRON = 3
AMDSMI_VRAM_VENDOR_NANYA = 4
AMDSMI_VRAM_VENDOR_HYNIX = 5
AMDSMI_VRAM_VENDOR_MOSEL = 6
AMDSMI_VRAM_VENDOR_WINBOND = 7
AMDSMI_VRAM_VENDOR_ESMT = 8
AMDSMI_VRAM_VENDOR_MICRON = 9
AMDSMI_VRAM_VENDOR_UNKNOWN = 10
amdsmi_vram_vendor_type_t = ctypes.c_uint32 # enum
class struct_amdsmi_range_t(Structure):
pass
@@ -1177,10 +1150,11 @@ class struct_amdsmi_vram_info_t(Structure):
struct_amdsmi_vram_info_t._pack_ = 1 # source:False
struct_amdsmi_vram_info_t._fields_ = [
('vram_type', amdsmi_vram_type_t),
('vram_vendor', amdsmi_vram_vendor_type_t),
('vram_vendor', ctypes.c_char * 256),
('PADDING_0', ctypes.c_ubyte * 4),
('vram_size', ctypes.c_uint64),
('vram_bit_width', ctypes.c_uint32),
('PADDING_0', ctypes.c_ubyte * 4),
('PADDING_1', ctypes.c_ubyte * 4),
('vram_max_bandwidth', ctypes.c_uint64),
('reserved', ctypes.c_uint64 * 4),
]
@@ -3191,14 +3165,9 @@ __all__ = \
'AMDSMI_VRAM_TYPE_HBM', 'AMDSMI_VRAM_TYPE_HBM2',
'AMDSMI_VRAM_TYPE_HBM2E', 'AMDSMI_VRAM_TYPE_HBM3',
'AMDSMI_VRAM_TYPE_UNKNOWN', 'AMDSMI_VRAM_TYPE__MAX',
'AMDSMI_VRAM_VENDOR_ELPIDA', 'AMDSMI_VRAM_VENDOR_ESMT',
'AMDSMI_VRAM_VENDOR_ETRON', 'AMDSMI_VRAM_VENDOR_HYNIX',
'AMDSMI_VRAM_VENDOR_INFINEON', 'AMDSMI_VRAM_VENDOR_MICRON',
'AMDSMI_VRAM_VENDOR_MOSEL', 'AMDSMI_VRAM_VENDOR_NANYA',
'AMDSMI_VRAM_VENDOR_SAMSUNG', 'AMDSMI_VRAM_VENDOR_UNKNOWN',
'AMDSMI_VRAM_VENDOR_WINBOND', 'AMDSMI_XGMI_LINK_DISABLE',
'AMDSMI_XGMI_LINK_DOWN', 'AMDSMI_XGMI_LINK_UP',
'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS',
'AMDSMI_XGMI_LINK_DISABLE', 'AMDSMI_XGMI_LINK_DOWN',
'AMDSMI_XGMI_LINK_UP', 'AMDSMI_XGMI_STATUS_ERROR',
'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS',
'AMDSMI_XGMI_STATUS_NO_ERRORS', 'CLK_LIMIT_MAX', 'CLK_LIMIT_MIN',
'RD_BW0', 'WR_BW0', 'amd_metrics_table_header_t',
'amdsmi_accelerator_partition_profile_config_t',
@@ -3233,7 +3202,8 @@ __all__ = \
'amdsmi_fw_info_t', 'amdsmi_get_afids_from_cper',
'amdsmi_get_cpu_affinity_with_scope',
'amdsmi_get_clk_freq', 'amdsmi_get_clock_info',
'amdsmi_get_cpu_cclk_limit', 'amdsmi_get_cpu_core_boostlimit',
'amdsmi_get_cpu_affinity_with_scope', 'amdsmi_get_cpu_cclk_limit',
'amdsmi_get_cpu_core_boostlimit',
'amdsmi_get_cpu_core_current_freq_limit',
'amdsmi_get_cpu_core_energy', 'amdsmi_get_cpu_cores_per_socket',
'amdsmi_get_cpu_current_io_bandwidth',
@@ -3378,8 +3348,7 @@ __all__ = \
'amdsmi_version_t', 'amdsmi_violation_status_t',
'amdsmi_virtualization_mode_t', 'amdsmi_voltage_metric_t',
'amdsmi_voltage_type_t', 'amdsmi_vram_info_t',
'amdsmi_vram_type_t', 'amdsmi_vram_usage_t',
'amdsmi_vram_vendor_type_t', 'amdsmi_xgmi_info_t',
'amdsmi_vram_type_t', 'amdsmi_vram_usage_t', 'amdsmi_xgmi_info_t',
'amdsmi_xgmi_link_status_t', 'amdsmi_xgmi_link_status_type_t',
'amdsmi_xgmi_status_t', 'processor_type_t', 'size_t',
'struct__links', 'struct_amd_metrics_table_header_t',
+6 -24
Zobrazit soubor
@@ -1755,7 +1755,7 @@ amdsmi_status_t amdsmi_get_gpu_vram_info(
// init the info structure with default value
info->vram_type = AMDSMI_VRAM_TYPE_UNKNOWN;
info->vram_size = 0;
info->vram_vendor = AMDSMI_VRAM_VENDOR_UNKNOWN;
strncpy(info->vram_vendor, "UNKNOWN", AMDSMI_MAX_STRING_LENGTH);
info->vram_bit_width = std::numeric_limits<decltype(info->vram_bit_width)>::max();
info->vram_max_bandwidth = std::numeric_limits<decltype(info->vram_max_bandwidth)>::max();
@@ -1849,30 +1849,12 @@ amdsmi_status_t amdsmi_get_gpu_vram_info(
info->vram_type = AMDSMI_VRAM_TYPE_UNKNOWN;
// map the vendor name to enum
char brand[256];
r = rsmi_wrapper(rsmi_dev_vram_vendor_get, processor_handle, 0,
brand, 255);
char brand[256] = {'\0'};
r = rsmi_wrapper(rsmi_dev_vram_vendor_get, processor_handle, 0, brand, 255);
if (r == AMDSMI_STATUS_SUCCESS) {
if (strcasecmp(brand, "SAMSUNG") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_SAMSUNG;
if (strcasecmp(brand, "INFINEON") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_INFINEON;
if (strcasecmp(brand, "ELPIDA") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_ELPIDA;
if (strcasecmp(brand, "ETRON") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_ETRON;
if (strcasecmp(brand, "NANYA") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_NANYA;
if (strcasecmp(brand, "HYNIX") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_HYNIX;
if (strcasecmp(brand, "MOSEL") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_MOSEL;
if (strcasecmp(brand, "WINBOND") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_WINBOND;
if (strcasecmp(brand, "ESMT") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_ESMT;
if (strcasecmp(brand, "MICRON") == 0)
info->vram_vendor = AMDSMI_VRAM_VENDOR_MICRON;
for (auto &x : brand)
x = static_cast<char>(toupper(x));
strncpy(info->vram_vendor, brand, AMDSMI_MAX_STRING_LENGTH);
}
uint64_t total = 0;
r = rsmi_wrapper(rsmi_dev_memory_total_get, processor_handle, 0,
+1 -3
Zobrazit soubor
@@ -139,9 +139,7 @@ void TestIdInfoRead::Run(void) {
IF_VERB(STANDARD) {
std::cout << "\t**Device Vram type id: "
<< vram_info.vram_type << std::endl;
std::cout << "\t**Device Vram vendor id: 0x"
<< std::hex << std::setw(4) << std::setfill('0') << vram_info.vram_vendor
<< " (" << std::dec << vram_info.vram_vendor << ")" << std::endl;
std::cout << "\t**Device Vram vendor id: " << vram_info.vram_vendor << std::endl;
std::cout << "\t**Device Vram size: 0x"
<< std::hex << vram_info.vram_size
<< " (" << std::dec << vram_info.vram_size << ")"
+1 -15
Zobrazit soubor
@@ -152,25 +152,11 @@ class TestAmdSmiPythonInterface(unittest.TestCase):
amdsmi.AmdSmiVramType.MAX: "MAX"
}
vram_vendors = {
amdsmi.AmdSmiVramVendor.SAMSUNG: "SAMSUNG",
amdsmi.AmdSmiVramVendor.INFINEON: "INFINEON",
amdsmi.AmdSmiVramVendor.ELPIDA: "ELPIDA",
amdsmi.AmdSmiVramVendor.ETRON: "ETRON",
amdsmi.AmdSmiVramVendor.NANYA: "NANYA",
amdsmi.AmdSmiVramVendor.HYNIX: "HYNIX",
amdsmi.AmdSmiVramVendor.MOSEL: "MOSEL",
amdsmi.AmdSmiVramVendor.WINBOND: "WINBOND",
amdsmi.AmdSmiVramVendor.ESMT: "ESMT",
amdsmi.AmdSmiVramVendor.MICRON: "MICRON",
amdsmi.AmdSmiVramVendor.UNKNOWN: "UNKNOWN"
}
vram_info = amdsmi.amdsmi_get_gpu_vram_info(processors[i])
print(" vram_info['vram_type'] is: {}".format(
vram_types[vram_info['vram_type']]))
print(" vram_info['vram_vendor'] is: {}".format(
vram_vendors[vram_info['vram_vendor']]))
vram_info['vram_vendor']))
print(" vram_info['vram_size'] is: {} MB".format(
vram_info['vram_size']))
print(" vram_info['vram_bit_width'] is: {}".format(