Merge amd-dev into amd-master 20240223
Signed-off-by: Maisam Arif <maisarif@amd.com>
Change-Id: I4179c02515fc8daad18ea3696eab2c4b17c8aebd
[ROCm/amdsmi commit: bfe14dde25]
Этот коммит содержится в:
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -69,7 +69,8 @@ if __name__ == "__main__":
|
||||
amd_smi_commands.set_value,
|
||||
amd_smi_commands.reset,
|
||||
amd_smi_commands.monitor,
|
||||
amd_smi_commands.rocm_smi)
|
||||
amd_smi_commands.rocm_smi,
|
||||
amd_smi_commands.xgmi)
|
||||
try:
|
||||
try:
|
||||
argcomplete.autocomplete(amd_smi_parser)
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -116,6 +116,18 @@ class AMDSMIHelpers():
|
||||
return self._is_windows
|
||||
|
||||
|
||||
def get_amdsmi_init_flag(self):
|
||||
return AMDSMI_INIT_FLAG
|
||||
|
||||
|
||||
def is_amdgpu_initialized(self):
|
||||
return AMDSMI_INIT_FLAG & amdsmi_interface.amdsmi_wrapper.AMDSMI_INIT_AMD_GPUS
|
||||
|
||||
|
||||
def is_amd_hsmp_initialized(self):
|
||||
return AMDSMI_INIT_FLAG & amdsmi_interface.amdsmi_wrapper.AMDSMI_INIT_AMD_CPUS
|
||||
|
||||
|
||||
def get_cpu_choices(self):
|
||||
"""Return dictionary of possible CPU choices and string of the output:
|
||||
Dictionary will be in format: cpus[ID]: Device Handle)
|
||||
@@ -136,11 +148,11 @@ class AMDSMIHelpers():
|
||||
except amdsmi_interface.AmdSmiLibraryException as e:
|
||||
if e.err_code in (amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NOT_INIT,
|
||||
amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_DRIVER_NOT_LOADED):
|
||||
logging.info('Unable to get device choices, driver not initialized (amdhsmp not found in modules)')
|
||||
logging.info('Unable to get device choices, driver not initialized (amd_hsmp not found in modules)')
|
||||
else:
|
||||
raise e
|
||||
if len(cpu_handles) == 0:
|
||||
logging.info('Unable to find any devices, check if driver is initialized (amdhsmp not found in modules)')
|
||||
logging.info('Unable to find any devices, check if driver is initialized (amd_hsmp not found in modules)')
|
||||
else:
|
||||
# Handle spacing for the gpu_choices_str
|
||||
max_padding = int(math.log10(len(cpu_handles))) + 1
|
||||
@@ -181,11 +193,11 @@ class AMDSMIHelpers():
|
||||
except amdsmi_interface.AmdSmiLibraryException as e:
|
||||
if e.err_code in (amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NOT_INIT,
|
||||
amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_DRIVER_NOT_LOADED):
|
||||
logging.info('Unable to get device choices, driver not initialized (amdhsmp not found in modules)')
|
||||
logging.info('Unable to get device choices, driver not initialized (amd_hsmp not found in modules)')
|
||||
else:
|
||||
raise e
|
||||
if len(core_handles) == 0:
|
||||
logging.info('Unable to find any devices, check if driver is initialized (amdhsmp not found in modules)')
|
||||
logging.info('Unable to find any devices, check if driver is initialized (amd_hsmp not found in modules)')
|
||||
else:
|
||||
# Handle spacing for the gpu_choices_str
|
||||
max_padding = int(math.log10(len(core_handles))) + 1
|
||||
@@ -463,6 +475,7 @@ class AMDSMIHelpers():
|
||||
else:
|
||||
return False, args.cpu
|
||||
|
||||
|
||||
def handle_cores(self, args, logger, subcommand):
|
||||
"""This function will run execute the subcommands based on the number
|
||||
of cores passed in via args.
|
||||
@@ -567,6 +580,7 @@ class AMDSMIHelpers():
|
||||
amdsmi_interface.amdsmi_wrapper.amdsmi_processor_handle,
|
||||
"Unable to find cpu ID from device_handle")
|
||||
|
||||
|
||||
def get_core_id_from_device_handle(self, input_device_handle):
|
||||
"""Get the core index from the device_handle.
|
||||
amdsmi_interface.amdsmi_get_cpusocket_handles() returns the list of device_handles in order of cpu_index
|
||||
|
||||
@@ -42,6 +42,7 @@ sys.tracebacklimit = -1 # Disable traceback when raising errors
|
||||
|
||||
# On initial import set initialized variable
|
||||
AMDSMI_INITIALIZED = False
|
||||
AMDSMI_INIT_FLAG = amdsmi_interface.AmdSmiInitFlags.INIT_ALL_PROCESSORS
|
||||
AMD_VENDOR_ID = 4098
|
||||
|
||||
def check_amdgpu_driver():
|
||||
@@ -53,8 +54,8 @@ def check_amdgpu_driver():
|
||||
return False
|
||||
|
||||
|
||||
def check_amdhsmp_driver():
|
||||
""" Returns true if amd hsmp is found in the list of initialized modules """
|
||||
def check_amd_hsmp_driver():
|
||||
""" Returns true if amd_hsmp is found in the list of initialized modules """
|
||||
amd_cpu_status_file = Path("/sys/module/amd_hsmp/initstate")
|
||||
if amd_cpu_status_file.exists():
|
||||
if amd_cpu_status_file.read_text(encoding="ascii").strip() == "live":
|
||||
@@ -62,32 +63,36 @@ def check_amdhsmp_driver():
|
||||
return False
|
||||
|
||||
|
||||
def init_amdsmi(flag=amdsmi_interface.AmdSmiInitFlags.INIT_AMD_GPUS):
|
||||
def init_amdsmi():
|
||||
""" Initializes AMDSMI
|
||||
|
||||
Raises:
|
||||
err: AmdSmiLibraryException if not successful
|
||||
"""
|
||||
gpu_flag = False;
|
||||
cpu_flag = False;
|
||||
Checks for the presence of the amdgpu and amd_hsmp drivers and initializes the
|
||||
AMD SMI library based on the live drivers found.
|
||||
|
||||
# Check if both the amdgpu and amdhsmp driver is up and handle error gracefully
|
||||
if check_amdgpu_driver() and check_amdhsmp_driver():
|
||||
# init AMD APUS
|
||||
Return:
|
||||
init_flag: the flag used to initialize the AMD SMI library without error
|
||||
|
||||
Raises:
|
||||
err: AmdSmiLibraryException if not successful in initializing any drivers
|
||||
"""
|
||||
init_flag = amdsmi_interface.AmdSmiInitFlags.INIT_ALL_PROCESSORS
|
||||
if check_amdgpu_driver() and check_amd_hsmp_driver():
|
||||
init_flag = amdsmi_interface.AmdSmiInitFlags.INIT_AMD_APUS
|
||||
logging.debug("Both amdgpu and amd_hsmp driver's initstate is live")
|
||||
try:
|
||||
amdsmi_interface.amdsmi_init(amdsmi_interface.AmdSmiInitFlags.INIT_AMD_APUS)
|
||||
amdsmi_interface.amdsmi_init(init_flag)
|
||||
except (amdsmi_interface.AmdSmiLibraryException, amdsmi_interface.AmdSmiParameterException) as e:
|
||||
if e.err_code in (amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NOT_INIT,
|
||||
amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_DRIVER_NOT_LOADED):
|
||||
logging.error("Drivers not loaded (amdgpu and hsmp drivers not found in modules)")
|
||||
logging.error("Drivers not loaded (amdgpu and amd_hsmp drivers not found in modules)")
|
||||
sys.exit(-1)
|
||||
else:
|
||||
raise e
|
||||
# # Check if amdgpu driver is up & Handle error gracefully
|
||||
elif check_amdgpu_driver():
|
||||
# Only init AMD GPUs for now, waiting for future support for AMD CPUs
|
||||
init_flag = amdsmi_interface.AmdSmiInitFlags.INIT_AMD_GPUS
|
||||
logging.debug("amdgpu driver initstate is live")
|
||||
try:
|
||||
amdsmi_interface.amdsmi_init(amdsmi_interface.AmdSmiInitFlags.INIT_AMD_GPUS)
|
||||
amdsmi_interface.amdsmi_init(init_flag)
|
||||
except (amdsmi_interface.AmdSmiLibraryException, amdsmi_interface.AmdSmiParameterException) as e:
|
||||
if e.err_code in (amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NOT_INIT,
|
||||
amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_DRIVER_NOT_LOADED):
|
||||
@@ -95,25 +100,24 @@ def init_amdsmi(flag=amdsmi_interface.AmdSmiInitFlags.INIT_AMD_GPUS):
|
||||
sys.exit(-1)
|
||||
else:
|
||||
raise e
|
||||
logging.debug("AMDSMI initialized successfully, but initstate was not live")
|
||||
|
||||
elif check_amdhsmp_driver():
|
||||
# Only init AMD CPUs
|
||||
logging.debug("amdgpu driver initialized successfully, but amd_hsmp initstate was not live")
|
||||
elif check_amd_hsmp_driver():
|
||||
init_flag = amdsmi_interface.AmdSmiInitFlags.INIT_AMD_CPUS
|
||||
logging.debug("amd_hsmp driver initstate is live")
|
||||
try:
|
||||
amdsmi_interface.amdsmi_init(amdsmi_interface.AmdSmiInitFlags.INIT_AMD_CPUS)
|
||||
cpu_flag = True
|
||||
amdsmi_interface.amdsmi_init(init_flag)
|
||||
except (amdsmi_interface.AmdSmiLibraryException, amdsmi_interface.AmdSmiParameterException) as e:
|
||||
if e.err_code in (amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NOT_INIT,
|
||||
amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_DRIVER_NOT_LOADED):
|
||||
logging.error("Driver not loaded (hsmp not found in modules)")
|
||||
logging.error("Driver not loaded (amd_hsmp not found in modules)")
|
||||
sys.exit(-1)
|
||||
else:
|
||||
raise e
|
||||
else:
|
||||
pass
|
||||
logging.debug("amd_hsmp driver initialized successfully, but amdgpu initstate was not live")
|
||||
|
||||
logging.debug("AMDSMI initialized successfully")
|
||||
logging.debug(f"AMDSMI initialized with atleast one driver successfully | init flag: {init_flag}")
|
||||
|
||||
return init_flag
|
||||
|
||||
def shut_down_amdsmi():
|
||||
"""Shutdown AMDSMI instance
|
||||
@@ -134,7 +138,7 @@ def signal_handler(sig, frame):
|
||||
|
||||
|
||||
if not AMDSMI_INITIALIZED:
|
||||
init_amdsmi()
|
||||
AMDSMI_INIT_FLAG = init_amdsmi()
|
||||
AMDSMI_INITIALIZED = True
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
@@ -25,8 +25,8 @@ import json
|
||||
import re
|
||||
import time
|
||||
from typing import Dict
|
||||
import yaml
|
||||
from enum import Enum
|
||||
import yaml
|
||||
|
||||
from amdsmi_helpers import AMDSMIHelpers
|
||||
import amdsmi_cli_exceptions
|
||||
@@ -118,14 +118,43 @@ class AMDSMILogger():
|
||||
table_values += value.rjust(12)
|
||||
elif key in ('throttle_status', 'pcie_replay'):
|
||||
table_values += value.rjust(13)
|
||||
elif 'gpu_' in key: # handle topology tables
|
||||
table_values += value.rjust(13)
|
||||
# Only for handling topology tables
|
||||
elif 'gpu_' in key:
|
||||
table_values += value.ljust(13)
|
||||
# Only for handling xgmi tables
|
||||
elif key == "gpu#":
|
||||
table_values += value.ljust(7)
|
||||
elif key == "bdf":
|
||||
table_values += value.ljust(13)
|
||||
elif "bdf_" in key:
|
||||
table_values += value.ljust(13)
|
||||
elif key == "bit_rate":
|
||||
table_values += value.ljust(9)
|
||||
elif key == "max_bandwidth":
|
||||
table_values += value.ljust(14)
|
||||
elif key == "link_type":
|
||||
table_values += value.ljust(10)
|
||||
elif key == "RW":
|
||||
table_values += " " + value.ljust(52)
|
||||
# Default spacing
|
||||
else:
|
||||
table_values += value.rjust(10)
|
||||
return table_values.rstrip()
|
||||
|
||||
# First Capitalize all keys in the json object
|
||||
capitalized_json = self._capitalize_keys(json_object)
|
||||
|
||||
# Increase tabbing for device arguments by pulling them out of the main dictionary and assiging them to an empty string
|
||||
tabbed_dictionary = {}
|
||||
for key, value in capitalized_json.items():
|
||||
if key not in ["GPU", "CPU", "CORE"]:
|
||||
tabbed_dictionary[key] = value
|
||||
|
||||
for key, value in tabbed_dictionary.items():
|
||||
del capitalized_json[key]
|
||||
|
||||
capitalized_json["AMDSMI_SPACING_REMOVAL"] = tabbed_dictionary
|
||||
|
||||
json_string = json.dumps(capitalized_json, indent=4)
|
||||
yaml_data = yaml.safe_load(json_string)
|
||||
yaml_output = yaml.dump(yaml_data, sort_keys=False, allow_unicode=True)
|
||||
@@ -243,6 +272,7 @@ class AMDSMILogger():
|
||||
core_id = self.helpers.get_core_id_from_device_handle(device_handle)
|
||||
self._store_core_output_amdsmi(core_id=core_id, argument=argument, data=data)
|
||||
|
||||
|
||||
def _store_core_output_amdsmi(self, core_id, argument, data):
|
||||
if argument == 'timestamp': # Make sure timestamp is the first element in the output
|
||||
self.output['timestamp'] = int(time.time())
|
||||
@@ -388,7 +418,7 @@ class AMDSMILogger():
|
||||
if multiple_device_enabled:
|
||||
json_output = self.multiple_device_output
|
||||
else:
|
||||
json_output = self.output
|
||||
json_output = [self.output]
|
||||
|
||||
if self.destination == 'stdout':
|
||||
if json_output:
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -403,12 +403,12 @@ int main() {
|
||||
ret = amdsmi_get_pcie_info(processor_handles[j], &pcie_info);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_pcie_info:\n");
|
||||
printf("\tCurrent PCIe lanes: %d\n", pcie_info.pcie_metric.pcie_lanes);
|
||||
printf("\tCurrent PCIe lanes: %d\n", pcie_info.pcie_metric.pcie_width);
|
||||
printf("\tCurrent PCIe speed: %d\n", pcie_info.pcie_metric.pcie_speed);
|
||||
printf("\tCurrent PCIe Interface Version: %d\n",
|
||||
pcie_info.pcie_static.pcie_interface_version);
|
||||
printf("\tPCIe slot type: %d\n", pcie_info.pcie_static.slot_type);
|
||||
printf("\tPCIe max lanes: %d\n", pcie_info.pcie_static.max_pcie_lanes);
|
||||
printf("\tPCIe max lanes: %d\n", pcie_info.pcie_static.max_pcie_width);
|
||||
printf("\tPCIe max speed: %d\n", pcie_info.pcie_static.max_pcie_speed);
|
||||
|
||||
// Get VRAM temperature limit
|
||||
|
||||
@@ -67,12 +67,12 @@ extern "C" {
|
||||
* Initialization flags may be OR'd together and passed to ::amdsmi_init().
|
||||
*/
|
||||
typedef enum {
|
||||
AMDSMI_INIT_ALL_PROCESSORS = 0x0, // Default option
|
||||
AMDSMI_INIT_ALL_PROCESSORS = 0xFFFFFFFF, //!< Initialize all processors
|
||||
AMDSMI_INIT_AMD_CPUS = (1 << 0),
|
||||
AMDSMI_INIT_AMD_GPUS = (1 << 1),
|
||||
AMDSMI_INIT_NON_AMD_CPUS = (1 << 2),
|
||||
AMDSMI_INIT_NON_AMD_GPUS = (1 << 3),
|
||||
AMDSMI_INIT_AMD_APUS = (AMDSMI_INIT_AMD_CPUS | AMDSMI_INIT_AMD_GPUS)
|
||||
AMDSMI_INIT_AMD_APUS = (AMDSMI_INIT_AMD_CPUS | AMDSMI_INIT_AMD_GPUS) // Default option
|
||||
} amdsmi_init_flags_t;
|
||||
|
||||
/* Maximum size definitions AMDSMI */
|
||||
@@ -500,15 +500,15 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
struct pcie_static_ {
|
||||
uint16_t max_pcie_lanes; //!< maximum number of PCIe lanes
|
||||
uint16_t max_pcie_width; //!< maximum number of PCIe lanes
|
||||
uint32_t max_pcie_speed; //!< maximum PCIe speed
|
||||
uint32_t pcie_interface_version; //!< PCIe interface version
|
||||
amdsmi_card_form_factor_t slot_type; //!< card form factor
|
||||
uint64_t reserved[10];
|
||||
} pcie_static;
|
||||
struct pcie_metric_ {
|
||||
uint16_t pcie_width; //!< current PCIe width
|
||||
uint32_t pcie_speed; //!< current PCIe speed in MT/s
|
||||
uint16_t pcie_lanes; //!< current PCIe width
|
||||
uint32_t pcie_bandwidth; //!< current PCIe bandwidth Mb/s
|
||||
uint64_t pcie_replay_count; //!< total number of the replays issued on the PCIe link
|
||||
uint64_t pcie_l0_to_recovery_count; //!< total number of times the PCIe link transitioned from L0 to the recovery state
|
||||
@@ -541,17 +541,17 @@ typedef struct {
|
||||
* @brief cache properties
|
||||
*/
|
||||
typedef enum {
|
||||
AMDSMI_CACHE_PROPERTIES_ENABLED = 0x00000001,
|
||||
AMDSMI_CACHE_PROPERTIES_DATA_CACHE = 0x00000002,
|
||||
AMDSMI_CACHE_PROPERTIES_INST_CACHE = 0x00000004,
|
||||
AMDSMI_CACHE_PROPERTIES_CPU_CACHE = 0x00000008,
|
||||
AMDSMI_CACHE_PROPERTIES_SIMD_CACHE = 0x00000010,
|
||||
} amdsmi_cache_properties_type_t;
|
||||
AMDSMI_CACHE_PROPERTY_ENABLED = 0x00000001,
|
||||
AMDSMI_CACHE_PROPERTY_DATA_CACHE = 0x00000002,
|
||||
AMDSMI_CACHE_PROPERTY_INST_CACHE = 0x00000004,
|
||||
AMDSMI_CACHE_PROPERTY_CPU_CACHE = 0x00000008,
|
||||
AMDSMI_CACHE_PROPERTY_SIMD_CACHE = 0x00000010,
|
||||
} amdsmi_cache_property_type_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t num_cache_types;
|
||||
struct cache_ {
|
||||
uint32_t cache_properties; // amdsmi_cache_properties_type_t which is a bitmask
|
||||
uint32_t cache_properties; // amdsmi_cache_property_type_t which is a bitmask
|
||||
uint32_t cache_size; /* In KB */
|
||||
uint32_t cache_level;
|
||||
uint32_t max_num_cu_shared; /* Indicates how many Compute Units share this cache instance */
|
||||
@@ -1608,6 +1608,19 @@ typedef struct __attribute__((__packed__)){
|
||||
uint32_t gfxclk_frequency[8];
|
||||
} amdsmi_hsmp_metrics_table_t;
|
||||
|
||||
/**
|
||||
* @brief hsmp frequency limit source names
|
||||
*/
|
||||
static char* const amdsmi_hsmp_freqlimit_src_names[] = {
|
||||
"cHTC-Active",
|
||||
"PROCHOT",
|
||||
"TDC limit",
|
||||
"PPT Limit",
|
||||
"OPN Max",
|
||||
"Reliability Limit",
|
||||
"APML Agent",
|
||||
"HSMP Agent"
|
||||
};
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -73,7 +73,7 @@ except AmdSmiException as e:
|
||||
|
||||
### amdsmi_init
|
||||
|
||||
Description: Initialize amdsmi lib and connect to driver
|
||||
Description: Dynamically initialize amdsmi with amd_hsmp and amdgpu drivers
|
||||
|
||||
Input parameters: `None`
|
||||
|
||||
@@ -87,7 +87,12 @@ Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
amdsmi_init()
|
||||
init_flag = amdsmi_init()
|
||||
# Print out integer bitmask of initialized drivers
|
||||
# 1 is for amd_hsmp
|
||||
# 2 is for amdgpu
|
||||
# 3 is for amd_hsmp and amdgpu
|
||||
print(init_flag)
|
||||
# continue with amdsmi
|
||||
except AmdSmiException as e:
|
||||
print("Init failed")
|
||||
@@ -476,8 +481,7 @@ Schema:
|
||||
|
||||
```JSON
|
||||
{
|
||||
cache: {"type" : "number"},
|
||||
cache_properties:
|
||||
cache_properties:
|
||||
{
|
||||
"type" : "array",
|
||||
"items" : {"type" : "string"}
|
||||
@@ -491,7 +495,6 @@ Schema:
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`cache` | cache index from 0-9
|
||||
`cache_properties` | list of up to 4 cache property type strings. Ex. data ("DATA_CACHE"), instruction ("INST_CACHE"), CPU ("CPU_CACHE"), or SIMD ("SIMD_CACHE").
|
||||
`cache_size` | size of cache in KB
|
||||
`cache_level` | level of cache
|
||||
@@ -515,13 +518,11 @@ try:
|
||||
for device in devices:
|
||||
cache_info = amdsmi_get_gpu_cache_info(device)
|
||||
for cache_index, cache_values in cache_info.items():
|
||||
print(cache_index)
|
||||
print(cache_values['cache_properties'])
|
||||
print(cache_values['cache_size'])
|
||||
print(cache_values['cache_level'])
|
||||
print(cache_values['data_cache'])
|
||||
print(cache_values['instruction_cache'])
|
||||
print(cache_values['cpu_cache'])
|
||||
print(cache_values['simd_cache'])
|
||||
print(cache_values['max_num_cu_shared'])
|
||||
print(cache_values['num_cache_instance'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
@@ -790,7 +791,7 @@ Output: Dictionary with fields
|
||||
|
||||
Field | Description
|
||||
---|---
|
||||
`pcie_lanes`| pcie lanes in use
|
||||
`pcie_width`| pcie lanes in use
|
||||
`pcie_speed`| current pcie speed
|
||||
`pcie_interface_version`| current pcie generation
|
||||
|
||||
@@ -810,7 +811,7 @@ try:
|
||||
else:
|
||||
for device in devices:
|
||||
pcie_link_status = amdsmi_get_pcie_info(device)
|
||||
print(pcie_link_status["pcie_lanes"])
|
||||
print(pcie_link_status["pcie_width"])
|
||||
print(pcie_link_status["pcie_speed"])
|
||||
print(pcie_link_status["pcie_interface_version"])
|
||||
except AmdSmiException as e:
|
||||
@@ -988,8 +989,8 @@ Field | Description
|
||||
`model_number` | Board serial number
|
||||
`product_serial` | Product serial
|
||||
`fru_id` | FRU ID
|
||||
`manufacturer_name` | Manufacturer name
|
||||
`product_name` | Product name
|
||||
`manufacturer_name` | Manufacturer name
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_gpu_board_info` function:
|
||||
|
||||
@@ -1006,8 +1007,8 @@ try:
|
||||
print(board_info["model_number"])
|
||||
print(board_info["product_serial"])
|
||||
print(board_info["fru_id"])
|
||||
print(board_info["manufacturer_name"])
|
||||
print(board_info["product_name"])
|
||||
print(board_info["manufacturer_name"])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
@@ -828,8 +828,9 @@ def amdsmi_get_cpu_socket_current_active_freq_limit(
|
||||
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
||||
)
|
||||
|
||||
amdsmi_wrapper.amdsmi_get_cpu_socket_current_active_freq_limit.argtypes = [amdsmi_wrapper.amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint16), ctypes.POINTER(ctypes.c_char_p * len(amdsmi_wrapper.amdsmi_hsmp_freqlimit_src_names))]
|
||||
freq = ctypes.c_uint16()
|
||||
src_type = ctypes.pointer(ctypes.pointer(ctypes.c_char()))
|
||||
src_type = (ctypes.c_char_p * len(amdsmi_wrapper.amdsmi_hsmp_freqlimit_src_names))()
|
||||
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_cpu_socket_current_active_freq_limit(
|
||||
@@ -837,9 +838,14 @@ def amdsmi_get_cpu_socket_current_active_freq_limit(
|
||||
)
|
||||
)
|
||||
|
||||
freq_src = []
|
||||
for names in src_type:
|
||||
if names is not None:
|
||||
freq_src.append(names.decode('utf-8'))
|
||||
|
||||
return {
|
||||
"freq": f"{freq.value} MHz",
|
||||
"freq_src": f"{amdsmi_wrapper.string_cast(src_type.contents)}"
|
||||
"freq_src": f"{freq_src}"
|
||||
}
|
||||
|
||||
def amdsmi_get_cpu_socket_freq_range(
|
||||
@@ -1285,6 +1291,8 @@ def amdsmi_set_cpu_pcie_link_rate(
|
||||
processor_handle, rate_ctrl, ctypes.byref(prev_mode))
|
||||
)
|
||||
|
||||
return f"{prev_mode.value}"
|
||||
|
||||
def amdsmi_set_cpu_df_pstate_range(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
|
||||
max_pstate: int, min_pstate: int
|
||||
@@ -1574,7 +1582,7 @@ def amdsmi_get_gpu_asic_info(
|
||||
"vendor_name": asic_info_struct.vendor_name.decode("utf-8"),
|
||||
"subvendor_id": asic_info_struct.subvendor_id,
|
||||
"device_id": asic_info_struct.device_id,
|
||||
"rev_id": asic_info_struct.rev_id,
|
||||
"rev_id": hex(asic_info_struct.rev_id),
|
||||
"asic_serial": asic_info_struct.asic_serial.decode("utf-8"),
|
||||
"oam_id": asic_info_struct.oam_id
|
||||
}
|
||||
@@ -1584,16 +1592,18 @@ def amdsmi_get_gpu_asic_info(
|
||||
if not asic_info[value]:
|
||||
asic_info[value] = "N/A"
|
||||
|
||||
hex_values = ["vendor_id", "subvendor_id", "device_id", "rev_id"]
|
||||
hex_values = ["vendor_id", "subvendor_id", "device_id"]
|
||||
for value in hex_values:
|
||||
if asic_info[value]:
|
||||
asic_info[value] = hex(asic_info[value])
|
||||
else:
|
||||
asic_info[value] = "N/A"
|
||||
|
||||
# Ensure hex output for asic_serial
|
||||
# Convert asic serial (hex string) to hex output format
|
||||
if asic_info["asic_serial"]:
|
||||
asic_info["asic_serial"] = str.format("0x{:016X}", int(asic_info["asic_serial"], base=16))
|
||||
asic_serial_string = asic_info["asic_serial"]
|
||||
asic_serial_hex = int(asic_serial_string, base=16)
|
||||
asic_info["asic_serial"] = str.format("0x{:016X}", asic_serial_hex)
|
||||
else:
|
||||
asic_info["asic_serial"] = "N/A"
|
||||
|
||||
@@ -1668,7 +1678,6 @@ def amdsmi_get_gpu_cache_info(
|
||||
for cache_index in range(cache_info_struct.num_cache_types):
|
||||
# Put cache_properties at the start of the dictionary for readability
|
||||
cache_dict = {
|
||||
"cache": cache_index,
|
||||
"cache_properties": [], # This will be a list of strings
|
||||
"cache_size": cache_info_struct.cache[cache_index].cache_size,
|
||||
"cache_level": cache_info_struct.cache[cache_index].cache_level,
|
||||
@@ -1678,17 +1687,17 @@ def amdsmi_get_gpu_cache_info(
|
||||
|
||||
# Check against cache properties bitmask
|
||||
cache_properties = cache_info_struct.cache[cache_index].cache_properties
|
||||
data_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_DATA_CACHE
|
||||
inst_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_INST_CACHE
|
||||
cpu_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_CPU_CACHE
|
||||
simd_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_SIMD_CACHE
|
||||
data_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_DATA_CACHE
|
||||
inst_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_INST_CACHE
|
||||
cpu_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_CPU_CACHE
|
||||
simd_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTY_SIMD_CACHE
|
||||
|
||||
cache_properties_status = [data_cache, inst_cache, cpu_cache, simd_cache]
|
||||
cache_property_list = []
|
||||
for cache_property in cache_properties_status:
|
||||
if cache_property:
|
||||
property_name = amdsmi_wrapper.amdsmi_cache_properties_type_t__enumvalues[cache_property]
|
||||
property_name = property_name.replace("AMDSMI_CACHE_PROPERTIES_", "")
|
||||
property_name = amdsmi_wrapper.amdsmi_cache_property_type_t__enumvalues[cache_property]
|
||||
property_name = property_name.replace("AMDSMI_CACHE_PROPERTY_", "")
|
||||
cache_property_list.append(property_name)
|
||||
|
||||
cache_dict["cache_properties"] = cache_property_list
|
||||
@@ -1697,7 +1706,9 @@ def amdsmi_get_gpu_cache_info(
|
||||
if not cache_info_list:
|
||||
raise AmdSmiLibraryException(amdsmi_wrapper.AMDSMI_STATUS_NO_DATA)
|
||||
|
||||
return cache_info_list
|
||||
return {
|
||||
"cache": cache_info_list
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_get_gpu_vbios_info(
|
||||
@@ -1842,8 +1853,8 @@ def amdsmi_get_gpu_board_info(
|
||||
"model_number": board_info.model_number.decode("utf-8").strip(),
|
||||
"product_serial": board_info.product_serial.decode("utf-8").strip(),
|
||||
"fru_id": board_info.fru_id.decode("utf-8").strip(),
|
||||
"manufacturer_name" : board_info.manufacturer_name.decode("utf-8").strip(),
|
||||
"product_name": board_info.product_name.decode("utf-8").strip()
|
||||
"product_name": board_info.product_name.decode("utf-8").strip(),
|
||||
"manufacturer_name": board_info.manufacturer_name.decode("utf-8").strip()
|
||||
}
|
||||
|
||||
|
||||
@@ -1993,8 +2004,6 @@ def amdsmi_get_gpu_driver_info(
|
||||
length = ctypes.c_int()
|
||||
length.value = _AMDSMI_MAX_DRIVER_VERSION_LENGTH
|
||||
|
||||
version = ctypes.create_string_buffer(_AMDSMI_MAX_DRIVER_VERSION_LENGTH)
|
||||
|
||||
info = amdsmi_wrapper.amdsmi_driver_info_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_gpu_driver_info(
|
||||
@@ -2004,7 +2013,8 @@ def amdsmi_get_gpu_driver_info(
|
||||
|
||||
return {
|
||||
"driver_name": info.driver_name.decode("utf-8"),
|
||||
"driver_version": info.driver_version.decode("utf-8")
|
||||
"driver_version": info.driver_version.decode("utf-8"),
|
||||
"driver_date": info.driver_date.decode("utf-8")
|
||||
}
|
||||
|
||||
|
||||
@@ -2101,13 +2111,13 @@ def amdsmi_get_gpu_vram_usage(
|
||||
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
||||
)
|
||||
|
||||
vram_info = amdsmi_wrapper.amdsmi_vram_usage_t()
|
||||
vram_usage = amdsmi_wrapper.amdsmi_vram_usage_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_gpu_vram_usage(
|
||||
processor_handle, ctypes.byref(vram_info))
|
||||
processor_handle, ctypes.byref(vram_usage))
|
||||
)
|
||||
|
||||
return {"vram_total": vram_info.vram_total, "vram_used": vram_info.vram_used}
|
||||
return {"vram_total": vram_usage.vram_total, "vram_used": vram_usage.vram_used}
|
||||
|
||||
|
||||
def amdsmi_get_pcie_info(
|
||||
@@ -2125,13 +2135,24 @@ def amdsmi_get_pcie_info(
|
||||
)
|
||||
)
|
||||
|
||||
return {"pcie_speed": pcie_info.pcie_metric.pcie_speed,
|
||||
"pcie_lanes": pcie_info.pcie_metric.pcie_lanes,
|
||||
"pcie_interface_version": pcie_info.pcie_static.pcie_interface_version,
|
||||
return {
|
||||
"pcie_static": {
|
||||
"max_pcie_width": pcie_info.pcie_static.max_pcie_width,
|
||||
"max_pcie_speed": pcie_info.pcie_static.max_pcie_speed,
|
||||
"max_pcie_lanes": pcie_info.pcie_static.max_pcie_lanes,
|
||||
"pcie_interface_version": pcie_info.pcie_static.pcie_interface_version,
|
||||
"pcie_slot_type": pcie_info.pcie_static.slot_type}
|
||||
"slot_type": pcie_info.pcie_static.slot_type,
|
||||
},
|
||||
"pcie_metric": {
|
||||
"pcie_width": pcie_info.pcie_metric.pcie_width,
|
||||
"pcie_speed": pcie_info.pcie_metric.pcie_speed,
|
||||
"pcie_bandwidth": pcie_info.pcie_metric.pcie_bandwidth,
|
||||
"pcie_replay_count": pcie_info.pcie_metric.pcie_replay_count,
|
||||
"pcie_l0_to_recovery_count": pcie_info.pcie_metric.pcie_l0_to_recovery_count,
|
||||
"pcie_replay_roll_over_count": pcie_info.pcie_metric.pcie_replay_roll_over_count,
|
||||
"pcie_nak_sent_count": pcie_info.pcie_metric.pcie_nak_sent_count,
|
||||
"pcie_nak_received_count": pcie_info.pcie_metric.pcie_nak_received_count,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def amdsmi_get_processor_handle_from_bdf(bdf):
|
||||
|
||||
@@ -196,14 +196,14 @@ _libraries['FIXME_STUB'] = FunctionFactoryStub() # ctypes.CDLL('FIXME_STUB')
|
||||
|
||||
# values for enumeration 'amdsmi_init_flags_t'
|
||||
amdsmi_init_flags_t__enumvalues = {
|
||||
0: 'AMDSMI_INIT_ALL_PROCESSORS',
|
||||
4294967295: 'AMDSMI_INIT_ALL_PROCESSORS',
|
||||
1: 'AMDSMI_INIT_AMD_CPUS',
|
||||
2: 'AMDSMI_INIT_AMD_GPUS',
|
||||
4: 'AMDSMI_INIT_NON_AMD_CPUS',
|
||||
8: 'AMDSMI_INIT_NON_AMD_GPUS',
|
||||
3: 'AMDSMI_INIT_AMD_APUS',
|
||||
}
|
||||
AMDSMI_INIT_ALL_PROCESSORS = 0
|
||||
AMDSMI_INIT_ALL_PROCESSORS = 4294967295
|
||||
AMDSMI_INIT_AMD_CPUS = 1
|
||||
AMDSMI_INIT_AMD_GPUS = 2
|
||||
AMDSMI_INIT_NON_AMD_CPUS = 4
|
||||
@@ -751,9 +751,9 @@ class struct_pcie_metric_(Structure):
|
||||
|
||||
struct_pcie_metric_._pack_ = 1 # source:False
|
||||
struct_pcie_metric_._fields_ = [
|
||||
('pcie_speed', ctypes.c_uint32),
|
||||
('pcie_lanes', ctypes.c_uint16),
|
||||
('pcie_width', ctypes.c_uint16),
|
||||
('PADDING_0', ctypes.c_ubyte * 2),
|
||||
('pcie_speed', ctypes.c_uint32),
|
||||
('pcie_bandwidth', ctypes.c_uint32),
|
||||
('PADDING_1', ctypes.c_ubyte * 4),
|
||||
('pcie_replay_count', ctypes.c_uint64),
|
||||
@@ -769,7 +769,7 @@ class struct_pcie_static_(Structure):
|
||||
|
||||
struct_pcie_static_._pack_ = 1 # source:False
|
||||
struct_pcie_static_._fields_ = [
|
||||
('max_pcie_lanes', ctypes.c_uint16),
|
||||
('max_pcie_width', ctypes.c_uint16),
|
||||
('PADDING_0', ctypes.c_ubyte * 2),
|
||||
('max_pcie_speed', ctypes.c_uint32),
|
||||
('pcie_interface_version', ctypes.c_uint32),
|
||||
@@ -813,20 +813,20 @@ struct_amdsmi_vbios_info_t._fields_ = [
|
||||
|
||||
amdsmi_vbios_info_t = struct_amdsmi_vbios_info_t
|
||||
|
||||
# values for enumeration 'amdsmi_cache_properties_type_t'
|
||||
amdsmi_cache_properties_type_t__enumvalues = {
|
||||
1: 'AMDSMI_CACHE_PROPERTIES_ENABLED',
|
||||
2: 'AMDSMI_CACHE_PROPERTIES_DATA_CACHE',
|
||||
4: 'AMDSMI_CACHE_PROPERTIES_INST_CACHE',
|
||||
8: 'AMDSMI_CACHE_PROPERTIES_CPU_CACHE',
|
||||
16: 'AMDSMI_CACHE_PROPERTIES_SIMD_CACHE',
|
||||
# values for enumeration 'amdsmi_cache_property_type_t'
|
||||
amdsmi_cache_property_type_t__enumvalues = {
|
||||
1: 'AMDSMI_CACHE_PROPERTY_ENABLED',
|
||||
2: 'AMDSMI_CACHE_PROPERTY_DATA_CACHE',
|
||||
4: 'AMDSMI_CACHE_PROPERTY_INST_CACHE',
|
||||
8: 'AMDSMI_CACHE_PROPERTY_CPU_CACHE',
|
||||
16: 'AMDSMI_CACHE_PROPERTY_SIMD_CACHE',
|
||||
}
|
||||
AMDSMI_CACHE_PROPERTIES_ENABLED = 1
|
||||
AMDSMI_CACHE_PROPERTIES_DATA_CACHE = 2
|
||||
AMDSMI_CACHE_PROPERTIES_INST_CACHE = 4
|
||||
AMDSMI_CACHE_PROPERTIES_CPU_CACHE = 8
|
||||
AMDSMI_CACHE_PROPERTIES_SIMD_CACHE = 16
|
||||
amdsmi_cache_properties_type_t = ctypes.c_uint32 # enum
|
||||
AMDSMI_CACHE_PROPERTY_ENABLED = 1
|
||||
AMDSMI_CACHE_PROPERTY_DATA_CACHE = 2
|
||||
AMDSMI_CACHE_PROPERTY_INST_CACHE = 4
|
||||
AMDSMI_CACHE_PROPERTY_CPU_CACHE = 8
|
||||
AMDSMI_CACHE_PROPERTY_SIMD_CACHE = 16
|
||||
amdsmi_cache_property_type_t = ctypes.c_uint32 # enum
|
||||
class struct_amdsmi_gpu_cache_info_t(Structure):
|
||||
pass
|
||||
|
||||
@@ -1846,6 +1846,7 @@ struct_amdsmi_hsmp_metrics_table_t._fields_ = [
|
||||
]
|
||||
|
||||
amdsmi_hsmp_metrics_table_t = struct_amdsmi_hsmp_metrics_table_t
|
||||
amdsmi_hsmp_freqlimit_src_names = ['cHTC-Active', 'PROCHOT', 'TDC limit', 'PPT Limit', 'OPN Max', 'Reliability Limit', 'APML Agent', 'HSMP Agent'] # Variable ctypes.POINTER(ctypes.c_char) * 8
|
||||
uint64_t = ctypes.c_uint64
|
||||
amdsmi_init = _libraries['libamd_smi.so'].amdsmi_init
|
||||
amdsmi_init.restype = amdsmi_status_t
|
||||
@@ -2308,14 +2309,14 @@ amdsmi_get_esmi_err_msg.restype = amdsmi_status_t
|
||||
amdsmi_get_esmi_err_msg.argtypes = [amdsmi_status_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))]
|
||||
__all__ = \
|
||||
['AGG_BW0', 'AMDSMI_ARG_PTR_NULL', 'AMDSMI_AVERAGE_POWER',
|
||||
'AMDSMI_CACHE_PROPERTIES_CPU_CACHE',
|
||||
'AMDSMI_CACHE_PROPERTIES_DATA_CACHE',
|
||||
'AMDSMI_CACHE_PROPERTIES_ENABLED',
|
||||
'AMDSMI_CACHE_PROPERTIES_INST_CACHE',
|
||||
'AMDSMI_CACHE_PROPERTIES_SIMD_CACHE',
|
||||
'AMDSMI_CARD_FORM_FACTOR_OAM', 'AMDSMI_CARD_FORM_FACTOR_PCIE',
|
||||
'AMDSMI_CARD_FORM_FACTOR_UNKNOWN', 'AMDSMI_CNTR_CMD_START',
|
||||
'AMDSMI_CNTR_CMD_STOP', 'AMDSMI_COARSE_GRAIN_GFX_ACTIVITY',
|
||||
'AMDSMI_CACHE_PROPERTY_CPU_CACHE',
|
||||
'AMDSMI_CACHE_PROPERTY_DATA_CACHE',
|
||||
'AMDSMI_CACHE_PROPERTY_ENABLED',
|
||||
'AMDSMI_CACHE_PROPERTY_INST_CACHE',
|
||||
'AMDSMI_CACHE_PROPERTY_SIMD_CACHE', 'AMDSMI_CARD_FORM_FACTOR_OAM',
|
||||
'AMDSMI_CARD_FORM_FACTOR_PCIE', 'AMDSMI_CARD_FORM_FACTOR_UNKNOWN',
|
||||
'AMDSMI_CNTR_CMD_START', 'AMDSMI_CNTR_CMD_STOP',
|
||||
'AMDSMI_COARSE_GRAIN_GFX_ACTIVITY',
|
||||
'AMDSMI_COARSE_GRAIN_MEM_ACTIVITY', 'AMDSMI_CURRENT_POWER',
|
||||
'AMDSMI_DEV_PERF_LEVEL_AUTO', 'AMDSMI_DEV_PERF_LEVEL_DETERMINISM',
|
||||
'AMDSMI_DEV_PERF_LEVEL_FIRST', 'AMDSMI_DEV_PERF_LEVEL_HIGH',
|
||||
@@ -2477,7 +2478,7 @@ __all__ = \
|
||||
'VRAM_TYPE_GDDR6', 'VRAM_TYPE_HBM', 'VRAM_TYPE_UNKNOWN',
|
||||
'VRAM_TYPE__MAX', 'WR_BW0', 'amd_metrics_table_header_t',
|
||||
'amdsmi_asic_info_t', 'amdsmi_bdf_t', 'amdsmi_bit_field_t',
|
||||
'amdsmi_board_info_t', 'amdsmi_cache_properties_type_t',
|
||||
'amdsmi_board_info_t', 'amdsmi_cache_property_type_t',
|
||||
'amdsmi_card_form_factor_t', 'amdsmi_clk_info_t',
|
||||
'amdsmi_clk_type_t', 'amdsmi_compute_partition_type_t',
|
||||
'amdsmi_container_types_t', 'amdsmi_counter_command_t',
|
||||
@@ -2569,10 +2570,10 @@ __all__ = \
|
||||
'amdsmi_gpu_counter_group_supported', 'amdsmi_gpu_create_counter',
|
||||
'amdsmi_gpu_destroy_counter', 'amdsmi_gpu_metrics_t',
|
||||
'amdsmi_gpu_read_counter', 'amdsmi_gpu_xgmi_error_status',
|
||||
'amdsmi_hsmp_metrics_table_t', 'amdsmi_init',
|
||||
'amdsmi_init_flags_t', 'amdsmi_init_gpu_event_notification',
|
||||
'amdsmi_io_bw_encoding_t', 'amdsmi_io_link_type_t',
|
||||
'amdsmi_is_P2P_accessible',
|
||||
'amdsmi_hsmp_freqlimit_src_names', 'amdsmi_hsmp_metrics_table_t',
|
||||
'amdsmi_init', 'amdsmi_init_flags_t',
|
||||
'amdsmi_init_gpu_event_notification', 'amdsmi_io_bw_encoding_t',
|
||||
'amdsmi_io_link_type_t', 'amdsmi_is_P2P_accessible',
|
||||
'amdsmi_is_gpu_power_management_enabled',
|
||||
'amdsmi_link_id_bw_type_t', 'amdsmi_link_metrics_t',
|
||||
'amdsmi_link_type_t', 'amdsmi_memory_page_status_t',
|
||||
|
||||
@@ -2642,7 +2642,10 @@ rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask) {
|
||||
|
||||
int32_t ret_i;
|
||||
ret_i = dev->writeDevInfo(amd::smi::kDevPCIEClk, freq_enable_str);
|
||||
|
||||
//
|
||||
// NOTE: kDevPCIEClk sysfs file maybe not exist for all cases.
|
||||
// If it doesn't exist (pp_dpm_pcie), it shouldn't be an error
|
||||
// and will get translated to RSMI_STATUS_NOT_SUPPORTED.
|
||||
return amd::smi::ErrnoToRsmiStatus(ret_i);
|
||||
|
||||
CATCH
|
||||
|
||||
@@ -448,13 +448,13 @@ amdsmi_status_t amdsmi_get_gpu_cache_info(
|
||||
// convert from sysfs type to CRAT type(HSA Cache Affinity type)
|
||||
info->cache[i].cache_properties = 0;
|
||||
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_DATA)
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_DATA_CACHE;
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_DATA_CACHE;
|
||||
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_INSTRUCTION)
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_INST_CACHE;
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_INST_CACHE;
|
||||
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_CPU)
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_CPU_CACHE;
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_CPU_CACHE;
|
||||
if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_HSACU)
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_SIMD_CACHE;
|
||||
info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTY_SIMD_CACHE;
|
||||
|
||||
info->cache[i].cache_size = rsmi_info.cache[i].cache_size_kb;
|
||||
info->cache[i].cache_level = rsmi_info.cache[i].cache_level;
|
||||
@@ -1964,7 +1964,7 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a
|
||||
printf("Failed to open file: %s \n", path_max_link_width.c_str());
|
||||
return AMDSMI_STATUS_API_FAILED;
|
||||
}
|
||||
info->pcie_static.max_pcie_lanes = (uint16_t)pcie_width;
|
||||
info->pcie_static.max_pcie_width = (uint16_t)pcie_width;
|
||||
|
||||
std::string path_max_link_speed = "/sys/class/drm/" +
|
||||
gpu_device->get_gpu_path() + "/device/max_link_speed";
|
||||
@@ -2028,7 +2028,7 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
info->pcie_metric.pcie_lanes = metric_info.pcie_link_width;
|
||||
info->pcie_metric.pcie_width = metric_info.pcie_link_width;
|
||||
// gpu metrics is inconsistent with pcie_speed values, if 0-6 then it needs to be translated
|
||||
if (metric_info.pcie_link_speed <= 6) {
|
||||
status = smi_amdgpu_get_pcie_speed_from_pcie_type(metric_info.pcie_link_speed, &info->pcie_metric.pcie_speed); // mapping to MT/s
|
||||
@@ -2915,6 +2915,7 @@ amdsmi_status_t amdsmi_set_cpu_pcie_link_rate(amdsmi_processor_handle processor_
|
||||
{
|
||||
amdsmi_status_t status;
|
||||
uint8_t sock_ind;
|
||||
uint8_t p_mode;
|
||||
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
@@ -2928,10 +2929,12 @@ amdsmi_status_t amdsmi_set_cpu_pcie_link_rate(amdsmi_processor_handle processor_
|
||||
sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0);
|
||||
|
||||
status = static_cast<amdsmi_status_t>(esmi_pcie_link_rate_set(sock_ind,
|
||||
rate_ctrl, prev_mode));
|
||||
rate_ctrl, &p_mode));
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return amdsmi_errno_to_esmi_status(status);
|
||||
|
||||
*prev_mode = p_mode;
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ amdsmi_status_t AMDSmiSystem::cleanup() {
|
||||
processors_.clear();
|
||||
sockets_.clear();
|
||||
esmi_exit();
|
||||
init_flag_ = AMDSMI_INIT_ALL_PROCESSORS;
|
||||
init_flag_ &= ~AMDSMI_INIT_AMD_CPUS;
|
||||
}
|
||||
#endif
|
||||
if (init_flag_ & AMDSMI_INIT_AMD_GPUS) {
|
||||
@@ -270,7 +270,7 @@ amdsmi_status_t AMDSmiSystem::cleanup() {
|
||||
}
|
||||
processors_.clear();
|
||||
sockets_.clear();
|
||||
init_flag_ = AMDSMI_INIT_ALL_PROCESSORS;
|
||||
init_flag_ &= ~AMDSMI_INIT_AMD_GPUS;
|
||||
rsmi_status_t ret = rsmi_shut_down();
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return amd::smi::rsmi_to_amdsmi_status(ret);
|
||||
|
||||
@@ -181,8 +181,9 @@ void TestFrequenciesRead::Run(void) {
|
||||
std::cout << b.transfer_rate.num_supported << std::endl;
|
||||
print_frequencies(&b.transfer_rate, b.lanes);
|
||||
// Verify api support checking functionality is working
|
||||
// NOTE: We expect AMDSMI_STATUS_NOT_SUPPORTED, if rsmi_pcie_bandwidth_t* is NULL
|
||||
err = amdsmi_get_gpu_pci_bandwidth(processor_handles_[i], nullptr);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
|
||||
ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,8 +163,9 @@ void TestPciReadWrite::Run(void) {
|
||||
std::endl;
|
||||
}
|
||||
// Verify api support checking functionality is working
|
||||
// NOTE: We expect AMDSMI_STATUS_NOT_SUPPORTED, if rsmi_pcie_bandwidth_t* is NULL
|
||||
ret = amdsmi_get_gpu_pci_bandwidth(processor_handles_[dv_ind], nullptr);
|
||||
ASSERT_EQ(ret, AMDSMI_STATUS_INVAL);
|
||||
ASSERT_EQ(ret, AMDSMI_STATUS_NOT_SUPPORTED);
|
||||
|
||||
// First set the bitmask to all supported bandwidths
|
||||
freq_bitmask = ~(~0u << bw.transfer_rate.num_supported);
|
||||
@@ -183,7 +184,14 @@ void TestPciReadWrite::Run(void) {
|
||||
" ..." << std::endl;
|
||||
}
|
||||
ret = amdsmi_set_gpu_pci_bandwidth(processor_handles_[dv_ind], freq_bitmask);
|
||||
CHK_ERR_ASRT(ret)
|
||||
if (ret != amdsmi_status_t::AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
CHK_ERR_ASRT(ret)
|
||||
}
|
||||
else {
|
||||
auto status_string("");
|
||||
amdsmi_status_code_to_string(ret, &status_string);
|
||||
std::cout << "\t\t** amdsmi_set_gpu_pci_bandwidth(): " << status_string << "\n";
|
||||
}
|
||||
|
||||
ret = amdsmi_get_gpu_pci_bandwidth(processor_handles_[dv_ind], &bw);
|
||||
CHK_ERR_ASRT(ret)
|
||||
@@ -194,7 +202,14 @@ void TestPciReadWrite::Run(void) {
|
||||
std::cout << "\tResetting mask to all bandwidths." << std::endl;
|
||||
}
|
||||
ret = amdsmi_set_gpu_pci_bandwidth(processor_handles_[dv_ind], 0xFFFFFFFF);
|
||||
CHK_ERR_ASRT(ret)
|
||||
if (ret != amdsmi_status_t::AMDSMI_STATUS_NOT_SUPPORTED) {
|
||||
CHK_ERR_ASRT(ret)
|
||||
}
|
||||
else {
|
||||
auto status_string("");
|
||||
amdsmi_status_code_to_string(ret, &status_string);
|
||||
std::cout << "\t\t** amdsmi_set_gpu_pci_bandwidth(): " << status_string << "\n";
|
||||
}
|
||||
|
||||
ret = amdsmi_set_gpu_perf_level(processor_handles_[dv_ind], AMDSMI_DEV_PERF_LEVEL_AUTO);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
Ссылка в новой задаче
Block a user