SWDEV-361376 - Updated python API

Added pcie, power and memory API

Change-Id: I0b3bd1c110099805c700f53974eceb6acd850930
Signed-off-by: Dalibor Stanisavljevic <Dalibor.Stanisavljevic@amd.com>


[ROCm/amdsmi commit: 21d6e0f990]
This commit is contained in:
Dalibor Stanisavljevic
2022-11-10 16:18:27 +01:00
parent 9164042117
commit dd0eab575b
3 changed files with 644 additions and 31 deletions
+348
View File
@@ -1389,6 +1389,8 @@ try:
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_clk_range_set
Description: This function sets the clock range information
@@ -1417,6 +1419,286 @@ try:
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_pci_id_get
Description: Get the unique PCI device identifier associated for a device
Input parameters:
* `device_handle` device which to query
Output: device bdf
The format of bdfid will be as follows:
BDFID = ((DOMAIN & 0xffffffff) << 32) | ((BUS & 0xff) << 8) |
((DEVICE & 0x1f) <<3 ) | (FUNCTION & 0x7)
| Name | Field |
---------- | ------- |
| Domain | [64:32] |
| Reserved | [31:16] |
| Bus | [15: 8] |
| Device | [ 7: 3] |
| Function | [ 2: 0] |
Exceptions that can be thrown by `amdsmi_dev_pci_id_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
bdfid = amdsmi_dev_pci_id_get(device)
print(bdfid)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_pci_bandwidth_get
Description: Get the list of possible PCIe bandwidths that are available.
Input parameters:
* `device_handle` device which to query
Output: Dictionary with the possible T/s values and associated number of lanes
Field | Content
---|---
`transfer_rate` | transfer_rate dictionary
`lanes` | lanes
transfer_rate dictionary
Field | Content
---|---
`num_supported` | num_supported
`current` | current
`frequency` | list of frequency
Exceptions that can be thrown by `amdsmi_dev_pci_bandwidth_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
bandwidth = amdsmi_dev_pci_bandwidth_get(device)
print(bandwidth)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_pci_throughput_get
Description: Get PCIe traffic information
Input parameters:
* `device_handle` device which to query
Output: Dictionary with the fields
Field | Content
---|---
`sent` | number of bytes sent in 1 second
`received` | the number of bytes received
`max_pkt_sz` | maximum packet size
Exceptions that can be thrown by `amdsmi_dev_pci_throughput_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
pci = amdsmi_dev_pci_throughput_get(device)
print(pci)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_pci_replay_counter_get
Description: Get PCIe replay counter
Input parameters:
* `device_handle` device which to query
Output: counter value
The sum of the NAK's received and generated by the GPU
Exceptions that can be thrown by `amdsmi_dev_pci_replay_counter_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
counter = amdsmi_dev_pci_replay_counter_get(device)
print(counter)
except AmdSmiException as e:
print(e)
```
## amdsmi_topo_numa_affinity_get
Description: Get the NUMA node associated with a device
Input parameters:
* `device_handle` device which to query
Output: NUMA node value
Exceptions that can be thrown by `amdsmi_topo_numa_affinity_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
numa_node = amdsmi_topo_numa_affinity_get(device)
print(numa_node)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_power_ave_get
Description: Get the average power consumption of the device
Input parameters:
* `device_handle` device which to query
* `sensor_id` a 0-based sensor index. Normally, this will be 0.
If a device has more than one sensor, it could be greater than 0.
Output: the average power consumption
Exceptions that can be thrown by `amdsmi_dev_power_ave_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
power = amdsmi_dev_power_ave_get(device)
print(power)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_energy_count_get
Description: Get the energy accumulator counter of the device.
Input parameters:
* `device_handle` device which to query
Output: Dictionary with fields
Field | Content
---|---
`power` | power
`counter_resolution` | counter resolution
`timestamp` | timestamp
Exceptions that can be thrown by `amdsmi_dev_energy_count_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
power = amdsmi_dev_energy_count_get(device)
print(power)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_memory_total_get
Description: Get the total amount of memory that exists
Input parameters:
* `device_handle` device which to query
* `mem_type` enum AmdSmiMemoryType
Output: total amount of memory
Exceptions that can be thrown by `amdsmi_dev_memory_total_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
memory = amdsmi_dev_memory_total_get(device)
print(memory)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_od_clk_info_set
Description: This function sets the clock frequency information
@@ -1451,6 +1733,39 @@ try:
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_memory_usage_get
Description: Get the current memory usage
Input parameters:
* `device_handle` device which to query
* `mem_type` enum AmdSmiMemoryType
Output: the amount of memory currently being used
Exceptions that can be thrown by `amdsmi_dev_memory_usage_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
memory = amdsmi_dev_memory_usage_get(device)
print(memory)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_od_volt_info_set
Description: This function sets 1 of the 3 voltage curve points
@@ -1479,6 +1794,39 @@ try:
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_memory_busy_percent_get
Description: Get percentage of time any device memory is being used
Input parameters:
* `device_handle` device which to query
Output: percentage of time that any device memory is being used for the specified device.
Exceptions that can be thrown by `amdsmi_dev_memory_busy_percent_get` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
* `AmdSmiParameterException`
Example:
```python
try:
devices = gpuvsmi_get_devices()
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
busy_percent = amdsmi_dev_memory_busy_percent_get(device)
print(busy_percent)
except AmdSmiException as e:
print(e)
```
## amdsmi_dev_perf_level_set_v1
Description: Set the PowerPlay performance level associated with the device
with provided device handle with the provided value