SWDEV-463405: Add amdsmi_get_link_topology_nearest support
amdsmi_get_link_topology_nearest() is used to retrieve
the set of GPUs that are nearest to a given device
at a specific interconnectivity level.
Code changes related to the following:
* API
* CLI
* Unit tests
* Examples
Header Unification Change: "/amdsmi/+/1122408"
Change-Id: Id0317797c652c267742513936d321677793ec634
Signed-off-by: Lang Yu <lang.yu@amd.com>
Этот коммит содержится в:
коммит произвёл
Oliveira, Daniel
родитель
f00a03ed2b
Коммит
7a557b1c50
+58
-55
@@ -13,6 +13,9 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
|
||||
- On amd-smi-lib-tests uninstall, the amd_smi tests folder is removed.
|
||||
- Removed pytest dependency, our python testing now only depends on the unittest framework.
|
||||
|
||||
- **Added retrieving a set of GPUs that are nearest to a given device at a specific link type level**.
|
||||
- Added `amdsmi_get_link_topology_nearest()` function to amd-smi C and Python Libraries.
|
||||
|
||||
- **Added more supported utilization count types to `amdsmi_get_utilization_count()`**.
|
||||
|
||||
- **Added `amd-smi set -L/--clk-limit ...` command**.
|
||||
@@ -27,7 +30,7 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
|
||||
- Added `amdsmi_get_gpu_mem_overdrive_level()` function to amd-smi C and Python Libraries.
|
||||
|
||||
- **Added retrieving connection type and P2P capabilities between two GPUs**.
|
||||
- Added `amdsmi_topo_get_p2p_status` function to amd-smi C and Python Libraries.
|
||||
- Added `amdsmi_topo_get_p2p_status()` function to amd-smi C and Python Libraries.
|
||||
- Added retrieving P2P link capabilities to CLI `amd-smi topology`.
|
||||
|
||||
```shell
|
||||
@@ -129,7 +132,7 @@ Legend:
|
||||
```
|
||||
|
||||
- **Created new amdsmi_kfd_info_t and added information under `amd-smi list`**.
|
||||
- Due to fixes needed to properly enumerate all logical GPUs in CPX, new device identifiers were added in to a new `amdsmi_kfd_info_t` which gets populated via the API `amdsmi_get_gpu_kfd_info`.
|
||||
- Due to fixes needed to properly enumerate all logical GPUs in CPX, new device identifiers were added in to a new `amdsmi_kfd_info_t` which gets populated via the API `amdsmi_get_gpu_kfd_info()`.
|
||||
- This info has been added to the `amd-smi list`.
|
||||
- These new fields are only available for BM/Guest Linux devices at this time.
|
||||
|
||||
@@ -402,9 +405,9 @@ Guest VMs can view enabled/disabled ras features that are on Host cards.
|
||||
|
||||
### Additions
|
||||
|
||||
- **`amd-smi dmon` is now available as an alias to `amd-smi monitor`**.
|
||||
- **`amd-smi dmon` is now available as an alias to `amd-smi monitor`**.
|
||||
|
||||
- **Added optional process table under `amd-smi monitor -q`**.
|
||||
- **Added optional process table under `amd-smi monitor -q`**.
|
||||
The monitor subcommand within the CLI Tool now has the `-q` option to enable an optional process table underneath the original monitored output.
|
||||
|
||||
```shell
|
||||
@@ -417,10 +420,10 @@ GPU NAME PID GTT_MEM CPU_MEM VRAM_MEM MEM_USAGE GF
|
||||
0 rvs 1564865 0.0 B 0.0 B 1.1 GB 0.0 B 0 ns 0 ns
|
||||
```
|
||||
|
||||
- **Added Handling to detect VMs with passthrough configurations in CLI Tool**.
|
||||
- **Added Handling to detect VMs with passthrough configurations in CLI Tool**.
|
||||
CLI Tool had only allowed a restricted set of options for Virtual Machines with passthrough GPUs. Now we offer an expanded set of functions availble to passthrough configured GPUs.
|
||||
|
||||
- **Added Process Isolation and Clear SRAM functionality to the CLI Tool for VMs**.
|
||||
- **Added Process Isolation and Clear SRAM functionality to the CLI Tool for VMs**.
|
||||
VMs now have the ability to set the process isolation and clear the sram from the CLI tool. Using the following commands
|
||||
|
||||
```shell
|
||||
@@ -428,10 +431,10 @@ amd-smi set --process-isolation <0 or 1>
|
||||
amd-smi reset --clean_local_data
|
||||
```
|
||||
|
||||
- **Added macros that were in `amdsmi.h` to the amdsmi Python library `amdsmi_interface.py`**.
|
||||
- **Added macros that were in `amdsmi.h` to the amdsmi Python library `amdsmi_interface.py`**.
|
||||
Added macros to reference max size limitations for certain amdsmi functions such as max dpm policies and max fanspeed.
|
||||
|
||||
- **Added Ring Hang event**.
|
||||
- **Added Ring Hang event**.
|
||||
Added `AMDSMI_EVT_NOTIF_RING_HANG` to the possible events in the `amdsmi_evt_notification_type_t` enum.
|
||||
|
||||
### Optimizations
|
||||
@@ -443,7 +446,7 @@ $ amd-smi static --asic --gpu 123123
|
||||
Can not find a device: GPU '123123' Error code: -3
|
||||
```
|
||||
|
||||
- **Removed elevated permission requirements for `amdsmi_get_gpu_process_list()`**.
|
||||
- **Removed elevated permission requirements for `amdsmi_get_gpu_process_list()`**.
|
||||
Previously if a processes with elevated permissions was running amd-smi would required sudo to display all output. Now amd-smi will populate all process data and return N/A for elevated process names instead. However if ran with sudo you will be able to see the name like so:
|
||||
|
||||
```shell
|
||||
@@ -478,10 +481,10 @@ GPU: 0
|
||||
ENC: 0 ns
|
||||
```
|
||||
|
||||
- **Updated naming for `amdsmi_set_gpu_clear_sram_data()` to `amdsmi_clean_gpu_local_data()`**.
|
||||
- **Updated naming for `amdsmi_set_gpu_clear_sram_data()` to `amdsmi_clean_gpu_local_data()`**.
|
||||
Changed the naming to be more accurate to what the function was doing. This change also extends to the CLI where we changed the `clear-sram-data` command to `clean_local_data`.
|
||||
|
||||
- **Updated `amdsmi_clk_info_t` struct in amdsmi.h and amdsmi_interface.py to align with host/guest**.
|
||||
- **Updated `amdsmi_clk_info_t` struct in amdsmi.h and amdsmi_interface.py to align with host/guest**.
|
||||
Changed cur_clk to clk, changed sleep_clk to clk_deep_sleep, and added clk_locked value. New struct will be in the following format:
|
||||
|
||||
```shell
|
||||
@@ -495,7 +498,7 @@ Changed cur_clk to clk, changed sleep_clk to clk_deep_sleep, and added clk_locke
|
||||
} amdsmi_clk_info_t;
|
||||
```
|
||||
|
||||
- **Multiple structure updates in amdsmi.h and amdsmi_interface.py to align with host/guest**.
|
||||
- **Multiple structure updates in amdsmi.h and amdsmi_interface.py to align with host/guest**.
|
||||
Multiple structures used by APIs were changed for alignment unification:
|
||||
- Changed `amdsmi_vram_info_t` `vram_size_mb` field changed to to `vram_size`
|
||||
- Updated `amdsmi_vram_type_t` struct updated to include new enums and added `AMDSMI` prefix
|
||||
@@ -503,7 +506,7 @@ Multiple structures used by APIs were changed for alignment unification:
|
||||
- Added `AMDSMI_PROCESSOR_TYPE` prefix to `processor_type_t` enums
|
||||
- Removed the fields structure definition in favor for an anonymous definition in `amdsmi_bdf_t`
|
||||
|
||||
- **Added `AMDSMI` prefix in amdsmi.h and amdsmi_interface.py to align with host/guest**.
|
||||
- **Added `AMDSMI` prefix in amdsmi.h and amdsmi_interface.py to align with host/guest**.
|
||||
Multiple structures used by APIs were changed for alignment unification. `AMDSMI` prefix was added to the following structures:
|
||||
- Added AMDSMI prefix to `amdsmi_container_types_t` enums
|
||||
- Added AMDSMI prefix to `amdsmi_clk_type_t` enums
|
||||
@@ -513,13 +516,13 @@ Multiple structures used by APIs were changed for alignment unification. `AMDSMI
|
||||
- Added AMDSMI prefix to `amdsmi_temperature_type_t` enums
|
||||
- Added AMDSMI prefix to `amdsmi_fw_block_t` enums
|
||||
|
||||
- **Changed dpm_policy references to soc_pstate**.
|
||||
- **Changed dpm_policy references to soc_pstate**.
|
||||
The file structure referenced to dpm_policy changed to soc_pstate and we have changed the APIs and CLI tool to be inline with the current structure. `amdsmi_get_dpm_policy()` and `amdsmi_set_dpm_policy()` is no longer valid with the new API being `amdsmi_get_soc_pstate()` and `amdsmi_set_soc_pstate()`. The CLI tool has been changed from `--policy` to `--soc-pstate`
|
||||
|
||||
- **Updated `amdsmi_get_gpu_board_info()` product_name to fallback to pciids**.
|
||||
- **Updated `amdsmi_get_gpu_board_info()` product_name to fallback to pciids**.
|
||||
Previously on devices without a FRU we would not populate the product name in the `amdsmi_board_info_t` structure, now we will fallback to using the name listed according to the pciids file if available.
|
||||
|
||||
- **Updated CLI voltage curve command output**.
|
||||
- **Updated CLI voltage curve command output**.
|
||||
The output for `amd-smi metric --voltage-curve` now splits the frequency and voltage output by curve point or outputs N/A for each curve point if not applicable
|
||||
|
||||
```shell
|
||||
@@ -533,16 +536,16 @@ GPU: 0
|
||||
POINT_2_VOLTAGE: 1186 mV
|
||||
```
|
||||
|
||||
- **Updated `amdsmi_get_gpu_board_info()` now has larger structure sizes for `amdsmi_board_info_t`**.
|
||||
- **Updated `amdsmi_get_gpu_board_info()` now has larger structure sizes for `amdsmi_board_info_t`**.
|
||||
Updated sizes that work for retreiving relavant board information across AMD's
|
||||
ASIC products. This requires users to update any ABIs using this structure.
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Fixed Leftover Mutex deadlock when running multiple instances of the CLI tool**.
|
||||
- **Fixed Leftover Mutex deadlock when running multiple instances of the CLI tool**.
|
||||
When running `amd-smi reset --gpureset --gpu all` and then running an instance of `amd-smi static` (or any other subcommand that access the GPUs) a mutex would lock and not return requiring either a clear of the mutex in /dev/shm or rebooting the machine.
|
||||
|
||||
- **Fixed multiple processes not being registered in `amd-smi process` with json and csv format**.
|
||||
- **Fixed multiple processes not being registered in `amd-smi process` with json and csv format**.
|
||||
Multiple process outputs in the CLI tool were not being registered correctly. The json output did not handle multiple processes and is now in a new valid json format:
|
||||
|
||||
```shell
|
||||
@@ -575,33 +578,33 @@ Multiple process outputs in the CLI tool were not being registered correctly. Th
|
||||
]
|
||||
```
|
||||
|
||||
- **Removed `throttle-status` from `amd-smi monitor` as it is no longer reliably supported**.
|
||||
- **Removed `throttle-status` from `amd-smi monitor` as it is no longer reliably supported**.
|
||||
Throttle status may work for older ASICs, but will be replaced with PVIOL and TVIOL metrics for future ASIC support. It remains a field in the gpu_metrics API and in `amd-smi metric --power`.
|
||||
|
||||
- **`amdsmi_get_gpu_board_info()` no longer returns junk char strings**.
|
||||
- **`amdsmi_get_gpu_board_info()` no longer returns junk char strings**.
|
||||
Previously if there was a partial failure to retrieve character strings, we would return
|
||||
garbage output to users using the API. This fix intends to populate as many values as possible.
|
||||
Then any failure(s) found along the way, `\0` is provided to `amdsmi_board_info_t`
|
||||
structures data members which cannot be populated. Ensuring empty char string values.
|
||||
|
||||
- **Fixed parsing of `pp_od_clk_voltage` within `amdsmi_get_gpu_od_volt_info`**.
|
||||
- **Fixed parsing of `pp_od_clk_voltage` within `amdsmi_get_gpu_od_volt_info`**.
|
||||
The parsing of `pp_od_clk_voltage` was not dynamic enough to work with the dropping of voltage curve support on MI series cards. This propagates down to correcting the CLI's output `amd-smi metric --voltage-curve` to N/A if voltage curve is not enabled.
|
||||
|
||||
### Known Issues
|
||||
|
||||
- **`amdsmi_get_gpu_process_isolation` and `amdsmi_clean_gpu_local_data` commands do no currently work and will be supported in a future release**.
|
||||
- **`amdsmi_get_gpu_process_isolation` and `amdsmi_clean_gpu_local_data` commands do no currently work and will be supported in a future release**.
|
||||
|
||||
## amd_smi_lib for ROCm 6.1.2
|
||||
|
||||
### Additions
|
||||
|
||||
- **Added process isolation and clean shader APIs and CLI commands**.
|
||||
- **Added process isolation and clean shader APIs and CLI commands**.
|
||||
Added APIs CLI and APIs to address LeftoverLocals security issues. Allowing clearing the sram data and setting process isolation on a per GPU basis. New APIs:
|
||||
- `amdsmi_get_gpu_process_isolation()`
|
||||
- `amdsmi_set_gpu_process_isolation()`
|
||||
- `amdsmi_set_gpu_clear_sram_data()`
|
||||
|
||||
- **Added `MIN_POWER` to output of `amd-smi static --limit`**.
|
||||
- **Added `MIN_POWER` to output of `amd-smi static --limit`**.
|
||||
This change helps users identify the range to which they can change the power cap of the GPU. The change is added to simplify why a device supports (or does not support) power capping (also known as overdrive). See `amd-smi set -g all --power-cap <value in W>` or `amd-smi reset -g all --power-cap`.
|
||||
|
||||
```shell
|
||||
@@ -633,7 +636,7 @@ GPU: 1
|
||||
|
||||
### Optimizations
|
||||
|
||||
- **Updated `amd-smi monitor --pcie` output**.
|
||||
- **Updated `amd-smi monitor --pcie` output**.
|
||||
The source for pcie bandwidth monitor output was a legacy file we no longer support and was causing delays within the monitor command. The output is no longer using TX/RX but instantaneous bandwidth from gpu_metrics instead; updated output:
|
||||
|
||||
```shell
|
||||
@@ -642,13 +645,13 @@ GPU PCIE_BW
|
||||
0 26 Mb/s
|
||||
```
|
||||
|
||||
- **`amdsmi_get_power_cap_info` now returns values in uW instead of W**.
|
||||
- **`amdsmi_get_power_cap_info` now returns values in uW instead of W**.
|
||||
`amdsmi_get_power_cap_info` will return in uW as originally reflected by driver. Previously `amdsmi_get_power_cap_info` returned W values, this conflicts with our sets and modifies values retrieved from driver. We decided to keep the values returned from driver untouched (in original units, uW). Then in CLI we will convert to watts (as previously done - no changes here). Additionally, driver made updates to min power cap displayed for devices when overdrive is disabled which prompted for this change (in this case min_power_cap and max_power_cap are the same).
|
||||
|
||||
- **Updated Python Library return types for amdsmi_get_gpu_memory_reserved_pages & amdsmi_get_gpu_bad_page_info**.
|
||||
- **Updated Python Library return types for amdsmi_get_gpu_memory_reserved_pages & amdsmi_get_gpu_bad_page_info**.
|
||||
Previously calls were returning "No bad pages found." if no pages were found, now it only returns the list type and can be empty.
|
||||
|
||||
- **Updated `amd-smi metric --ecc-blocks` output**.
|
||||
- **Updated `amd-smi metric --ecc-blocks` output**.
|
||||
The ecc blocks argument was outputing blocks without counters available, updated the filtering show blocks that counters are available for:
|
||||
|
||||
``` shell
|
||||
@@ -685,12 +688,12 @@ GPU: 0
|
||||
DEFERRED_COUNT: 0
|
||||
```
|
||||
|
||||
- **Removed `amdsmi_get_gpu_process_info` from Python library**.
|
||||
- **Removed `amdsmi_get_gpu_process_info` from Python library**.
|
||||
amdsmi_get_gpu_process_info was removed from the C library in an earlier build, but the API was still in the Python interface.
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Fixed `amd-smi metric --power` now provides power output for Navi2x/Navi3x/MI1x**.
|
||||
- **Fixed `amd-smi metric --power` now provides power output for Navi2x/Navi3x/MI1x**.
|
||||
These systems use an older version of gpu_metrics in amdgpu. This fix only updates what CLI outputs.
|
||||
No change in any of our APIs.
|
||||
|
||||
@@ -715,10 +718,10 @@ GPU: 1
|
||||
THROTTLE_STATUS: UNTHROTTLED
|
||||
```
|
||||
|
||||
- **Fixed `amdsmitstReadWrite.TestPowerCapReadWrite` test for Navi3X, Navi2X, MI100**.
|
||||
- **Fixed `amdsmitstReadWrite.TestPowerCapReadWrite` test for Navi3X, Navi2X, MI100**.
|
||||
Updates required `amdsmi_get_power_cap_info` to return in uW as originally reflected by driver. Previously `amdsmi_get_power_cap_info` returned W values, this conflicts with our sets and modifies values retrieved from driver. We decided to keep the values returned from driver untouched (in original units, uW). Then in CLI we will convert to watts (as previously done - no changes here). Additionally, driver made updates to min power cap displayed for devices when overdrive is disabled which prompted for this change (in this case min_power_cap and max_power_cap are the same).
|
||||
|
||||
- **Fixed Python interface call amdsmi_get_gpu_memory_reserved_pages & amdsmi_get_gpu_bad_page_info**.
|
||||
- **Fixed Python interface call amdsmi_get_gpu_memory_reserved_pages & amdsmi_get_gpu_bad_page_info**.
|
||||
Previously Python interface calls to populated bad pages resulted in a `ValueError: NULL pointer access`. This fixes the bad-pages subcommand CLI subcommand as well.
|
||||
|
||||
### Known Issues
|
||||
@@ -729,7 +732,7 @@ Previously Python interface calls to populated bad pages resulted in a `ValueErr
|
||||
|
||||
### Changes
|
||||
|
||||
- **Updated metrics --clocks**.
|
||||
- **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
|
||||
@@ -840,7 +843,7 @@ GPU: 0
|
||||
DEEP_SLEEP: ENABLED
|
||||
```
|
||||
|
||||
- **Added deferred ecc counts**.
|
||||
- **Added deferred ecc counts**.
|
||||
Added deferred error correctable counts to `amd-smi metric --ecc --ecc-blocks`
|
||||
|
||||
```shell
|
||||
@@ -864,7 +867,7 @@ GPU: 0
|
||||
...
|
||||
```
|
||||
|
||||
- **Updated `amd-smi topology --json` to align with host/guest**.
|
||||
- **Updated `amd-smi topology --json` to align with host/guest**.
|
||||
Topology's `--json` output now is changed to align with output host/guest systems. Additionally, users can select/filter specific topology details as desired (refer to `amd-smi topology -h` for full list). See examples shown below.
|
||||
|
||||
*Previous format:*
|
||||
@@ -999,7 +1002,7 @@ $ /opt/rocm/bin/amd-smi topology -a -t --json
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Fix for GPU reset error on non-amdgpu cards**.
|
||||
- **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.
|
||||
|
||||
@@ -1007,10 +1010,10 @@ updates CLI to target only AMD ASICs.
|
||||
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).
|
||||
|
||||
- **Fix for `amd-smi process`**.
|
||||
- **Fix for `amd-smi process`**.
|
||||
Fixed output results when getting processes running on a device.
|
||||
|
||||
- **Improved Error handling for `amd-smi process`**.
|
||||
- **Improved Error handling for `amd-smi process`**.
|
||||
Fixed Attribute Error when getting process in csv format
|
||||
|
||||
### Known issues
|
||||
@@ -1021,7 +1024,7 @@ Fixed Attribute Error when getting process in csv format
|
||||
|
||||
### Additions
|
||||
|
||||
- **Added Monitor Command**.
|
||||
- **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
|
||||
@@ -1081,7 +1084,7 @@ GPU POWER GPU_TEMP MEM_TEMP GFX_UTIL GFX_CLOCK MEM_UTIL MEM_CLOCK VRAM_U
|
||||
7 175 W 34 °C 32 °C 0 % 113 MHz 0 % 900 MHz 283 MB 196300 MB
|
||||
```
|
||||
|
||||
- **Integrated ESMI Tool**.
|
||||
- **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
|
||||
@@ -1231,7 +1234,7 @@ CPU: 0
|
||||
RESPONSE: N/A
|
||||
```
|
||||
|
||||
- **Added support for new metrics: VCN, JPEG engines, and PCIe errors**.
|
||||
- **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.
|
||||
|
||||
```shell
|
||||
@@ -1264,7 +1267,7 @@ GPU: 0
|
||||
|
||||
```
|
||||
|
||||
- **Added AMDSMI Tool Version**.
|
||||
- **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.
|
||||
@@ -1275,7 +1278,7 @@ $ amd-smi version
|
||||
AMDSMI Tool: 23.4.2+505b858 | AMDSMI Library version: 24.2.0.0 | ROCm version: 6.1.0
|
||||
```
|
||||
|
||||
- **Added XGMI table**.
|
||||
- **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
|
||||
@@ -1309,7 +1312,7 @@ GPU7 0000:df:00.0 32 Gb/s 512 Gb/s XGMI
|
||||
|
||||
```
|
||||
|
||||
- **Added units of measure to JSON output**.
|
||||
- **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.
|
||||
@@ -1345,7 +1348,7 @@ amd-smi metric -p --json
|
||||
|
||||
### Changes
|
||||
|
||||
- **Topology is now left-aligned with BDF of each device listed individual table's row/coloumns**.
|
||||
- **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.
|
||||
|
||||
```shell
|
||||
@@ -1408,9 +1411,9 @@ NUMA BW TABLE:
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Fix for Navi3X/Navi2X/MI100 `amdsmi_get_gpu_pci_bandwidth()` in frequencies_read tests**.
|
||||
- **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**.
|
||||
- **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:
|
||||
- `amd-smi list`
|
||||
- `amd-smi static`
|
||||
@@ -1422,20 +1425,20 @@ Platforms which are identified as having an older pyyaml version or pip, we no m
|
||||
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.
|
||||
|
||||
## amd_smi_lib for ROCm 6.0.0
|
||||
|
||||
### Additions
|
||||
|
||||
- **Integrated the E-SMI (EPYC-SMI) library**.
|
||||
- **Integrated the E-SMI (EPYC-SMI) library**.
|
||||
You can now query CPU-related information directly through AMD SMI. Metrics include power, energy, performance, and other system details.
|
||||
|
||||
- **Added support for gfx942 metrics**.
|
||||
- **Added support for gfx942 metrics**.
|
||||
You can now query MI300 device metrics to get real-time information. Metrics include power, temperature, energy, and performance.
|
||||
|
||||
- **Compute and memory partition support**.
|
||||
- **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.
|
||||
|
||||
### Optimizations
|
||||
@@ -1444,13 +1447,13 @@ Users can now view, set, and reset partitions. The topology display can provide
|
||||
|
||||
### Changes
|
||||
|
||||
- **GPU index sorting made consistent with other tools**.
|
||||
- **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.
|
||||
|
||||
### Fixes
|
||||
|
||||
- **Fix for driver not initialized**.
|
||||
- **Fix for driver not initialized**.
|
||||
If driver module is not loaded, user retrieve error reponse indicating amdgpu module is not loaded.
|
||||
|
||||
@@ -3867,6 +3867,55 @@ except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_link_topology_nearest
|
||||
|
||||
Description: Retrieve the set of GPUs that are nearest to a given device
|
||||
at a specific interconnectivity level.
|
||||
|
||||
Input parameters:
|
||||
* `processor_handle` The identifier of the given device.
|
||||
* `link_type` The AmdSmiLinkType level to search for nearest devices
|
||||
|
||||
Output: Dictionary holding the following fields.
|
||||
* `count` number of nearest devices found based on given topology level
|
||||
* `processor_list` list of all nearest device handlers found
|
||||
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_link_topology_nearest` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
amdsmi_init()
|
||||
|
||||
devices = amdsmi_get_processor_handles()
|
||||
if len(devices) == 0:
|
||||
print("No GPUs found on machine")
|
||||
exit()
|
||||
else:
|
||||
print(amdsmi_get_gpu_device_uuid(devices[0]))
|
||||
|
||||
nearest_gpus = amdsmi_topology_nearest_t()
|
||||
nearest_gpus = amdsmi_get_link_topology_nearest(devices[0], AmdSmiLinkType(2))
|
||||
if (nearest_gpus['count']) == 0:
|
||||
print("No nearest GPUs found on machine")
|
||||
else:
|
||||
print("Nearest GPUs")
|
||||
for gpu in nearest_gpus['processor_list']:
|
||||
print(amdsmi_get_gpu_device_uuid(gpu))
|
||||
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
finally:
|
||||
try:
|
||||
amdsmi_shut_down()
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
## CPU APIs
|
||||
|
||||
### amdsmi_get_processor_info
|
||||
|
||||
@@ -852,6 +852,36 @@ int main() {
|
||||
std::cout << "\n";
|
||||
std::cout << "+=======+==================+============+=============="
|
||||
<< "+=============+=============+=============+============+\n";
|
||||
|
||||
// Get nearest GPUs
|
||||
char *topology_link_type_str[] = {
|
||||
"AMDSMI_LINK_TYPE_INTERNAL",
|
||||
"AMDSMI_LINK_TYPE_XGMI",
|
||||
"AMDSMI_LINK_TYPE_PCIE",
|
||||
"AMDSMI_LINK_TYPE_NOT_APPLICABLE",
|
||||
"AMDSMI_LINK_TYPE_UNKNOWN",
|
||||
};
|
||||
printf("\tOutput of amdsmi_get_link_topology_nearest:\n");
|
||||
for (uint32_t topo_link_type = AMDSMI_LINK_TYPE_INTERNAL; topo_link_type <= AMDSMI_LINK_TYPE_UNKNOWN; topo_link_type++) {
|
||||
auto topology_nearest_info = amdsmi_topology_nearest_t();
|
||||
ret = amdsmi_get_link_topology_nearest(processor_handles[j],
|
||||
static_cast<amdsmi_link_type_t>(topo_link_type),
|
||||
nullptr);
|
||||
CHK_AMDSMI_RET(ret);
|
||||
|
||||
ret = amdsmi_get_link_topology_nearest(processor_handles[j],
|
||||
static_cast<amdsmi_link_type_t>(topo_link_type),
|
||||
&topology_nearest_info);
|
||||
CHK_AMDSMI_RET(ret);
|
||||
printf("\tNearest GPUs found at %s\n", topology_link_type_str[topo_link_type]);
|
||||
for (uint32_t k = 0; k < topology_nearest_info.count; k++) {
|
||||
amdsmi_bdf_t bdf = {};
|
||||
ret = amdsmi_get_gpu_device_bdf(topology_nearest_info.processor_list[k], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf("\t\tGPU BDF %04lx:%02x:%02x.%d\n", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -344,6 +344,35 @@ int main() {
|
||||
<<"," << policy.policies[x].policy_description << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Get nearest GPUs
|
||||
char *topology_link_type_str[] = {
|
||||
"AMDSMI_LINK_TYPE_INTERNAL",
|
||||
"AMDSMI_LINK_TYPE_XGMI",
|
||||
"AMDSMI_LINK_TYPE_PCIE",
|
||||
"AMDSMI_LINK_TYPE_NOT_APPLICABLE",
|
||||
"AMDSMI_LINK_TYPE_UNKNOWN",
|
||||
};
|
||||
printf("\tOutput of amdsmi_get_link_topology_nearest:\n");
|
||||
for (uint32_t topo_link_type = AMDSMI_LINK_TYPE_INTERNAL; topo_link_type <= AMDSMI_LINK_TYPE_UNKNOWN; topo_link_type++) {
|
||||
auto topology_nearest_info = amdsmi_topology_nearest_t();
|
||||
ret = amdsmi_get_link_topology_nearest(processor_handles[j],
|
||||
static_cast<amdsmi_link_type_t>(topo_link_type),
|
||||
nullptr);
|
||||
CHK_AMDSMI_RET(ret);
|
||||
ret = amdsmi_get_link_topology_nearest(processor_handles[j],
|
||||
static_cast<amdsmi_link_type_t>(topo_link_type),
|
||||
&topology_nearest_info);
|
||||
CHK_AMDSMI_RET(ret);
|
||||
printf("\tNearest GPUs found at %s\n", topology_link_type_str[topo_link_type]);
|
||||
for (uint32_t k = 0; k < topology_nearest_info.count; k++) {
|
||||
amdsmi_bdf_t bdf = {};
|
||||
ret = amdsmi_get_gpu_device_bdf(topology_nearest_info.processor_list[k], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf("\tGPU BDF %04lx:%02x:%02x.%d\n", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -651,8 +651,9 @@ typedef struct {
|
||||
} amdsmi_accelerator_partition_profile_t;
|
||||
|
||||
typedef enum {
|
||||
AMDSMI_LINK_TYPE_PCIE,
|
||||
AMDSMI_LINK_TYPE_INTERNAL,
|
||||
AMDSMI_LINK_TYPE_XGMI,
|
||||
AMDSMI_LINK_TYPE_PCIE,
|
||||
AMDSMI_LINK_TYPE_NOT_APPLICABLE,
|
||||
AMDSMI_LINK_TYPE_UNKNOWN
|
||||
} amdsmi_link_type_t;
|
||||
@@ -1585,6 +1586,14 @@ typedef struct {
|
||||
uint32_t cu_occupancy; //!< Compute Unit usage in percent
|
||||
} amdsmi_process_info_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t count;
|
||||
amdsmi_processor_handle processor_list[AMDSMI_MAX_DEVICES];
|
||||
uint64_t reserved[15];
|
||||
} amdsmi_topology_nearest_t;
|
||||
|
||||
|
||||
//! Place-holder "variant" for functions that have don't have any variants,
|
||||
//! but do have monitors or sensors.
|
||||
#define AMDSMI_DEFAULT_VARIANT 0xFFFFFFFFFFFFFFFF
|
||||
@@ -5097,6 +5106,35 @@ amdsmi_get_gpu_total_ecc_count(amdsmi_processor_handle processor_handle, amdsmi_
|
||||
|
||||
/** @} End eccinfo */
|
||||
|
||||
/**
|
||||
* @brief Retrieve the set of GPUs that are nearest to a given device
|
||||
* at a specific interconnectivity level.
|
||||
*
|
||||
* @platform{gpu_bm_linux} @platform{host}
|
||||
*
|
||||
* @details Once called topology_nearest_info will get populated with a list of
|
||||
* all nearest devices for a given link_type. The list has a count of
|
||||
* the number of devices found and their respective handles/identifiers.
|
||||
*
|
||||
* @param[in] processor_handle The identifier of the given device.
|
||||
*
|
||||
* @param[in] link_type The amdsmi_link_type_t level to search for nearest GPUs.
|
||||
*
|
||||
* @param[in,out] topology_nearest_info
|
||||
* .count;
|
||||
* - When zero, is set to the number of matching GPUs such that .device_list can
|
||||
* be malloc'd.
|
||||
* - When non-zero, .device_list will be filled with count number of processor_handle.
|
||||
*
|
||||
* @param[out] .device_list An array of processor_handle for GPUs found at level.
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail.
|
||||
*/
|
||||
amdsmi_status_t
|
||||
amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_link_type_t link_type,
|
||||
amdsmi_topology_nearest_t* topology_nearest_info);
|
||||
|
||||
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -3906,6 +3906,54 @@ except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_link_topology_nearest
|
||||
|
||||
Description: Retrieve the set of GPUs that are nearest to a given device
|
||||
at a specific interconnectivity level.
|
||||
|
||||
Input parameters:
|
||||
* `processor_handle` The identifier of the given device.
|
||||
* `link_type` The AmdSmiLinkType level to search for nearest devices
|
||||
|
||||
Output: Dictionary holding the following fields.
|
||||
* `count` number of nearest devices found based on given topology level
|
||||
* `processor_list` list of all nearest device handlers found
|
||||
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_link_topology_nearest` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
amdsmi_init()
|
||||
|
||||
devices = amdsmi_get_processor_handles()
|
||||
if len(devices) == 0:
|
||||
print("No GPUs found on machine")
|
||||
exit()
|
||||
else:
|
||||
print(amdsmi_get_gpu_device_uuid(devices[0]))
|
||||
|
||||
nearest_gpus = amdsmi_get_link_topology_nearest(devices[0], AmdSmiLinkType.AMDSMI_LINK_TYPE_PCIE)
|
||||
if (nearest_gpus['count']) == 0:
|
||||
print("No nearest GPUs found on machine")
|
||||
else:
|
||||
print("Nearest GPUs")
|
||||
for gpu in nearest_gpus['processor_list']:
|
||||
print(amdsmi_get_gpu_device_uuid(gpu))
|
||||
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
finally:
|
||||
try:
|
||||
amdsmi_shut_down()
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
## CPU APIs
|
||||
|
||||
### amdsmi_get_processor_info
|
||||
|
||||
@@ -216,6 +216,7 @@ from .amdsmi_interface import amdsmi_topo_get_link_type
|
||||
from .amdsmi_interface import amdsmi_topo_get_p2p_status
|
||||
from .amdsmi_interface import amdsmi_is_P2P_accessible
|
||||
from .amdsmi_interface import amdsmi_get_xgmi_info
|
||||
from .amdsmi_interface import amdsmi_get_link_topology_nearest
|
||||
|
||||
# # Partition Functions
|
||||
from .amdsmi_interface import amdsmi_get_gpu_compute_partition
|
||||
@@ -255,6 +256,7 @@ from .amdsmi_interface import AmdSmiFreqInd
|
||||
from .amdsmi_interface import AmdSmiXgmiStatus
|
||||
from .amdsmi_interface import AmdSmiMemoryPageStatus
|
||||
from .amdsmi_interface import AmdSmiIoLinkType
|
||||
from .amdsmi_interface import AmdSmiLinkType
|
||||
from .amdsmi_interface import AmdSmiUtilizationCounterType
|
||||
from .amdsmi_interface import AmdSmiProcessorType
|
||||
|
||||
|
||||
@@ -383,6 +383,14 @@ class AmdSmiIoLinkType(IntEnum):
|
||||
SIZE = amdsmi_wrapper.AMDSMI_IOLINK_TYPE_SIZE
|
||||
|
||||
|
||||
class AmdSmiLinkType(IntEnum):
|
||||
AMDSMI_LINK_TYPE_INTERNAL = amdsmi_wrapper.AMDSMI_LINK_TYPE_INTERNAL
|
||||
AMDSMI_LINK_TYPE_XGMI = amdsmi_wrapper.AMDSMI_LINK_TYPE_XGMI
|
||||
AMDSMI_LINK_TYPE_PCIE = amdsmi_wrapper.AMDSMI_LINK_TYPE_PCIE
|
||||
AMDSMI_LINK_TYPE_NOT_APPLICABLE = amdsmi_wrapper.AMDSMI_LINK_TYPE_NOT_APPLICABLE
|
||||
AMDSMI_LINK_TYPE_UNKNOWN = amdsmi_wrapper.AMDSMI_LINK_TYPE_UNKNOWN
|
||||
|
||||
|
||||
class AmdSmiUtilizationCounterType(IntEnum):
|
||||
COARSE_GRAIN_GFX_ACTIVITY = amdsmi_wrapper.AMDSMI_COARSE_GRAIN_GFX_ACTIVITY
|
||||
COARSE_GRAIN_MEM_ACTIVITY = amdsmi_wrapper.AMDSMI_COARSE_GRAIN_MEM_ACTIVITY
|
||||
@@ -4174,3 +4182,26 @@ def amdsmi_get_gpu_metrics_header_info(
|
||||
"format_revision": header_info.format_revision,
|
||||
"content_revision": header_info.content_revision
|
||||
}
|
||||
|
||||
def amdsmi_get_link_topology_nearest(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
|
||||
link_type: AmdSmiLinkType,
|
||||
)-> Dict[str, Any]:
|
||||
|
||||
topology_nearest_list = amdsmi_wrapper.amdsmi_topology_nearest_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_link_topology_nearest(
|
||||
processor_handle,
|
||||
link_type,
|
||||
ctypes.byref(topology_nearest_list)
|
||||
)
|
||||
)
|
||||
|
||||
device_list = []
|
||||
for index in range(topology_nearest_list.count):
|
||||
device_list.append(topology_nearest_list.processor_list[index])
|
||||
|
||||
return {
|
||||
'count': topology_nearest_list.count,
|
||||
'processor_list': device_list
|
||||
}
|
||||
|
||||
@@ -978,15 +978,17 @@ amdsmi_accelerator_partition_profile_t = struct_amdsmi_accelerator_partition_pro
|
||||
|
||||
# values for enumeration 'amdsmi_link_type_t'
|
||||
amdsmi_link_type_t__enumvalues = {
|
||||
0: 'AMDSMI_LINK_TYPE_PCIE',
|
||||
0: 'AMDSMI_LINK_TYPE_INTERNAL',
|
||||
1: 'AMDSMI_LINK_TYPE_XGMI',
|
||||
2: 'AMDSMI_LINK_TYPE_NOT_APPLICABLE',
|
||||
3: 'AMDSMI_LINK_TYPE_UNKNOWN',
|
||||
2: 'AMDSMI_LINK_TYPE_PCIE',
|
||||
3: 'AMDSMI_LINK_TYPE_NOT_APPLICABLE',
|
||||
4: 'AMDSMI_LINK_TYPE_UNKNOWN',
|
||||
}
|
||||
AMDSMI_LINK_TYPE_PCIE = 0
|
||||
AMDSMI_LINK_TYPE_INTERNAL = 0
|
||||
AMDSMI_LINK_TYPE_XGMI = 1
|
||||
AMDSMI_LINK_TYPE_NOT_APPLICABLE = 2
|
||||
AMDSMI_LINK_TYPE_UNKNOWN = 3
|
||||
AMDSMI_LINK_TYPE_PCIE = 2
|
||||
AMDSMI_LINK_TYPE_NOT_APPLICABLE = 3
|
||||
AMDSMI_LINK_TYPE_UNKNOWN = 4
|
||||
amdsmi_link_type_t = ctypes.c_uint32 # enum
|
||||
class struct_amdsmi_link_metrics_t(Structure):
|
||||
pass
|
||||
@@ -1842,6 +1844,19 @@ struct_amdsmi_process_info_t._fields_ = [
|
||||
]
|
||||
|
||||
amdsmi_process_info_t = struct_amdsmi_process_info_t
|
||||
class struct_amdsmi_topology_nearest_t(Structure):
|
||||
pass
|
||||
|
||||
struct_amdsmi_topology_nearest_t._pack_ = 1 # source:False
|
||||
struct_amdsmi_topology_nearest_t._fields_ = [
|
||||
('count', ctypes.c_uint32),
|
||||
('PADDING_0', ctypes.c_ubyte * 4),
|
||||
('processor_list', ctypes.POINTER(None) * 32),
|
||||
('reserved', ctypes.c_uint32 * 15),
|
||||
('PADDING_1', ctypes.c_ubyte * 4),
|
||||
]
|
||||
|
||||
amdsmi_topology_nearest_t = struct_amdsmi_topology_nearest_t
|
||||
class struct_amdsmi_smu_fw_version_t(Structure):
|
||||
pass
|
||||
|
||||
@@ -2376,6 +2391,9 @@ amdsmi_get_gpu_process_list.argtypes = [amdsmi_processor_handle, ctypes.POINTER(
|
||||
amdsmi_get_gpu_total_ecc_count = _libraries['libamd_smi.so'].amdsmi_get_gpu_total_ecc_count
|
||||
amdsmi_get_gpu_total_ecc_count.restype = amdsmi_status_t
|
||||
amdsmi_get_gpu_total_ecc_count.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_error_count_t)]
|
||||
amdsmi_get_link_topology_nearest = _libraries['libamd_smi.so'].amdsmi_get_link_topology_nearest
|
||||
amdsmi_get_link_topology_nearest.restype = amdsmi_status_t
|
||||
amdsmi_get_link_topology_nearest.argtypes = [amdsmi_processor_handle, amdsmi_link_type_t, ctypes.POINTER(struct_amdsmi_topology_nearest_t)]
|
||||
amdsmi_get_cpu_core_energy = _libraries['libamd_smi.so'].amdsmi_get_cpu_core_energy
|
||||
amdsmi_get_cpu_core_energy.restype = amdsmi_status_t
|
||||
amdsmi_get_cpu_core_energy.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64)]
|
||||
@@ -2616,11 +2634,11 @@ __all__ = \
|
||||
'AMDSMI_IOLINK_TYPE_NUMIOLINKTYPES',
|
||||
'AMDSMI_IOLINK_TYPE_PCIEXPRESS', 'AMDSMI_IOLINK_TYPE_SIZE',
|
||||
'AMDSMI_IOLINK_TYPE_UNDEFINED', 'AMDSMI_IOLINK_TYPE_XGMI',
|
||||
'AMDSMI_LINK_TYPE_NOT_APPLICABLE', 'AMDSMI_LINK_TYPE_PCIE',
|
||||
'AMDSMI_LINK_TYPE_UNKNOWN', 'AMDSMI_LINK_TYPE_XGMI',
|
||||
'AMDSMI_MEMORY_PARTITION_NPS1', 'AMDSMI_MEMORY_PARTITION_NPS2',
|
||||
'AMDSMI_MEMORY_PARTITION_NPS4', 'AMDSMI_MEMORY_PARTITION_NPS8',
|
||||
'AMDSMI_MEMORY_PARTITION_UNKNOWN',
|
||||
'AMDSMI_LINK_TYPE_INTERNAL', 'AMDSMI_LINK_TYPE_NOT_APPLICABLE',
|
||||
'AMDSMI_LINK_TYPE_PCIE', 'AMDSMI_LINK_TYPE_UNKNOWN',
|
||||
'AMDSMI_LINK_TYPE_XGMI', 'AMDSMI_MEMORY_PARTITION_NPS1',
|
||||
'AMDSMI_MEMORY_PARTITION_NPS2', 'AMDSMI_MEMORY_PARTITION_NPS4',
|
||||
'AMDSMI_MEMORY_PARTITION_NPS8', 'AMDSMI_MEMORY_PARTITION_UNKNOWN',
|
||||
'AMDSMI_MEM_PAGE_STATUS_PENDING',
|
||||
'AMDSMI_MEM_PAGE_STATUS_RESERVED',
|
||||
'AMDSMI_MEM_PAGE_STATUS_UNRESERVABLE', 'AMDSMI_MEM_TYPE_FIRST',
|
||||
@@ -2798,7 +2816,7 @@ __all__ = \
|
||||
'amdsmi_get_gpu_vram_info', 'amdsmi_get_gpu_vram_usage',
|
||||
'amdsmi_get_gpu_vram_vendor', 'amdsmi_get_hsmp_metrics_table',
|
||||
'amdsmi_get_hsmp_metrics_table_version', 'amdsmi_get_lib_version',
|
||||
'amdsmi_get_link_metrics',
|
||||
'amdsmi_get_link_metrics', 'amdsmi_get_link_topology_nearest',
|
||||
'amdsmi_get_minmax_bandwidth_between_processors',
|
||||
'amdsmi_get_pcie_info', 'amdsmi_get_power_cap_info',
|
||||
'amdsmi_get_power_info',
|
||||
@@ -2862,7 +2880,8 @@ __all__ = \
|
||||
'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',
|
||||
'amdsmi_topo_get_p2p_status', 'amdsmi_utilization_counter_t',
|
||||
'amdsmi_topo_get_p2p_status', 'amdsmi_topology_nearest_t',
|
||||
'amdsmi_utilization_counter_t',
|
||||
'amdsmi_utilization_counter_type_t', 'amdsmi_vbios_info_t',
|
||||
'amdsmi_version_t', 'amdsmi_voltage_metric_t',
|
||||
'amdsmi_voltage_type_t', 'amdsmi_vram_info_t',
|
||||
@@ -2896,6 +2915,7 @@ __all__ = \
|
||||
'struct_amdsmi_retired_page_record_t',
|
||||
'struct_amdsmi_smu_fw_version_t',
|
||||
'struct_amdsmi_temp_range_refresh_rate_t',
|
||||
'struct_amdsmi_topology_nearest_t',
|
||||
'struct_amdsmi_utilization_counter_t',
|
||||
'struct_amdsmi_vbios_info_t', 'struct_amdsmi_version_t',
|
||||
'struct_amdsmi_vram_info_t', 'struct_amdsmi_vram_usage_t',
|
||||
|
||||
@@ -51,11 +51,13 @@
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <functional>
|
||||
#include <xf86drm.h>
|
||||
#include "amd_smi/amdsmi.h"
|
||||
#include "amd_smi/impl/fdinfo.h"
|
||||
@@ -2321,6 +2323,166 @@ amdsmi_status_t amdsmi_get_processor_handle_from_bdf(amdsmi_bdf_t bdf,
|
||||
return AMDSMI_STATUS_API_FAILED;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_link_type_t link_type,
|
||||
amdsmi_topology_nearest_t* topology_nearest_info)
|
||||
{
|
||||
if (topology_nearest_info == nullptr) {
|
||||
return amdsmi_status_t::AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
if (link_type < amdsmi_link_type_t::AMDSMI_LINK_TYPE_INTERNAL ||
|
||||
link_type > amdsmi_link_type_t::AMDSMI_LINK_TYPE_UNKNOWN) {
|
||||
return amdsmi_status_t::AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
|
||||
|
||||
auto status(amdsmi_status_t::AMDSMI_STATUS_SUCCESS);
|
||||
constexpr auto kKFD_CRAT_INTRA_SOCKET_WEIGHT = uint32_t(13);
|
||||
constexpr auto kKFD_CRAT_XGMI_WEIGHT = uint32_t(15);
|
||||
|
||||
/*
|
||||
* Note: This will need to be eventually consolidated within a unique link type.
|
||||
*/
|
||||
static const std::map<amdsmi_link_type_t, amdsmi_io_link_type_t> kLinkToIoLinkTypeTranslationTable =
|
||||
{
|
||||
{amdsmi_link_type_t::AMDSMI_LINK_TYPE_INTERNAL, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED},
|
||||
{amdsmi_link_type_t::AMDSMI_LINK_TYPE_XGMI, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_XGMI},
|
||||
{amdsmi_link_type_t::AMDSMI_LINK_TYPE_PCIE, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_PCIEXPRESS},
|
||||
{amdsmi_link_type_t::AMDSMI_LINK_TYPE_NOT_APPLICABLE, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED},
|
||||
{amdsmi_link_type_t::AMDSMI_LINK_TYPE_UNKNOWN, amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED}
|
||||
};
|
||||
|
||||
auto translated_link_type = [&](amdsmi_link_type_t link_type) {
|
||||
auto io_link_type(amdsmi_io_link_type_t::AMDSMI_IOLINK_TYPE_UNDEFINED);
|
||||
if (kLinkToIoLinkTypeTranslationTable.find(link_type) != kLinkToIoLinkTypeTranslationTable.end()) {
|
||||
io_link_type = kLinkToIoLinkTypeTranslationTable.at(link_type);
|
||||
}
|
||||
return io_link_type;
|
||||
};
|
||||
|
||||
auto translated_io_link_type = [&](amdsmi_io_link_type_t io_link_type) {
|
||||
auto link_type(amdsmi_link_type_t::AMDSMI_LINK_TYPE_UNKNOWN);
|
||||
for (const auto& [key, value] : kLinkToIoLinkTypeTranslationTable) {
|
||||
if (value == io_link_type) {
|
||||
link_type = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return link_type;
|
||||
};
|
||||
//
|
||||
|
||||
struct LinkTopolyInfo_t
|
||||
{
|
||||
amdsmi_processor_handle target_processor_handle;
|
||||
amdsmi_link_type_t link_type;
|
||||
bool is_accessible;
|
||||
uint64_t num_hops;
|
||||
uint64_t link_weight;
|
||||
};
|
||||
|
||||
using LinkTopogyOrderPair_t = std::pair<uint64_t, uint64_t>;
|
||||
/*
|
||||
* Note: The link topology table is sorted by the number of hops and link weight.
|
||||
*/
|
||||
struct LinkTopogyOrderCmp_t {
|
||||
constexpr bool operator()(const LinkTopolyInfo_t& left,
|
||||
const LinkTopolyInfo_t& right) const noexcept
|
||||
{
|
||||
if (left.num_hops == right.num_hops) {
|
||||
return (left.num_hops >= right.num_hops);
|
||||
}
|
||||
else {
|
||||
return (left.link_weight > right.link_weight);
|
||||
}
|
||||
}
|
||||
};
|
||||
std::priority_queue<LinkTopolyInfo_t,
|
||||
std::vector<LinkTopolyInfo_t>,
|
||||
LinkTopogyOrderCmp_t> link_topology_order{};
|
||||
//
|
||||
|
||||
|
||||
AMDSMI_CHECK_INIT();
|
||||
auto socket_counter = uint32_t(0);
|
||||
if (auto api_status = amdsmi_get_socket_handles(&socket_counter, nullptr);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS)) {
|
||||
return api_status;
|
||||
}
|
||||
|
||||
amdsmi_socket_handle socket_list[socket_counter];
|
||||
if (auto api_status = amdsmi_get_socket_handles(&socket_counter, &socket_list[0]);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS)) {
|
||||
return api_status;
|
||||
}
|
||||
|
||||
|
||||
uint32_t device_counter(AMDSMI_MAX_DEVICES);
|
||||
amdsmi_processor_handle device_list[AMDSMI_MAX_DEVICES];
|
||||
for (auto socket_idx = uint32_t(0); socket_idx < socket_counter; ++socket_idx) {
|
||||
if (auto api_status = amdsmi_get_processor_handles(socket_list[socket_idx], &device_counter, device_list);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS)) {
|
||||
return api_status;
|
||||
}
|
||||
|
||||
for (auto device_idx = uint32_t(0); device_idx < device_counter; ++device_idx) {
|
||||
/* Note: Skip the processor handle that is being queried. */
|
||||
if (processor_handle != device_list[device_idx]) {
|
||||
// Accessibility?
|
||||
auto is_accessible(false);
|
||||
if (auto api_status = amdsmi_is_P2P_accessible(processor_handle, device_list[device_idx], &is_accessible);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) || !is_accessible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Link type matches what we are searching for?
|
||||
auto io_link_type = translated_link_type(link_type);
|
||||
auto io_link_type_bck(io_link_type);
|
||||
auto num_hops = uint64_t(0);
|
||||
if (auto api_status = amdsmi_topo_get_link_type(processor_handle, device_list[device_idx], &num_hops, &io_link_type);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) || (translated_io_link_type(io_link_type) != link_type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Link weights
|
||||
auto link_weight = uint64_t(0);
|
||||
if (auto api_status = amdsmi_topo_get_link_weight(processor_handle, device_list[device_idx], &link_weight);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Topology nearest info
|
||||
LinkTopolyInfo_t link_info = {
|
||||
.target_processor_handle = device_list[device_idx],
|
||||
.link_type = translated_io_link_type(io_link_type),
|
||||
.is_accessible = is_accessible,
|
||||
.num_hops = num_hops,
|
||||
.link_weight = link_weight
|
||||
};
|
||||
link_topology_order.push(link_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: The link topology table is sorted by the number of hops and link weight.
|
||||
*/
|
||||
topology_nearest_info->processor_list[AMDSMI_MAX_DEVICES] = {nullptr};
|
||||
topology_nearest_info->count = link_topology_order.size();
|
||||
auto topology_nearest_counter = uint32_t(0);
|
||||
while (!link_topology_order.empty()) {
|
||||
auto link_info = link_topology_order.top();
|
||||
link_topology_order.pop();
|
||||
|
||||
if (topology_nearest_counter < AMDSMI_MAX_DEVICES) {
|
||||
topology_nearest_info->processor_list[topology_nearest_counter++] = link_info.target_processor_handle;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_ESMI_LIB
|
||||
static amdsmi_status_t amdsmi_errno_to_esmi_status(amdsmi_status_t status)
|
||||
|
||||
@@ -456,4 +456,58 @@ void TestHWTopologyRead::Run(void) {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
char *topology_link_type_str[] = {
|
||||
"AMDSMI_LINK_TYPE_INTERNAL",
|
||||
"AMDSMI_LINK_TYPE_XGMI",
|
||||
"AMDSMI_LINK_TYPE_PCIE",
|
||||
"AMDSMI_LINK_TYPE_NOT_APPLICABLE",
|
||||
"AMDSMI_LINK_TYPE_UNKNOWN",
|
||||
};
|
||||
|
||||
auto ret(amdsmi_status_t::AMDSMI_STATUS_SUCCESS);
|
||||
for (uint32_t dv_ind_src = 0; dv_ind_src < num_devices; dv_ind_src++) {
|
||||
std::cout <<"** Nearest GPUs for GPU" << dv_ind_src << " **" << "\n";
|
||||
for (uint32_t topo_link_type = AMDSMI_LINK_TYPE_INTERNAL; topo_link_type <= AMDSMI_LINK_TYPE_UNKNOWN; topo_link_type++) {
|
||||
|
||||
|
||||
/*
|
||||
* Note: We should get AMDSMI_STATUS_INVAL for the first call with amdsmi_topology_nearest_t = nullptr
|
||||
*/
|
||||
ret = amdsmi_get_link_topology_nearest(processor_handles_[dv_ind_src],
|
||||
static_cast<amdsmi_link_type_t>(topo_link_type),
|
||||
nullptr);
|
||||
ASSERT_EQ(ret, amdsmi_status_t::AMDSMI_STATUS_INVAL);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
auto topology_nearest_info = amdsmi_topology_nearest_t();
|
||||
ret = amdsmi_get_link_topology_nearest(processor_handles_[dv_ind_src],
|
||||
static_cast<amdsmi_link_type_t>(topo_link_type),
|
||||
&topology_nearest_info);
|
||||
if (ret != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout <<"Nearest GPUs found for Link Type: " << topology_link_type_str[topo_link_type] << "\n";
|
||||
if (topology_nearest_info.count > 0) {
|
||||
for (uint32_t k = 0; k < topology_nearest_info.count; k++) {
|
||||
amdsmi_bdf_t bdf = {};
|
||||
ret = amdsmi_get_gpu_device_bdf(topology_nearest_info.processor_list[k], &bdf);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("\tGPU BDF %04lx:%02x:%02x.%d\n", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "\tNot found" << "\n";
|
||||
}
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user