Merge amd-dev into amd-master 20240327

Signed-off-by: Maisam Arif <maisarif@amd.com>
Change-Id: I69a4c59e900ba67e1f84934dc2cb967114c839cc


[ROCm/amdsmi commit: d3a33b3ec3]
This commit is contained in:
Maisam Arif
2024-03-27 01:11:22 -05:00
16 zmienionych plików z 922 dodań i 153 usunięć
+180 -12
Wyświetl plik
@@ -1,14 +1,172 @@
# Change Log for AMD SMI Library
Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/](https://rocm.docs.amd.com/projects/amdsmi/en/latest/).
Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/](https://rocm.docs.amd.com/projects/amdsmi/en/latest/).
***All information listed below is for reference and subject to change.***
## amd_smi_lib for ROCm 6.1.1
### Changed
- **Updated metrics --clocks**
Output for `amd-smi metric --clock` is updated to reflect each engine and bug fixes for the clock lock status and deep sleep status.
``` shell
$ amd-smi metric --clock
GPU: 0
CLOCK:
GFX_0:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_1:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_2:
CLK: 112 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_3:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_4:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_5:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_6:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
GFX_7:
CLK: 113 MHz
MIN_CLK: 500 MHz
MAX_CLK: 1800 MHz
CLK_LOCKED: DISABLED
DEEP_SLEEP: ENABLED
MEM_0:
CLK: 900 MHz
MIN_CLK: 900 MHz
MAX_CLK: 1200 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: DISABLED
VCLK_0:
CLK: 29 MHz
MIN_CLK: 914 MHz
MAX_CLK: 1480 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
VCLK_1:
CLK: 29 MHz
MIN_CLK: 914 MHz
MAX_CLK: 1480 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
VCLK_2:
CLK: 29 MHz
MIN_CLK: 914 MHz
MAX_CLK: 1480 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
VCLK_3:
CLK: 29 MHz
MIN_CLK: 914 MHz
MAX_CLK: 1480 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
DCLK_0:
CLK: 22 MHz
MIN_CLK: 711 MHz
MAX_CLK: 1233 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
DCLK_1:
CLK: 22 MHz
MIN_CLK: 711 MHz
MAX_CLK: 1233 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
DCLK_2:
CLK: 22 MHz
MIN_CLK: 711 MHz
MAX_CLK: 1233 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
DCLK_3:
CLK: 22 MHz
MIN_CLK: 711 MHz
MAX_CLK: 1233 MHz
CLK_LOCKED: N/A
DEEP_SLEEP: ENABLED
```
- **Added deferred ecc counts**
Added deferred error correctable counts to `amd-smi metric --ecc --ecc-blocks`
```shell
$ amd-smi metric --ecc --ecc-blocks
GPU: 0
ECC:
TOTAL_CORRECTABLE_COUNT: 0
TOTAL_UNCORRECTABLE_COUNT: 0
TOTAL_DEFERRED_COUNT: 0
CACHE_CORRECTABLE_COUNT: 0
CACHE_UNCORRECTABLE_COUNT: 0
ECC_BLOCKS:
UMC:
CORRECTABLE_COUNT: 0
UNCORRECTABLE_COUNT: 0
DEFERRED_COUNT: 0
SDMA:
CORRECTABLE_COUNT: 0
UNCORRECTABLE_COUNT: 0
DEFERRED_COUNT: 0
...
```
### Fixed
- **Fix for GPU reset error on non-amdgpu cards**
Previously our reset could attempting to reset non-amd GPUS- resuting in "Unable to reset non-amd GPU" error. Fix
updates CLI to target only AMD ASICs.
- **Fix for `amd-smi metric --pcie` and `amdsmi_get_pcie_info()`Navi32/31 cards**
Updated API to include `amdsmi_card_form_factor_t.AMDSMI_CARD_FORM_FACTOR_CEM`. Prevously, this would report "UNKNOWN". This fix
provides the correct board `SLOT_TYPE` associated with these ASICs (and other Navi cards).
- **Improved Error handling for `amd-smi process`**
Fixed Attribute Error when getting process in csv format
### Known issues
- `amd-smi bad-pages` can results with "ValueError: NULL pointer access" with certain PM FW versions
## amd_smi_lib for ROCm 6.1.0
### Added
- **Added Monitor Command**
Provides users the ability to customize GPU metrics to capture, collect, and observe. Output is provided in a table view. This aligns closer to ROCm SMI `rocm-smi` (no argument), additionally allows uers to customize what data is helpful for their use-case.
```shell
$ amd-smi monitor -h
usage: amd-smi monitor [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL]
@@ -52,6 +210,7 @@ Command Modifiers:
--loglevel LEVEL Set the logging level from the possible choices:
DEBUG, INFO, WARNING, ERROR, CRITICAL
```
```shell
$ amd-smi monitor -ptumv
GPU POWER GPU_TEMP MEM_TEMP GFX_UTIL GFX_CLOCK MEM_UTIL MEM_CLOCK VRAM_USED VRAM_TOTAL
@@ -66,9 +225,9 @@ GPU POWER GPU_TEMP MEM_TEMP GFX_UTIL GFX_CLOCK MEM_UTIL MEM_CLOCK VRAM_U
```
- **Integrated ESMI Tool**
Users can get CPU metrics and telemetry through our API and CLI tools. This information can be seen in `amd-smi static` and `amd-smi metric` commands. Only available for limited target processors. As of ROCm 6.0.2, this is listed as:
- AMD Zen3 based CPU Family 19h Models 0h-Fh and 30h-3Fh
- AMD Zen4 based CPU Family 19h Models 10h-1Fh and A0-AFh
Users can get CPU metrics and telemetry through our API and CLI tools. This information can be seen in `amd-smi static` and `amd-smi metric` commands. Only available for limited target processors. As of ROCm 6.0.2, this is listed as:
- AMD Zen3 based CPU Family 19h Models 0h-Fh and 30h-3Fh
- AMD Zen4 based CPU Family 19h Models 10h-1Fh and A0-AFh
See a few examples listed below.
@@ -80,6 +239,7 @@ CPU: 0
INTERFACE_VERSION:
PROTO VERSION: 6
```
```shell
$ amd-smi metric -O 0 1 2
CORE: 0
@@ -106,6 +266,7 @@ CORE: 2
CORE_ENERGY:
VALUE: N/A
```
```shell
$ amd-smi metric -U all
CPU: 0
@@ -212,6 +373,7 @@ CPU: 0
CPU_TEMP:
RESPONSE: N/A
```
- **Added support for new metrics: VCN, JPEG engines, and PCIe errors**
Using the AMD SMI tool, users can retreive VCN, JPEG engines, and PCIe errors by calling `amd-smi metric -P` or `amd-smi metric --usage`. Depending on device support, `VCN_ACTIVITY` will update for MI3x ASICs (with 4 separate VCN engine activities) for older asics `MM_ACTIVITY` with UVD/VCN engine activity (average of all engines). `JPEG_ACTIVITY` is a new field for MI3x ASICs, where device can support up to 32 JPEG engine activities. See our documentation for more in-depth understanding of these new fields.
@@ -230,6 +392,7 @@ GPU: 0
CURRENT_BANDWIDTH_RECEIVED: N/A
MAX_PACKET_SIZE: N/A
```
```shell
$ amd-smi metric --usage
GPU: 0
@@ -243,11 +406,13 @@ GPU: 0
0 %, 0 %, 0 %, 0 %]
```
- **Added AMDSMI Tool Version**
AMD SMI will report ***three versions***: AMDSMI Tool, AMDSMI Library version, and ROCm version.
The AMDSMI Tool version is the CLI/tool version number with commit ID appended after `+` sign.
The AMDSMI Library version is the library package version number.
The ROCm version is the system's installed ROCm version, if ROCm is not installed it will report N/A.
```shell
$ amd-smi version
AMDSMI Tool: 23.4.2+505b858 | AMDSMI Library version: 24.2.0.0 | ROCm version: 6.1.0
@@ -255,6 +420,7 @@ AMDSMI Tool: 23.4.2+505b858 | AMDSMI Library version: 24.2.0.0 | ROCm version: 6
- **Added XGMI table**
Displays XGMI information for AMD GPU devices in a table format. Only available on supported ASICs (eg. MI300). Here users can view read/write data XGMI or PCIe accumulated data transfer size (in KiloBytes).
```shell
$ amd-smi xgmi
LINK METRIC TABLE:
@@ -285,10 +451,12 @@ GPU7 0000:df:00.0 32 Gb/s 512 Gb/s XGMI
Write 0 KB 1 KB 1 KB 1 KB 1 KB 1 KB 1 KB N/A
```
- **Added units of measure to JSON output.**
We added unit of measure to JSON/CSV `amd-smi metric`, `amd-smi static`, and `amd-smi monitor` commands.
Ex.
```shell
amd-smi metric -p --json
[
@@ -321,7 +489,8 @@ amd-smi metric -p --json
### Changed
- **Topology is now left-aligned with BDF of each device listed individual table's row/coloumns.**
We provided each device's BDF for every table's row/columns, then left aligned data. We want AMD SMI Tool output to be easy to understand and digest for our users. Having users scroll up to find this information made it difficult to follow, especially for devices which have many devices associated with one ASIC.
We provided each device's BDF for every table's row/columns, then left aligned data. We want AMD SMI Tool output to be easy to understand and digest for our users. Having users scroll up to find this information made it difficult to follow, especially for devices which have many devices associated with one ASIC.
```shell
$ amd-smi topology
ACCESS TABLE:
@@ -381,6 +550,7 @@ NUMA BW TABLE:
```
### Optimizations
- N/A
### Fixed
@@ -388,20 +558,20 @@ NUMA BW TABLE:
- **Fix for Navi3X/Navi2X/MI100 `amdsmi_get_gpu_pci_bandwidth()` in frequencies_read tests**
Devices which do not report (eg. Navi3X/Navi2X/MI100) we have added checks to confirm these devices return AMDSMI_STATUS_NOT_SUPPORTED. Otherwise, tests now display a return string.
- **Fix for devices which have an older pyyaml installed**
Platforms which are identified as having an older pyyaml version or pip, we no manually update both pip and pyyaml as needed. This corrects issues identified below. Fix impacts the following CLI commands:
Platforms which are identified as having an older pyyaml version or pip, we no manually update both pip and pyyaml as needed. This corrects issues identified below. Fix impacts the following CLI commands:
- `amd-smi list`
- `amd-smi static`
- `amd-smi firmware`
- `amd-smi metric`
- `amd-smi topology`
```shell
TypeError: dump_all() got an unexpected keyword argument 'sort_keys'
```
- **Fix for crash when user is not a member of video/render groups**
- **Fix for crash when user is not a member of video/render groups**
AMD SMI now uses same mutex handler for devices as rocm-smi. This helps avoid crashes when DRM/device data is inaccessable to the logged in user.
### Known Issues
- N/A
@@ -419,12 +589,11 @@ You can now query MI300 device metrics to get real-time information. Metrics inc
- **Compute and memory partition support**
Users can now view, set, and reset partitions. The topology display can provide a more in-depth look at the device's current configuration.
### Changed
- **GPU index sorting made consistent with other tools**
To ensure alignment with other ROCm software tools, GPU index sorting is optimized to use Bus:Device.Function (BDF) rather than the card number.
- **Topology output is now aligned with GPU BDF table**
- **Topology output is now aligned with GPU BDF table**
Earlier versions of the topology output were difficult to read since each GPU was displayed linearly.
Now the information is displayed as a table by each GPU's BDF, which closer resembles rocm-smi output.
@@ -437,7 +606,6 @@ Now the information is displayed as a table by each GPU's BDF, which closer rese
- **Fix for driver not initialized**
If driver module is not loaded, user retrieve error reponse indicating amdgpu module is not loaded.
### Known Issues
- N/A
+1 -1
Wyświetl plik
@@ -28,7 +28,7 @@ find_program(GIT NAMES git)
## Setup the package version based on git tags.
set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver")
get_package_version_number("24.4.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
get_package_version_number("24.5.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
message("Package version: ${PKG_VERSION_STR}")
set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}")
set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}")
+46 -5
Wyświetl plik
@@ -79,7 +79,7 @@ amd-smi will report the version and current platform detected when running the c
~$ amd-smi
usage: amd-smi [-h] ...
AMD System Management Interface | Version: 24.4.0.0 | ROCm version: 6.1.0 | Platform: Linux Baremetal
AMD System Management Interface | Version: 24.5.0.0 | ROCm version: 6.1.1 | Platform: Linux Baremetal
options:
-h, --help show this help message and exit
@@ -513,6 +513,7 @@ Set Arguments:
NPS1, NPS2, NPS4, NPS8
-o, --power-cap WATTS Set power capacity limit
-p, --dpm-policy POLICY_ID Set the GPU DPM policy using policy id
-x, --xgmi-plpd POLICY_ID Set the GPU XGMI per-link power down policy using policy id
CPU Arguments:
--cpu-pwr-limit PWR_LIMIT Set power limit for the given socket. Input parameter is power limit value.
@@ -675,7 +676,7 @@ GPU: 0
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
POLICY:
DPM_POLICY:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -687,6 +688,16 @@ GPU: 0
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
NUMA:
NODE: 0
AFFINITY: 0
@@ -783,7 +794,7 @@ GPU: 1
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
POLICY:
DPM_POLICY:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -795,6 +806,16 @@ GPU: 1
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
NUMA:
NODE: 1
AFFINITY: 1
@@ -891,7 +912,7 @@ GPU: 2
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
POLICY:
DPM_POLICY:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -903,6 +924,16 @@ GPU: 2
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
NUMA:
NODE: 2
AFFINITY: 2
@@ -999,7 +1030,7 @@ GPU: 3
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
POLICY:
DPM_POLICY:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -1011,6 +1042,16 @@ GPU: 3
POLICY_DESCRIPTION: soc_pstate_1
POLICY_ID: 3
POLICY_DESCRIPTION: soc_pstate_2
XGMI_PLPD:
NUM_SUPPORTED: 3
CURRENT_ID: 1
PLPDS:
POLICY_ID: 0
POLICY_DESCRIPTION: plpd_disallow
POLICY_ID: 1
POLICY_DESCRIPTION: plpd_default
POLICY_ID: 2
POLICY_DESCRIPTION: plpd_optimized
NUMA:
NODE: 3
AFFINITY: 3
@@ -244,7 +244,8 @@ class AMDSMICommands():
def static_gpu(self, args, multiple_devices=False, gpu=None, asic=None, bus=None, vbios=None,
limit=None, driver=None, ras=None, board=None, numa=None, vram=None,
cache=None, partition=None, dfc_ucode=None, fb_info=None, num_vf=None, policy=None):
cache=None, partition=None, dfc_ucode=None, fb_info=None, num_vf=None,
policy=None, xgmi_plpd=None):
"""Get Static information for target gpu
Args:
@@ -268,6 +269,7 @@ class AMDSMICommands():
fb_info (bool, optional): Value override for args.fb_info. Defaults to None.
num_vf (bool, optional): Value override for args.num_vf. Defaults to None.
policy (bool, optional): Value override for args.policy. Defaults to None.
xgmi_plpd (bool, optional): Value override for args.xgmi_plpd. Defaults to None.
Returns:
None: Print output via AMDSMILogger to destination
"""
@@ -302,8 +304,10 @@ class AMDSMICommands():
args.limit = limit
if policy:
args.policy = policy
current_platform_args += ["ras", "limit", "partition", "policy"]
current_platform_values += [args.ras, args.limit, args.partition, args.policy]
if xgmi_plpd:
args.xgmi_plpd = xgmi_plpd
current_platform_args += ["ras", "limit", "partition", "policy", "xgmi_plpd"]
current_platform_values += [args.ras, args.limit, args.partition, args.policy, args.xgmi_plpd]
if self.helpers.is_linux() and not self.helpers.is_virtual_os():
if numa:
@@ -630,6 +634,15 @@ class AMDSMICommands():
logging.debug("Failed to get policy info for gpu %s | %s", gpu_id, e.get_error_info())
static_dict['dpm_policy'] = policy_info
if 'xgmi_plpd' in current_platform_args:
if args.xgmi_plpd:
try:
policy_info = amdsmi_interface.amdsmi_get_xgmi_plpd(args.gpu)
except amdsmi_exception.AmdSmiLibraryException as e:
policy_info = "N/A"
logging.debug("Failed to get xgmi_plpd info for gpu %s | %s", gpu_id, e.get_error_info())
static_dict['xgmi_plpd'] = policy_info
if 'numa' in current_platform_args:
if args.numa:
try:
@@ -766,7 +779,7 @@ class AMDSMICommands():
bus=None, vbios=None, limit=None, driver=None, ras=None,
board=None, numa=None, vram=None, cache=None, partition=None,
dfc_ucode=None, fb_info=None, num_vf=None, cpu=None,
interface_ver=None, policy=None):
interface_ver=None, policy=None, xgmi_plpd = None):
"""Get Static information for target gpu and cpu
Args:
@@ -790,6 +803,7 @@ class AMDSMICommands():
cpu (cpu_handle, optional): cpu_handle for target device. Defaults to None.
interface_ver (bool, optional): Value override for args.interface_ver. Defaults to None
policy (bool, optional): Value override for args.policy. Defaults to None.
xgmi_plpd (bool, optional): Value override for args.xgmi_plpd. Defaults to None.
Raises:
IndexError: Index error if gpu list is empty
@@ -815,7 +829,7 @@ class AMDSMICommands():
gpu_args_enabled = False
gpu_attributes = ["asic", "bus", "vbios", "limit", "driver", "ras",
"board", "numa", "vram", "cache", "partition",
"dfc_ucode", "fb_info", "num_vf", "policy"]
"dfc_ucode", "fb_info", "num_vf", "policy", "xgmi_plpd"]
for attr in gpu_attributes:
if hasattr(args, attr):
if getattr(args, attr):
@@ -859,7 +873,7 @@ class AMDSMICommands():
self.static_gpu(args, multiple_devices, gpu, asic,
bus, vbios, limit, driver, ras,
board, numa, vram, cache, partition,
dfc_ucode, fb_info, num_vf, policy)
dfc_ucode, fb_info, num_vf, policy, xgmi_plpd)
def firmware(self, args, multiple_devices=False, gpu=None, fw_list=True):
@@ -1330,73 +1344,189 @@ class AMDSMICommands():
values_dict['power'] = power_dict
if "clock" in current_platform_args:
if args.clock:
# Populate Skeleton output with N/A
clocks = {}
clock_types = [amdsmi_interface.AmdSmiClkType.GFX,
amdsmi_interface.AmdSmiClkType.MEM,
amdsmi_interface.AmdSmiClkType.VCLK0,
amdsmi_interface.AmdSmiClkType.VCLK1]
for clock_type in clock_types:
clock_name = amdsmi_interface.amdsmi_wrapper.amdsmi_clk_type_t__enumvalues[clock_type].replace("CLK_TYPE_", "")
# Ensure that gfx is the clock_name instead of another macro
if clock_type == amdsmi_interface.AmdSmiClkType.GFX:
clock_name = "gfx"
# Store the clock_name for vclk0
vlck0_clock_name = None
if clock_type == amdsmi_interface.AmdSmiClkType.VCLK0:
vlck0_clock_name = clock_name
for clock_index in range(amdsmi_interface.AMDSMI_MAX_NUM_GFX_CLKS):
gfx_index = f"gfx_{clock_index}"
clocks[gfx_index] = {"clk" : "N/A",
"min_clk" : "N/A",
"max_clk" : "N/A",
"clk_locked" : "N/A",
"deep_sleep" : "N/A"}
try:
clock_info_dict = amdsmi_interface.amdsmi_get_clock_info(args.gpu, clock_type)
clock_info = {"clk" : clock_info_dict["cur_clk"]}
del clock_info_dict["cur_clk"]
clock_info.update(clock_info_dict)
clocks["mem_0"] = {"clk" : "N/A",
"min_clk" : "N/A",
"max_clk" : "N/A",
"clk_locked" : "N/A",
"deep_sleep" : "N/A"}
if clock_info['sleep_clk'] == 0xFFFFFFFF:
clock_info['sleep_clk'] = "N/A"
for clock_index in range(amdsmi_interface.AMDSMI_MAX_NUM_CLKS):
vclk_index = f"vclk_{clock_index}"
clocks[vclk_index] = {"clk" : "N/A",
"min_clk" : "N/A",
"max_clk" : "N/A",
"clk_locked" : "N/A",
"deep_sleep" : "N/A"}
clock_freq_unit = 'MHz'
for key, value in clock_info.items():
if isinstance(value, int):
if self.logger.is_human_readable_format():
clock_info[key] = f"{value} {clock_freq_unit}"
if self.logger.is_json_format():
clock_info[key] = {"value" : value,
"unit" : clock_freq_unit}
for clock_index in range(amdsmi_interface.AMDSMI_MAX_NUM_CLKS):
dclk_index = f"dclk_{clock_index}"
clocks[dclk_index] = {"clk" : "N/A",
"min_clk" : "N/A",
"max_clk" : "N/A",
"clk_locked" : "N/A",
"deep_sleep" : "N/A"}
clocks[clock_name] = clock_info
except amdsmi_exception.AmdSmiLibraryException as e:
# Handle the case where VCLK1 is not enaled in sysfs on all GPUs
if clock_type == amdsmi_interface.AmdSmiClkType.VCLK1:
# Check if VCLK0 was retrieved successfully
if vlck0_clock_name in clocks:
# Since VCLK0 exists, do not error
logging.debug("VLCK0 exists, not adding %s clock info to output for gpu %s | %s", clock_name, gpu_id, e.get_error_info())
continue
else:
# Handle all other failed to get clock info
clocks[clock_name] = {"clk": "N/A",
"max_clk": "N/A",
"min_clk": "N/A",
"sleep_clk": "N/A"}
logging.debug("Failed to get %s clock info for gpu %s | %s", clock_name, gpu_id, e.get_error_info())
clock_unit = "MHz"
# TODO make the deepsleep threshold correspond to the * in sysfs for current deep sleep status
deep_sleep_threshold = 140
# Populate clock values from gpu_metrics_info
try:
gfxclk_lock_status = amdsmi_interface.amdsmi_get_gpu_metrics_info(args.gpu)['gfxclk_lock_status']
if gfxclk_lock_status != "N/A":
if gfxclk_lock_status:
gfxclk_lock_status = "ENABLED"
else:
gfxclk_lock_status = "DISABLED"
except amdsmi_exception.AmdSmiLibraryException as e:
gfxclk_lock_status = "N/A"
logging.debug("Failed to get gfx clock lock status info for gpu %s | %s", gpu_id, e.get_error_info())
gpu_metrics_info = amdsmi_interface.amdsmi_get_gpu_metrics_info(args.gpu)
if "gfx" in clocks:
if isinstance(clocks['gfx'], dict):
clocks['gfx']['clk_locked'] = gfxclk_lock_status
else:
clocks['gfx'] = {"clk_locked": gfxclk_lock_status}
# Populate GFX clock values
current_gfx_clocks = gpu_metrics_info["current_gfxclks"]
for clock_index, current_gfx_clock in enumerate(current_gfx_clocks):
# If the current clock is N/A then nothing else applies
if current_gfx_clock == "N/A":
continue
gfx_index = f"gfx_{clock_index}"
clocks[gfx_index]["clk"] = self.helpers.unit_format(self.logger,
current_gfx_clock,
clock_unit)
# Populate clock locked status
if gpu_metrics_info["gfxclk_lock_status"] != "N/A":
gfx_clock_lock_flag = 1 << clock_index # This is the position of the clock lock flag
if gpu_metrics_info["gfxclk_lock_status"] & gfx_clock_lock_flag:
clocks[gfx_index]["clk_locked"] = "ENABLED"
else:
clocks[gfx_index]["clk_locked"] = "DISABLED"
# Populate deep sleep status
if int(current_gfx_clock) <= deep_sleep_threshold:
clocks[gfx_index]["deep_sleep"] = "ENABLED"
else:
clocks[gfx_index]["deep_sleep"] = "DISABLED"
# Populate MEM clock value
current_mem_clock = gpu_metrics_info["current_uclk"] # single value
if current_mem_clock != "N/A":
clocks["mem_0"]["clk"] = self.helpers.unit_format(self.logger,
current_mem_clock,
clock_unit)
if int(current_mem_clock) <= deep_sleep_threshold:
clocks["mem_0"]["deep_sleep"] = "ENABLED"
else:
clocks["mem_0"]["deep_sleep"] = "DISABLED"
# Populate VCLK clock values
current_vclk_clocks = gpu_metrics_info["current_vclk0s"]
for clock_index, current_vclk_clock in enumerate(current_vclk_clocks):
# If the current clock is N/A then nothing else applies
if current_vclk_clock == "N/A":
continue
vclk_index = f"vclk_{clock_index}"
clocks[vclk_index]["clk"] = self.helpers.unit_format(self.logger,
current_vclk_clock,
clock_unit)
if int(current_vclk_clock) <= deep_sleep_threshold:
clocks[vclk_index]["deep_sleep"] = "ENABLED"
else:
clocks[vclk_index]["deep_sleep"] = "DISABLED"
# Populate DCLK clock values
current_dclk_clocks = gpu_metrics_info["current_dclk0s"]
for clock_index, current_dclk_clock in enumerate(current_dclk_clocks):
# If the current clock is N/A then nothing else applies
if current_dclk_clock == "N/A":
continue
dclk_index = f"dclk_{clock_index}"
clocks[dclk_index]["clk"] = self.helpers.unit_format(self.logger,
current_dclk_clock,
clock_unit)
if int(current_dclk_clock) <= deep_sleep_threshold:
clocks[dclk_index]["deep_sleep"] = "ENABLED"
else:
clocks[dclk_index]["deep_sleep"] = "DISABLED"
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get gpu_metrics_info for gpu %s | %s", gpu_id, e.get_error_info())
# Populate the max and min clock values from sysfs
# Min and Max values are per clock type, not per clock engine
# GFX min and max clocks
try:
gfx_clock_info_dict = amdsmi_interface.amdsmi_get_clock_info(args.gpu,
amdsmi_interface.AmdSmiClkType.GFX)
for clock_index in range(amdsmi_interface.AMDSMI_MAX_NUM_GFX_CLKS):
gfx_index = f"gfx_{clock_index}"
if clocks[gfx_index]["clk"] == "N/A":
# if the current clock is N/A then we shouldn't populate the max and min values
continue
clocks[gfx_index]["min_clk"] = self.helpers.unit_format(self.logger,
gfx_clock_info_dict["min_clk"],
clock_unit)
clocks[gfx_index]["max_clk"] = self.helpers.unit_format(self.logger,
gfx_clock_info_dict["max_clk"],
clock_unit)
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get gfx clock info for gpu %s | %s", gpu_id, e.get_error_info())
# MEM min and max clocks
try:
mem_clock_info_dict = amdsmi_interface.amdsmi_get_clock_info(args.gpu,
amdsmi_interface.AmdSmiClkType.MEM)
# if the current clock is N/A then we shouldn't populate the max and min values
if clocks["mem_0"]["clk"] != "N/A":
clocks["mem_0"]["min_clk"] = self.helpers.unit_format(self.logger,
mem_clock_info_dict["min_clk"],
clock_unit)
clocks["mem_0"]["max_clk"] = self.helpers.unit_format(self.logger,
mem_clock_info_dict["max_clk"],
clock_unit)
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get mem clock info for gpu %s | %s", gpu_id, e.get_error_info())
# VCLK & DCLK min and max clocks
try:
vclk0_clock_info_dict = amdsmi_interface.amdsmi_get_clock_info(args.gpu,
amdsmi_interface.AmdSmiClkType.VCLK0)
dclk0_clock_info_dict = amdsmi_interface.amdsmi_get_clock_info(args.gpu,
amdsmi_interface.AmdSmiClkType.DCLK0)
for clock_index in range(amdsmi_interface.AMDSMI_MAX_NUM_CLKS):
vclk_index = f"vclk_{clock_index}"
# if the current clock is N/A then we shouldn't populate the max and min values
if clocks[vclk_index]["clk"] != "N/A":
clocks[vclk_index]["min_clk"] = self.helpers.unit_format(self.logger,
vclk0_clock_info_dict["min_clk"],
clock_unit)
clocks[vclk_index]["max_clk"] = self.helpers.unit_format(self.logger,
vclk0_clock_info_dict["max_clk"],
clock_unit)
dclk_index = f"dclk_{clock_index}"
if clocks[dclk_index]["clk"] != "N/A":
clocks[dclk_index]["min_clk"] = self.helpers.unit_format(self.logger,
dclk0_clock_info_dict["min_clk"],
clock_unit)
clocks[dclk_index]["max_clk"] = self.helpers.unit_format(self.logger,
dclk0_clock_info_dict["max_clk"],
clock_unit)
except amdsmi_exception.AmdSmiLibraryException as e:
logging.debug("Failed to get vclk and/or dclk clock info for gpu %s | %s", gpu_id, e.get_error_info())
values_dict['clock'] = clocks
if "temperature" in current_platform_args:
@@ -1538,6 +1668,7 @@ class AMDSMICommands():
ecc_count = amdsmi_interface.amdsmi_get_gpu_total_ecc_count(args.gpu)
ecc_count['total_correctable_count'] = ecc_count.pop('correctable_count')
ecc_count['total_uncorrectable_count'] = ecc_count.pop('uncorrectable_count')
ecc_count['total_deferred_count'] = ecc_count.pop('deferred_count')
except amdsmi_exception.AmdSmiLibraryException as e:
ecc_count['total_correctable_count'] = "N/A"
ecc_count['total_uncorrectable_count'] = "N/A"
@@ -1561,7 +1692,7 @@ class AMDSMICommands():
if "ecc_blocks" in current_platform_args:
if args.ecc_blocks:
ecc_dict = {}
uncountable_blocks = ["ATHUB", "DF", "SMN", "SEM", "MP0", "MP1", "FUSE"]
uncountable_blocks = ["ATHUB", "DF", "SMN", "SEM", "FUSE"]
try:
ras_states = amdsmi_interface.amdsmi_get_gpu_ras_block_features_enabled(args.gpu)
for state in ras_states:
@@ -1572,10 +1703,12 @@ class AMDSMICommands():
try:
ecc_count = amdsmi_interface.amdsmi_get_gpu_ecc_count(args.gpu, gpu_block)
ecc_dict[state['block']] = {'correctable_count' : ecc_count['correctable_count'],
'uncorrectable_count' : ecc_count['uncorrectable_count']}
'uncorrectable_count' : ecc_count['uncorrectable_count'],
'deferred_count' : ecc_count['deferred_count']}
except amdsmi_exception.AmdSmiLibraryException as e:
ecc_dict[state['block']] = {'correctable_count' : "N/A",
'uncorrectable_count' : "N/A"}
'uncorrectable_count' : "N/A",
'deferred_count' : "N/A"}
logging.debug("Failed to get ecc count for gpu %s at block %s | %s", gpu_id, gpu_block, e.get_error_info())
values_dict['ecc_blocks'] = ecc_dict
@@ -3090,7 +3223,7 @@ class AMDSMICommands():
def set_gpu(self, args, multiple_devices=False, gpu=None, fan=None, perf_level=None,
profile=None, perf_determinism=None, compute_partition=None,
memory_partition=None, power_cap=None, dpm_policy=None):
memory_partition=None, power_cap=None, dpm_policy=None, xgmi_plpd = None):
"""Issue reset commands to target gpu(s)
Args:
@@ -3105,6 +3238,7 @@ class AMDSMICommands():
memory_partition (amdsmi_interface.AmdSmiMemoryPartitionType, optional): Value override for args.memory_partition. Defaults to None.
power_cap (int, optional): Value override for args.power_cap. Defaults to None.
dpm_policy (int, optional): Value override for args.dpm_policy. Defaults to None.
xgmi_plpd (int, optional): Value override for args.xgmi_plpd. Defaults to None.
Raises:
ValueError: Value error if no gpu value is provided
@@ -3132,6 +3266,8 @@ class AMDSMICommands():
args.power_cap = power_cap
if dpm_policy:
args.dpm_policy = dpm_policy
if xgmi_plpd:
args.xgmi_plpd = xgmi_plpd
# Handle No GPU passed
if args.gpu == None:
raise ValueError('No GPU provided, specific GPU target(s) are needed')
@@ -3151,7 +3287,8 @@ class AMDSMICommands():
args.memory_partition,
args.perf_determinism is not None,
args.power_cap,
args.dpm_policy]):
args.dpm_policy,
args.xgmi_plpd]):
command = " ".join(sys.argv[1:])
raise AmdSmiRequiredCommandException(command, self.logger.format)
@@ -3225,6 +3362,15 @@ class AMDSMICommands():
raise ValueError(f"Unable to set dpm policy to {args.dpm_policy} on {gpu_string}") from e
self.logger.store_output(args.gpu, 'dpmpolicy', f"Successfully set dpm policy to id {args.dpm_policy}")
if args.xgmi_plpd:
try:
amdsmi_interface.amdsmi_set_xgmi_plpd(args.gpu, args.xgmi_plpd)
except amdsmi_exception.AmdSmiLibraryException as e:
if e.get_error_code() == amdsmi_interface.amdsmi_wrapper.AMDSMI_STATUS_NO_PERM:
raise PermissionError('Command requires elevation') from e
raise ValueError(f"Unable to set XGMI policy to {args.xgmi_plpd} on {gpu_string}") from e
self.logger.store_output(args.gpu, 'xgmiplpd', f"Successfully set per-link power down policy to id {args.dpm_policy}")
if isinstance(args.power_cap, int):
try:
power_cap_info = amdsmi_interface.amdsmi_get_power_cap_info(args.gpu)
@@ -3264,7 +3410,7 @@ class AMDSMICommands():
cpu=None, cpu_pwr_limit=None, cpu_xgmi_link_width=None, cpu_lclk_dpm_level=None,
cpu_pwr_eff_mode=None, cpu_gmi3_link_width=None, cpu_pcie_link_rate=None,
cpu_df_pstate_range=None, cpu_enable_apb=None, cpu_disable_apb=None,
soc_boost_limit=None, core=None, core_boost_limit=None, dpm_policy=None):
soc_boost_limit=None, core=None, core_boost_limit=None, dpm_policy=None, xgmi_plpd=None):
"""Issue reset commands to target gpu(s)
Args:
@@ -3294,6 +3440,7 @@ class AMDSMICommands():
core (device_handle, optional): device_handle for target core. Defaults to None.
core_boost_limit (int, optional): Value override for args.core_boost_limit. Defaults to None
dpm_policy (int, optional): Value override for args.dpm_policy. Defaults to None.
xgmi_plpd (int, optional): Value override for args.xgmi_plpd. Defaults to None.
Raises:
ValueError: Value error if no gpu value is provided
@@ -3314,7 +3461,7 @@ class AMDSMICommands():
# Check if a GPU argument has been set
gpu_args_enabled = False
gpu_attributes = ["fan", "perf_level", "profile", "perf_determinism", "compute_partition",
"memory_partition", "power_cap", "dpm_policy"]
"memory_partition", "power_cap", "dpm_policy", "xgmi_plpd"]
for attr in gpu_attributes:
if hasattr(args, attr):
if getattr(args, attr) is not None:
@@ -3325,18 +3472,13 @@ class AMDSMICommands():
cpu_args_enabled = False
cpu_attributes = ["cpu_pwr_limit", "cpu_xgmi_link_width", "cpu_lclk_dpm_level", "cpu_pwr_eff_mode",
"cpu_gmi3_link_width", "cpu_pcie_link_rate", "cpu_df_pstate_range",
"cpu_disable_apb", "soc_boost_limit"]
"cpu_enable_apb", "cpu_disable_apb", "soc_boost_limit"]
for attr in cpu_attributes:
if hasattr(args, attr):
if getattr(args, attr) is not None:
cpu_args_enabled = True
break
# Check if CPU set argument with store_true has been passed
if hasattr(args, "cpu_enable_apb"):
if getattr(args, attr):
cpu_args_enabled = True
# Check if a Core argument has been set
core_args_enabled = False
core_attributes = ["core_boost_limit"]
@@ -3375,7 +3517,7 @@ class AMDSMICommands():
self.logger.clear_multiple_devices_ouput()
self.set_gpu(args, multiple_devices, gpu, fan, perf_level,
profile, perf_determinism, compute_partition,
memory_partition, power_cap, dpm_policy)
memory_partition, power_cap, dpm_policy, xgmi_plpd)
elif self.helpers.is_amd_hsmp_initialized(): # Only CPU is initialized
if args.cpu == None and args.core == None:
raise ValueError('No CPU or CORE provided, specific target(s) are needed')
@@ -3394,7 +3536,7 @@ class AMDSMICommands():
self.logger.clear_multiple_devices_ouput()
self.set_gpu(args, multiple_devices, gpu, fan, perf_level,
profile, perf_determinism, compute_partition,
memory_partition, power_cap, dpm_policy)
memory_partition, power_cap, dpm_policy, xgmi_plpd)
def reset(self, args, multiple_devices=False, gpu=None, gpureset=None,
@@ -4093,7 +4235,7 @@ class AMDSMICommands():
for xgmi_dict in xgmi_values:
src_gpu_id = xgmi_dict['gpu']
src_gpu_bdf = xgmi_dict['bdf']
src_gpu = amdsmi_interface.amdsmi_get_processor_handle_from_bdf(src_gpu_bdf) #TODO VERIFY this is correct
src_gpu = amdsmi_interface.amdsmi_get_processor_handle_from_bdf(src_gpu_bdf)
logging.debug("check2 device_handle: %s", src_gpu)
# This should be the same order as the check1
@@ -4233,7 +4375,7 @@ class AMDSMICommands():
self.logger.multiple_device_output = xgmi_values
if self.logger.is_csv_format(): # @TODO Test topology override needed
if self.logger.is_csv_format():
new_output = []
for elem in self.logger.multiple_device_output:
new_output.append(self.logger.flatten_dict(elem, topology_override=True))
@@ -412,7 +412,7 @@ class AMDSMIHelpers():
return True, selected_device_handles
def handle_gpus(self, args,logger, subcommand):
def handle_gpus(self, args, logger, subcommand):
"""This function will run execute the subcommands based on the number
of gpus passed in via args.
params:
@@ -708,3 +708,21 @@ class AMDSMIHelpers():
return f"{bytes_input:3.1f} {unit}"
bytes_input /= 1024
return f"{bytes_input:.1f} YB"
def unit_format(self, logger, value, unit):
"""This function will format output with unit based on the logger output format
params:
args - argparser args to pass to subcommand
logger (AMDSMILogger) - Logger to print out output
value - the value to be formatted
unit - the unit to be formatted with the value
return:
str or dict : formatted output
"""
if logger.is_json_format():
return {"value": value, "unit": unit}
if logger.is_human_readable_format():
return f"{value} {unit}"
return f"{value}"
@@ -544,6 +544,7 @@ class AMDSMIParser(argparse.ArgumentParser):
cache_help = "All cache information"
board_help = "All board information"
dpm_policy_help = "The available DPM policy"
xgmi_plpd_help = "The available XGMI per-link power down policy"
# Options arguments help text for Hypervisors and Baremetal
ras_help = "Displays RAS features information"
@@ -584,6 +585,7 @@ class AMDSMIParser(argparse.ArgumentParser):
static_parser.add_argument('-p', '--partition', action='store_true', required=False, help=partition_help)
static_parser.add_argument('-l', '--limit', action='store_true', required=False, help=limit_help)
static_parser.add_argument('-P', '--policy', action='store_true', required=False, help=dpm_policy_help)
static_parser.add_argument('-x', '--xgmi-plpd', action='store_true', required=False, help=xgmi_plpd_help)
if self.helpers.is_linux() and not self.helpers.is_virtual_os():
static_parser.add_argument('-u', '--numa', action='store_true', required=False, help=numa_help)
@@ -966,6 +968,7 @@ class AMDSMIParser(argparse.ArgumentParser):
set_memory_partition_help = f"Set one of the following the memory partition modes:\n\t{memory_partition_choices_str}"
set_power_cap_help = "Set power capacity limit"
set_dpm_policy_help = f"Set the GPU DPM policy using policy id\n"
set_xgmi_plpd_help = f"Set the GPU XGMI per-link power down policy using policy id\n"
# Help text for CPU set options
set_cpu_pwr_limit_help = "Set power limit for the given socket. Input parameter is power limit value."
@@ -1002,6 +1005,7 @@ class AMDSMIParser(argparse.ArgumentParser):
set_value_parser.add_argument('-M', '--memory-partition', action='store', choices=self.helpers.get_memory_partition_types(), type=str.upper, required=False, help=set_memory_partition_help, metavar='PARTITION')
set_value_parser.add_argument('-o', '--power-cap', action='store', type=self._positive_int, required=False, help=set_power_cap_help, metavar='WATTS')
set_value_parser.add_argument('-p', '--dpm-policy', action='store', required=False, type=self._not_negative_int, help=set_dpm_policy_help, metavar='POLICY_ID')
set_value_parser.add_argument('-x', '--xgmi-plpd', action='store', required=False, type=self._not_negative_int, help=set_xgmi_plpd_help, metavar='POLICY_ID')
if self.helpers.is_amd_hsmp_initialized():
# Optional CPU Args
+1 -1
Wyświetl plik
@@ -48,7 +48,7 @@ PROJECT_NAME = AMD SMI
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "24.4.0.0"
PROJECT_NUMBER = "24.5.0.0"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -495,6 +495,7 @@ typedef union {
typedef enum {
AMDSMI_CARD_FORM_FACTOR_PCIE,
AMDSMI_CARD_FORM_FACTOR_OAM,
AMDSMI_CARD_FORM_FACTOR_CEM,
AMDSMI_CARD_FORM_FACTOR_UNKNOWN
} amdsmi_card_form_factor_t;
@@ -3405,6 +3406,49 @@ amdsmi_status_t amdsmi_get_dpm_policy(amdsmi_processor_handle processor_handle,
*/
amdsmi_status_t amdsmi_set_dpm_policy(amdsmi_processor_handle processor_handle,
uint32_t policy_id);
/**
* @brief Get the xgmi per-link power down policy parameter for the processor
*
* @platform{gpu_bm_linux}
*
* @details Given a processor handle @p processor_handle, this function will write
* current xgmi plpd settings to @p policy. All the processors at the same socket
* will have the same policy.
*
* @param[in] processor_handle a processor handle
*
* @param[in, out] policy the xgmi plpd for this processor.
* If this parameter is nullptr, this function will return
* ::AMDSMI_STATUS_INVAL
*
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
*/
amdsmi_status_t amdsmi_get_xgmi_plpd(amdsmi_processor_handle processor_handle,
amdsmi_dpm_policy_t* xgmi_plpd);
/**
* @brief Set the xgmi per-link power down policy parameter for the processor
*
* @platform{gpu_bm_linux}
*
* @details Given a processor handle @p processor_handle and a dpm policy @p plpd_id,
* this function will set the xgmi plpd for this processor. All the processors at
* the same socket will be set to the same policy.
*
* @note This function requires root access
*
* @param[in] processor_handle a processor handle
*
* @param[in] xgmi_plpd_id the xgmi plpd id to set. The id is the id in
* amdsmi_dpm_policy_entry_t, which can be obtained by calling
* amdsmi_get_xgmi_plpd()
*
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
*/
amdsmi_status_t amdsmi_set_xgmi_plpd(amdsmi_processor_handle processor_handle,
uint32_t plpd_id);
/** @} End PerfCont */
/*****************************************************************************/
+101 -13
Wyświetl plik
@@ -73,9 +73,9 @@ except AmdSmiException as e:
### amdsmi_init
Description: Dynamically initialize amdsmi with amd_hsmp and amdgpu drivers
Description: Initialize amdsmi with AmdSmiInitFlags
Input parameters: `None`
Input parameters: AmdSmiInitFlags
Output: `None`
@@ -83,19 +83,37 @@ Exceptions that can be thrown by `amdsmi_init` function:
* `AmdSmiLibraryException`
Example:
Initialize GPUs only example:
```python
try:
# by default we initalize with AmdSmiInitFlags.INIT_AMD_GPUS
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")
print("Init GPUs failed")
print(e)
```
Initialize CPUs only example:
```python
try:
init_flag = amdsmi_init(AmdSmiInitFlags.INIT_AMD_CPUS)
# continue with amdsmi
except AmdSmiException as e:
print("Init CPUs failed")
print(e)
```
Initialize both GPUs and CPUs example:
```python
try:
init_flag = amdsmi_init(AmdSmiInitFlags.INIT_AMD_APUS)
# continue with amdsmi
except AmdSmiException as e:
print("Init both GPUs & CPUs failed")
print(e)
```
@@ -791,7 +809,7 @@ Output: Dictionary with 2 fields `pcie_static` and `pcie_metric`
Fields | Description
---|---
`pcie_static` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`max_pcie_width`</td><td>Maximum number of pcie lanes available</td></tr><tr><td>`max_pcie_speed`</td><td>Maximum capable pcie speed in GT/s</td></tr><tr><td>`pcie_interface_version`</td><td>PCIe generation ie. 3,4,5...</td></tr><tr><td>`slot_type`</td><td>The type of form factor of the slot: PCIE, OAM, or Unknown</td></tr></tbody></table>
`pcie_static` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`max_pcie_width`</td><td>Maximum number of pcie lanes available</td></tr><tr><td>`max_pcie_speed`</td><td>Maximum capable pcie speed in GT/s</td></tr><tr><td>`pcie_interface_version`</td><td>PCIe generation ie. 3,4,5...</td></tr><tr><td>`slot_type`</td><td>The type of form factor of the slot: OAM, PCIE, CEM, or Unknown</td></tr></tbody></table>
`pcie_metric` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`pcie_width`</td><td>Current number of pcie lanes available</td></tr><tr><td>`pcie_speed`</td><td>Current pcie speed capable in GT/s</td></tr><tr><td>`pcie_bandwidth`</td><td>Current instantaneous bandwidth usage in Mb/s</td></tr><tr><td>`pcie_replay_count`</td><td>Total number of PCIe replays (NAKs)</td></tr><tr><td>`pcie_l0_to_recovery_count`</td><td>PCIE L0 to recovery state transition accumulated count</td></tr><tr><td>`pcie_replay_roll_over_count`</td><td>PCIe Replay accumulated count</td></tr><tr><td>`pcie_nak_sent_count`</td><td>PCIe NAK sent accumulated count</td></tr><tr><td>`pcie_nak_received_count`</td><td>PCIe NAK received accumulated count</td></tr></tbody></table>
Exceptions that can be thrown by `amdsmi_get_pcie_info` function:
@@ -909,8 +927,8 @@ Field | Description
`name` | Name of process
`pid` | Process ID
`mem` | Process memory usage
`engine_usage`| <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gfx`</td><td>GFX engine usage in ns</td></tr><tr><td>`enc`</td><td>Encode engine usage in ns</td></tr></tbody></table>
`memory_usage`| <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gtt_mem`</td><td>GTT memory usage</td></tr><tr><td>`cpu_mem`</td><td>CPU memory usage</td></tr><tr><td>`vram_mem`</td><td>VRAM memory usage</td></tr> </tbody></table>
`engine_usage` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gfx`</td><td>GFX engine usage in ns</td></tr><tr><td>`enc`</td><td>Encode engine usage in ns</td></tr></tbody></table>
`memory_usage` | <table><thead><tr> <th> Subfield </th> <th> Description</th> </tr></thead><tbody><tr><td>`gtt_mem`</td><td>GTT memory usage</td></tr><tr><td>`cpu_mem`</td><td>CPU memory usage</td></tr><tr><td>`vram_mem`</td><td>VRAM memory usage</td></tr> </tbody></table>
Exceptions that can be thrown by `amdsmi_get_gpu_process_info` function:
@@ -949,6 +967,7 @@ Field | Description
---|---
`correctable_count` | Correctable ECC error count
`uncorrectable_count` | Uncorrectable ECC error count
`deferred_count` | Deferred ECC error count
Exceptions that can be thrown by `amdsmi_get_gpu_total_ecc_count` function:
@@ -2137,7 +2156,7 @@ Output: Dictionary with fields
`indep_throttle_status` | ASIC independent throttle status (see drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h for bit flags) |
`current_socket_power` | Current socket power (also known as instant socket power) | W
`vcn_activity` | List of VCN encode/decode engine utilization per AID | %
`gfxclk_lock_status` | Clock lock status. Each bit corresponds to clock instance. |
`gfxclk_lock_status` | Clock lock status. Bits 0:7 correspond to each gfx clock engine instance. Bits 0:5 for APU/AID devices |
`xgmi_link_width` | XGMI bus width | lanes
`xgmi_link_speed` | XGMI bitrate | GB/s
`pcie_bandwidth_acc` | PCIe accumulated bandwidth | GB/s
@@ -2612,6 +2631,74 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_set_xgmi_plpd
Description: Set the xgmi per-link power down policy parameter for the processor
Input parameters:
* `processor_handle` handle for the given device
* `policy_id` the xgmi plpd id to set.
Output: None
Exceptions that can be thrown by `amdsmi_set_xgmi_plpd` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
amdsmi_set_xgmi_plpd(device, 0)
except AmdSmiException as e:
print(e)
```
### amdsmi_get_xgmi_plpd
Description: Get the xgmi per-link power down policy parameter for the processor
Input parameters:
* `processor_handle` handle for the given device
Output: Dict containing information about xgmi per-link power down policy
Field | Description
---|---
`num_supported` | The number of supported policies
`current_id` | The current policy index
`plpds` | List of policies.
Exceptions that can be thrown by `amdsmi_get_xgmi_plpd` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = amdsmi_get_processor_handles()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
xgmi_plpd = amdsmi_get_xgmi_plpd(device)
print(xgmi_plpd)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_gpu_overdrive_level
Description: **deprecated** Set the overdrive percent associated with the
@@ -2661,6 +2748,7 @@ Field | Description
---|---
`correctable_count` | Count of correctable errors
`uncorrectable_count` | Count of uncorrectable errors
`deferred_count` | Count of deferred errors
Exceptions that can be thrown by `amdsmi_get_gpu_ecc_count` function:
@@ -1821,16 +1821,17 @@ def amdsmi_get_gpu_total_ecc_count(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
error_count = amdsmi_wrapper.amdsmi_error_count_t()
ec = amdsmi_wrapper.amdsmi_error_count_t()
_check_res(
amdsmi_wrapper.amdsmi_get_gpu_total_ecc_count(
processor_handle, ctypes.byref(error_count)
processor_handle, ctypes.byref(ec)
)
)
return {
"correctable_count": error_count.correctable_count,
"uncorrectable_count": error_count.uncorrectable_count,
"correctable_count": ec.correctable_count,
"uncorrectable_count": ec.uncorrectable_count,
"deferred_count": ec.deferred_count,
}
@@ -1848,7 +1849,7 @@ def amdsmi_get_gpu_board_info(
processor_handle, ctypes.byref(board_info))
)
return {
board_info_dict = {
"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(),
@@ -1856,6 +1857,12 @@ def amdsmi_get_gpu_board_info(
"manufacturer_name": board_info.manufacturer_name.decode("utf-8").strip()
}
for key, value in board_info_dict.items():
if value == "":
board_info_dict[key] = "N/A"
return board_info_dict
def amdsmi_get_gpu_ras_feature_info(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
@@ -2032,7 +2039,7 @@ def amdsmi_get_power_info(
)
)
return {
power_info_dict = {
"current_socket_power": power_measure.current_socket_power,
"average_socket_power": power_measure.average_socket_power,
"gfx_voltage": power_measure.gfx_voltage,
@@ -2041,6 +2048,12 @@ def amdsmi_get_power_info(
"power_limit" : power_measure.power_limit,
}
for key, value in power_info_dict.items():
if value == 0xFFFF:
power_info_dict[key] = "N/A"
return power_info_dict
def amdsmi_is_gpu_power_management_enabled(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle
@@ -2746,6 +2759,20 @@ def amdsmi_set_dpm_policy(
)
)
def amdsmi_set_xgmi_plpd(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
policy_id: int,
):
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
_check_res(
amdsmi_wrapper.amdsmi_set_xgmi_plpd(
processor_handle, policy_id
)
)
def amdsmi_set_gpu_overdrive_level(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, overdrive_value: int
):
@@ -3335,6 +3362,37 @@ def amdsmi_get_dpm_policy(
"policies": polices,
}
def amdsmi_get_xgmi_plpd(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
policy = amdsmi_wrapper.amdsmi_dpm_policy_t()
_check_res(
amdsmi_wrapper.amdsmi_get_xgmi_plpd(
processor_handle, ctypes.byref(policy)
)
)
polices = []
for i in range(0, policy.num_supported):
id = policy.policies[i].policy_id
desc = policy.policies[i].policy_description
polices.append({
'policy_id' : id,
'policy_description': desc.decode()
})
current_id = policy.policies[policy.current].policy_id
return {
"num_supported": policy.num_supported,
"current_id": current_id,
"plpds": polices,
}
def amdsmi_get_gpu_od_volt_info(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
@@ -3462,7 +3520,7 @@ def amdsmi_get_gpu_metrics_info(
if gpu_metrics_output[metric] == 0xFFFF:
gpu_metrics_output[metric] = "N/A"
uint_32_metrics = ['gfx_activity_acc','mem_activity_acc', 'pcie_nak_sent_count_acc', 'pcie_nak_rcvd_count_acc']
uint_32_metrics = ['gfx_activity_acc','mem_activity_acc', 'pcie_nak_sent_count_acc', 'pcie_nak_rcvd_count_acc', 'gfxclk_lock_status']
for metric in uint_32_metrics:
if gpu_metrics_output[metric] == 0xFFFFFFFF:
gpu_metrics_output[metric] = "N/A"
@@ -3476,7 +3534,7 @@ def amdsmi_get_gpu_metrics_info(
gpu_metrics_output[metric] = "N/A"
# Custom validation for metrics in a bool format
uint_32_bool_metrics = ['throttle_status', 'gfxclk_lock_status']
uint_32_bool_metrics = ['throttle_status']
for metric in uint_32_bool_metrics:
if gpu_metrics_output[metric] == 0xFFFFFFFF:
gpu_metrics_output[metric] = "N/A"
@@ -3598,6 +3656,7 @@ def amdsmi_get_gpu_ecc_count(
return {
"correctable_count": ec.correctable_count,
"uncorrectable_count": ec.uncorrectable_count,
"deferred_count": ec.deferred_count,
}
@@ -737,28 +737,17 @@ amdsmi_bdf_t = union_amdsmi_bdf_t
amdsmi_card_form_factor_t__enumvalues = {
0: 'AMDSMI_CARD_FORM_FACTOR_PCIE',
1: 'AMDSMI_CARD_FORM_FACTOR_OAM',
2: 'AMDSMI_CARD_FORM_FACTOR_UNKNOWN',
2: 'AMDSMI_CARD_FORM_FACTOR_CEM',
3: 'AMDSMI_CARD_FORM_FACTOR_UNKNOWN',
}
AMDSMI_CARD_FORM_FACTOR_PCIE = 0
AMDSMI_CARD_FORM_FACTOR_OAM = 1
AMDSMI_CARD_FORM_FACTOR_UNKNOWN = 2
AMDSMI_CARD_FORM_FACTOR_CEM = 2
AMDSMI_CARD_FORM_FACTOR_UNKNOWN = 3
amdsmi_card_form_factor_t = ctypes.c_uint32 # enum
class struct_amdsmi_pcie_info_t(Structure):
pass
class struct_pcie_static_(Structure):
pass
struct_pcie_static_._pack_ = 1 # source:False
struct_pcie_static_._fields_ = [
('max_pcie_width', ctypes.c_uint16),
('PADDING_0', ctypes.c_ubyte * 2),
('max_pcie_speed', ctypes.c_uint32),
('pcie_interface_version', ctypes.c_uint32),
('slot_type', amdsmi_card_form_factor_t),
('reserved', ctypes.c_uint64 * 10),
]
class struct_pcie_metric_(Structure):
pass
@@ -777,6 +766,19 @@ struct_pcie_metric_._fields_ = [
('reserved', ctypes.c_uint64 * 13),
]
class struct_pcie_static_(Structure):
pass
struct_pcie_static_._pack_ = 1 # source:False
struct_pcie_static_._fields_ = [
('max_pcie_width', ctypes.c_uint16),
('PADDING_0', ctypes.c_ubyte * 2),
('max_pcie_speed', ctypes.c_uint32),
('pcie_interface_version', ctypes.c_uint32),
('slot_type', amdsmi_card_form_factor_t),
('reserved', ctypes.c_uint64 * 10),
]
struct_amdsmi_pcie_info_t._pack_ = 1 # source:False
struct_amdsmi_pcie_info_t._fields_ = [
('pcie_static', struct_pcie_static_),
@@ -2058,6 +2060,12 @@ amdsmi_get_dpm_policy.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct
amdsmi_set_dpm_policy = _libraries['libamd_smi.so'].amdsmi_set_dpm_policy
amdsmi_set_dpm_policy.restype = amdsmi_status_t
amdsmi_set_dpm_policy.argtypes = [amdsmi_processor_handle, uint32_t]
amdsmi_get_xgmi_plpd = _libraries['libamd_smi.so'].amdsmi_get_xgmi_plpd
amdsmi_get_xgmi_plpd.restype = amdsmi_status_t
amdsmi_get_xgmi_plpd.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_dpm_policy_t)]
amdsmi_set_xgmi_plpd = _libraries['libamd_smi.so'].amdsmi_set_xgmi_plpd
amdsmi_set_xgmi_plpd.restype = amdsmi_status_t
amdsmi_set_xgmi_plpd.argtypes = [amdsmi_processor_handle, uint32_t]
amdsmi_get_lib_version = _libraries['libamd_smi.so'].amdsmi_get_lib_version
amdsmi_get_lib_version.restype = amdsmi_status_t
amdsmi_get_lib_version.argtypes = [ctypes.POINTER(struct_amdsmi_version_t)]
@@ -2341,10 +2349,10 @@ __all__ = \
'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_CACHE_PROPERTY_SIMD_CACHE', 'AMDSMI_CARD_FORM_FACTOR_CEM',
'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',
@@ -2594,8 +2602,9 @@ __all__ = \
'amdsmi_get_processor_info', 'amdsmi_get_processor_type',
'amdsmi_get_socket_handles', 'amdsmi_get_socket_info',
'amdsmi_get_temp_metric', 'amdsmi_get_utilization_count',
'amdsmi_get_xgmi_info', 'amdsmi_gpu_block_t',
'amdsmi_gpu_cache_info_t', 'amdsmi_gpu_control_counter',
'amdsmi_get_xgmi_info', 'amdsmi_get_xgmi_plpd',
'amdsmi_gpu_block_t', 'amdsmi_gpu_cache_info_t',
'amdsmi_gpu_control_counter',
'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',
@@ -2636,10 +2645,10 @@ __all__ = \
'amdsmi_set_gpu_overdrive_level', 'amdsmi_set_gpu_pci_bandwidth',
'amdsmi_set_gpu_perf_determinism_mode',
'amdsmi_set_gpu_perf_level', 'amdsmi_set_gpu_power_profile',
'amdsmi_set_power_cap', 'amdsmi_shut_down',
'amdsmi_smu_fw_version_t', 'amdsmi_socket_handle',
'amdsmi_status_code_to_string', 'amdsmi_status_t',
'amdsmi_stop_gpu_event_notification',
'amdsmi_set_power_cap', 'amdsmi_set_xgmi_plpd',
'amdsmi_shut_down', 'amdsmi_smu_fw_version_t',
'amdsmi_socket_handle', 'amdsmi_status_code_to_string',
'amdsmi_status_t', 'amdsmi_stop_gpu_event_notification',
'amdsmi_temp_range_refresh_rate_t', 'amdsmi_temperature_metric_t',
'amdsmi_temperature_type_t', 'amdsmi_topo_get_link_type',
'amdsmi_topo_get_link_weight', 'amdsmi_topo_get_numa_node_number',
@@ -3364,6 +3364,45 @@ rsmi_status_t rsmi_dev_dpm_policy_get(uint32_t dv_ind,
rsmi_status_t rsmi_dev_dpm_policy_set(uint32_t dv_ind,
uint32_t policy_id);
/**
* @brief Get the xgmi per-link power down policy parameter for a device
*
*
* @details Given a device index @p dv_ind, this function will write
* current xgmi plpd settings to @p xgmi_plpd. All the processors at the same socket
* will have the same policy.
*
* @param[in] dv_ind a device index
*
* @param[in, out] xgmi_plpd the xgmi_plpd policy for this device.
* If this parameter is nullptr, this function will return
* ::RSMI_STATUS_INVAL
*
* @return ::RSMI_STATUS_SUCCESS is returned upon successful call, non-zero on fail
*/
rsmi_status_t rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
rsmi_dpm_policy_t* xgmi_plpd);
/**
* @brief Set the xgmi per-link power down policy parameter for a device
*
*
* @details Given a device index @p dv_ind, and a dpm policy @p plpd_id,
* this function will set the xgmi plpd for this processor. All the processors at
* the same socket will be set to the same policy.
*
* @note This function requires root access
*
* @param[in] processor_handle a processor handle
*
* @param[in] xgmi_plpd_id the xgmi plpd id to set. The id is the id in
* rsmi_dpm_policy_entry_t, which can be obtained by calling
* rsmi_dev_xgmi_plpd_get()
*
* @return ::RSMI_STATUS_SUCCESS is returned upon successful call, non-zero on fail
*/
rsmi_status_t rsmi_dev_xgmi_plpd_set(uint32_t dv_ind,
uint32_t plpd_id);
/** @} */ // end of PerfCont
/*****************************************************************************/
+126 -2
Wyświetl plik
@@ -2038,6 +2038,130 @@ rsmi_dev_dpm_policy_set(uint32_t dv_ind,
CATCH
}
rsmi_status_t
rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
rsmi_dpm_policy_t* policy) {
rsmi_status_t ret;
std::vector<std::string> val_vec;
if (policy == nullptr) {
return RSMI_STATUS_INVALID_ARGS;
}
*policy = {};
TRY
std::ostringstream ss;
ss << __PRETTY_FUNCTION__ << " | ======= start =======";
LOG_TRACE(ss);
DEVICE_MUTEX
ret = GetDevValueVec(amd::smi::kDevDPMPolicy, dv_ind, &val_vec);
if (ret == RSMI_STATUS_FILE_ERROR) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", GetDevValueVec() ret was RSMI_STATUS_FILE_ERROR "
<< "-> reporting RSMI_STATUS_NOT_SUPPORTED";
LOG_ERROR(ss);
return RSMI_STATUS_NOT_SUPPORTED;
}
if (ret != RSMI_STATUS_SUCCESS) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", GetDevValueVec() ret was not RSMI_STATUS_SUCCESS"
<< " -> reporting " << amd::smi::getRSMIStatusString(ret);
LOG_ERROR(ss);
return ret;
}
/*
It will reply on the number but no string as it may vary from soc to soc.
The current xmgi plpd marked with *
xgmi plpd
0 : plpd_disallow
1 : plpd_default
2 : plpd_optimized*
*/
bool see_plpd_pstate = false;
bool see_current = false;
policy->num_supported = 0;
for (uint32_t i = 0; i < val_vec.size(); ++i) {
auto current_line = amd::smi::trim(val_vec[i]);
if (current_line == "xgmi plpd") {
see_plpd_pstate = true;
continue;
}
if (see_plpd_pstate == false) continue;
// Get tokens: <integer> : <string *>
std::vector<std::string> tokens;
std::istringstream f(current_line);
std::string s;
while (getline(f, s, ':')) {
tokens.push_back(s);
}
int value = 0;
// At the end
if (tokens.size() < 2 || !amd::smi::stringToInteger(tokens[0], value)) {
break;
}
if (value < 0 || policy->num_supported >= RSMI_MAX_NUM_PM_POLICIES) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", Unexpected pstat data: the id is negative or too many plpd policies.";
LOG_ERROR(ss);
return RSMI_STATUS_UNEXPECTED_DATA;
}
policy->policies[policy->num_supported].policy_id = value;
std::string description = amd::smi::trim(tokens[1]);
if (current_line.back() == '*') { // current policy
description.pop_back(); // remove last *
description = amd::smi::trim(description);
policy->current = policy->num_supported;
see_current = true;
}
strncpy(policy->policies[policy->num_supported].policy_description,
description.c_str(),
RSMI_MAX_POLICY_NAME-1);
policy->num_supported++;
} // end for
if (!see_plpd_pstate) {
return RSMI_STATUS_NOT_SUPPORTED;
}
if (!see_current) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", Unexpected pstat data: cannot find the current plpd policy.";
LOG_ERROR(ss);
return RSMI_STATUS_UNEXPECTED_DATA;
}
// Cannot find it
return RSMI_STATUS_SUCCESS;
CATCH
}
rsmi_status_t
rsmi_dev_xgmi_plpd_set(uint32_t dv_ind,
uint32_t plpd_id) {
rsmi_status_t ret;
TRY
std::ostringstream ss;
ss << __PRETTY_FUNCTION__ << " | ======= start =======";
LOG_TRACE(ss);
REQUIRE_ROOT_ACCESS
DEVICE_MUTEX
GET_DEV_FROM_INDX
std::string value("xgmi ");
value += std::to_string(plpd_id);
int ret = dev->writeDevInfo(amd::smi::kDevDPMPolicy , value);
return amd::smi::ErrnoToRsmiStatus(ret);
CATCH
}
rsmi_status_t
rsmi_dev_dpm_policy_get(uint32_t dv_ind,
rsmi_dpm_policy_t* policy) {
@@ -2107,7 +2231,7 @@ rsmi_dev_dpm_policy_get(uint32_t dv_ind,
if (value < 0 || policy->num_supported >= RSMI_MAX_NUM_PM_POLICIES) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", Unexpeced pstat data: the id is negative or too many policies.";
<< ", Unexpected pstat data: the id is negative or too many policies.";
LOG_ERROR(ss);
return RSMI_STATUS_UNEXPECTED_DATA;
}
@@ -2132,7 +2256,7 @@ rsmi_dev_dpm_policy_get(uint32_t dv_ind,
if (!see_current) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", Unexpeced pstat data: cannot find the current policy.";
<< ", Unexpected pstat data: cannot find the current policy.";
LOG_ERROR(ss);
return RSMI_STATUS_UNEXPECTED_DATA;
}
@@ -536,8 +536,10 @@ static const std::map<const char *, dev_depends_t> kDevFuncDependsMap = {
{"rsmi_topo_numa_affinity_get", {{kDevNumaNodeFName}, {}}},
{"rsmi_dev_gpu_metrics_info_get", {{kDevGpuMetricsFName}, {}}},
{"rsmi_dev_pm_metrics_info_get", {{kDevPmMetricsFName}, {}}},
{"rsmi_dev_dpm_policy_get", {{kDevDPMPolicyFName}, {}}},
{"rsmi_dev_dpm_policy_set", {{kDevDPMPolicyFName}, {}}},
{"rsmi_dev_dpm_policy_get", {{kDevDPMPolicyFName}, {}}},
{"rsmi_dev_dpm_policy_set", {{kDevDPMPolicyFName}, {}}},
{"rsmi_dev_xgmi_plpd_get", {{kDevDPMPolicyFName}, {}}},
{"rsmi_dev_xgmi_plpd_set", {{kDevDPMPolicyFName}, {}}},
{"rsmi_dev_reg_table_info_get", {{kDevRegMetricsFName}, {}}},
{"rsmi_dev_gpu_reset", {{kDevGpuResetFName}, {}}},
{"rsmi_dev_compute_partition_get", {{kDevComputePartitionFName}, {}}},
+27 -2
Wyświetl plik
@@ -1369,6 +1369,22 @@ amdsmi_status_t amdsmi_get_dpm_policy(amdsmi_processor_handle processor_handle,
reinterpret_cast<rsmi_dpm_policy_t*>(policy));
}
amdsmi_status_t amdsmi_set_xgmi_plpd(amdsmi_processor_handle processor_handle,
uint32_t policy) {
AMDSMI_CHECK_INIT();
return rsmi_wrapper(rsmi_dev_xgmi_plpd_set, processor_handle,
policy);
}
amdsmi_status_t amdsmi_get_xgmi_plpd(amdsmi_processor_handle processor_handle,
amdsmi_dpm_policy_t* policy) {
AMDSMI_CHECK_INIT();
return rsmi_wrapper(rsmi_dev_xgmi_plpd_get, processor_handle,
reinterpret_cast<rsmi_dpm_policy_t*>(policy));
}
amdsmi_status_t
amdsmi_get_gpu_memory_reserved_pages(amdsmi_processor_handle processor_handle,
uint32_t *num_pages,
@@ -1635,6 +1651,12 @@ amdsmi_get_clock_info(amdsmi_processor_handle processor_handle, amdsmi_clk_type_
case CLK_TYPE_VCLK1:
info->cur_clk = metrics.current_vclk1;
break;
case CLK_TYPE_DCLK0:
info->cur_clk = metrics.current_dclk0;
break;
case CLK_TYPE_DCLK1:
info->cur_clk = metrics.current_dclk1;
break;
default:
return AMDSMI_STATUS_INVAL;
}
@@ -2028,11 +2050,14 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a
processor_handle, &slot_type);
if (status == AMDSMI_STATUS_SUCCESS) {
switch (slot_type) {
case RSMI_PCIE_SLOT_PCIE:
info->pcie_static.slot_type = AMDSMI_CARD_FORM_FACTOR_PCIE;
break;
case RSMI_PCIE_SLOT_OAM:
info->pcie_static.slot_type = AMDSMI_CARD_FORM_FACTOR_OAM;
break;
case RSMI_PCIE_SLOT_PCIE:
info->pcie_static.slot_type = AMDSMI_CARD_FORM_FACTOR_PCIE;
case RSMI_PCIE_SLOT_CEM:
info->pcie_static.slot_type = AMDSMI_CARD_FORM_FACTOR_CEM;
break;
default:
info->pcie_static.slot_type = AMDSMI_CARD_FORM_FACTOR_UNKNOWN;
@@ -229,6 +229,12 @@ amdsmi_status_t smi_amdgpu_get_ranges(amd::smi::AMDSmiGPUDevice* device, amdsmi_
case CLK_TYPE_VCLK1:
fullpath += "/pp_dpm_vclk1";
break;
case CLK_TYPE_DCLK0:
fullpath += "/pp_dpm_dclk";
break;
case CLK_TYPE_DCLK1:
fullpath += "/pp_dpm_dclk1";
break;
default:
return AMDSMI_STATUS_INVAL;
}