another set of esmi python wrappers updated to amdsmi python library
Change-Id: I33557b9021ecfdab76daaf65ad63f624115aa322
Tento commit je obsažen v:
@@ -4069,3 +4069,133 @@ try:
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_cpu_socket_temperature
|
||||
|
||||
Description: Get the socket temperature.
|
||||
|
||||
Output: amdsmi temperature value
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_cpu_socket_temperature` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
socket_handles = amdsmi_get_cpusocket_handles()
|
||||
if len(socket_handles) == 0:
|
||||
print("No CPU sockets on machine")
|
||||
else:
|
||||
for socket in socket_handles:
|
||||
ptmon = amdsmi_get_cpu_socket_temperature(socket)
|
||||
print(ptmon)
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_cpu_dimm_temp_range_and_refresh_rate
|
||||
|
||||
Description: Get DIMM temperature range and refresh rate.
|
||||
|
||||
Output: amdsmi dimm metric data
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_cpu_dimm_temp_range_and_refresh_rate` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
socket_handles = amdsmi_get_cpusocket_handles()
|
||||
if len(socket_handles) == 0:
|
||||
print("No CPU sockets on machine")
|
||||
else:
|
||||
for socket in socket_handles:
|
||||
dimm = amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(socket)
|
||||
print(dimm['range'])
|
||||
print(dimm['ref_rate'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_cpu_dimm_power_consumption
|
||||
|
||||
Description: amdsmi_get_cpu_dimm_power_consumption.
|
||||
|
||||
Output: amdsmi dimm power consumption value
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_cpu_dimm_power_consumption` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
socket_handles = amdsmi_get_cpusocket_handles()
|
||||
if len(socket_handles) == 0:
|
||||
print("No CPU sockets on machine")
|
||||
else:
|
||||
for socket in socket_handles:
|
||||
dimm = amdsmi_get_cpu_dimm_power_consumption(socket)
|
||||
print(dimm['power'])
|
||||
print(dimm['update_rate'])
|
||||
print(dimm['dimm_addr'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_get_cpu_dimm_thermal_sensor
|
||||
|
||||
Description: Get DIMM thermal sensor value.
|
||||
|
||||
Output: amdsmi dimm temperature data
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_cpu_dimm_thermal_sensor` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
socket_handles = amdsmi_get_cpusocket_handles()
|
||||
if len(socket_handles) == 0:
|
||||
print("No CPU sockets on machine")
|
||||
else:
|
||||
for socket in socket_handles:
|
||||
dimm = amdsmi_get_cpu_dimm_thermal_sensor(socket)
|
||||
print(dimm['sensor'])
|
||||
print(dimm['update_rate'])
|
||||
print(dimm['dimm_addr'])
|
||||
print(dimm['temp'])
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
### amdsmi_set_cpu_xgmi_width
|
||||
|
||||
Description: Set xgmi width.
|
||||
|
||||
Input: amdsmi xgmi width
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_set_cpu_xgmi_width` function:
|
||||
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
|
||||
```python
|
||||
try:
|
||||
socket_handles = amdsmi_get_cpusocket_handles()
|
||||
if len(socket_handles) == 0:
|
||||
print("No CPU sockets on machine")
|
||||
else:
|
||||
for socket in socket_handles:
|
||||
xgmi_width = amdsmi_set_cpu_xgmi_width(socket, 0, 100)
|
||||
except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
@@ -45,6 +45,21 @@ try:
|
||||
from .amdsmi_interface import amdsmi_get_cpu_socket_freq_range
|
||||
from .amdsmi_interface import amdsmi_get_cpu_core_current_freq_limit
|
||||
from .amdsmi_interface import amdsmi_get_cpu_socket_power
|
||||
from .amdsmi_interface import amdsmi_get_cpu_socket_power_cap
|
||||
from .amdsmi_interface import amdsmi_get_cpu_socket_power_cap_max
|
||||
from .amdsmi_interface import amdsmi_get_cpu_pwr_svi_telemetry_all_rails
|
||||
from .amdsmi_interface import amdsmi_set_cpu_socket_power_cap
|
||||
from .amdsmi_interface import amdsmi_set_cpu_pwr_efficiency_mode
|
||||
from .amdsmi_interface import amdsmi_get_cpu_core_boostlimit
|
||||
from .amdsmi_interface import amdsmi_get_cpu_socket_c0_residency
|
||||
from .amdsmi_interface import amdsmi_set_cpu_core_boostlimit
|
||||
from .amdsmi_interface import amdsmi_set_cpu_socket_boostlimit
|
||||
from .amdsmi_interface import amdsmi_get_cpu_ddr_bw
|
||||
from .amdsmi_interface import amdsmi_get_cpu_socket_temperature
|
||||
from .amdsmi_interface import amdsmi_get_cpu_dimm_temp_range_and_refresh_rate
|
||||
from .amdsmi_interface import amdsmi_get_cpu_dimm_power_consumption
|
||||
from .amdsmi_interface import amdsmi_get_cpu_dimm_thermal_sensor
|
||||
from .amdsmi_interface import amdsmi_set_cpu_xgmi_width
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -1063,6 +1063,111 @@ def amdsmi_get_cpu_ddr_bw(socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle)
|
||||
"ddr_bw_utilized_pct": ddr_bw.utilized_pct
|
||||
}
|
||||
|
||||
def amdsmi_get_cpu_socket_temperature(
|
||||
socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, sock_idx: int
|
||||
) -> int:
|
||||
if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle):
|
||||
raise AmdSmiParameterException(
|
||||
socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle
|
||||
)
|
||||
if not isinstance(sock_idx, int):
|
||||
raise AmdSmiParameterException(sock_idx, int)
|
||||
|
||||
ptmon = ctypes.c_uint32()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_cpu_socket_temperature(
|
||||
socket_handle, sock_idx, ctypes.byref(ptmon)
|
||||
)
|
||||
)
|
||||
|
||||
return ptmon.value
|
||||
|
||||
def amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(
|
||||
socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle,
|
||||
sock_idx: int, dimm_addr: int):
|
||||
if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle):
|
||||
raise AmdSmiParameterException(
|
||||
socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle
|
||||
)
|
||||
if not isinstance(sock_idx, int):
|
||||
raise AmdSmiParameterException(sock_idx, int)
|
||||
if not isinstance(dimm_addr, int):
|
||||
raise AmdSmiParameterException(dimm_addr, int)
|
||||
|
||||
dimm = amdsmi_wrapper.amdsmi_temp_range_refresh_rate_t()
|
||||
|
||||
_check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(socket_handle, dimm))
|
||||
|
||||
return {
|
||||
"dimm_temperature_range": dimm.range,
|
||||
"dimm_refresh_rate": dimm.ref_rate
|
||||
}
|
||||
|
||||
def amdsmi_get_cpu_dimm_power_consumption(
|
||||
socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle,
|
||||
sock_idx: int, dimm_addr: int):
|
||||
if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle):
|
||||
raise AmdSmiParameterException(
|
||||
socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle
|
||||
)
|
||||
if not isinstance(sock_idx, int):
|
||||
raise AmdSmiParameterException(sock_idx, int)
|
||||
if not isinstance(dimm_addr, int):
|
||||
raise AmdSmiParameterException(dimm_addr, int)
|
||||
|
||||
dimm = amdsmi_wrapper.amdsmi_dimm_power_t()
|
||||
|
||||
_check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_power_consumption(socket_handle, dimm))
|
||||
|
||||
return {
|
||||
"dimm_power_consumed": dimm.power,
|
||||
"dimm_power_update_rate": dimm.update_rate,
|
||||
"dimm_dimm_addr": dimm.dimm_addr
|
||||
}
|
||||
|
||||
def amdsmi_get_cpu_dimm_thermal_sensor(
|
||||
socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle,
|
||||
sock_idx: int, dimm_addr: int):
|
||||
if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle):
|
||||
raise AmdSmiParameterException(
|
||||
socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle
|
||||
)
|
||||
if not isinstance(sock_idx, int):
|
||||
raise AmdSmiParameterException(sock_idx, int)
|
||||
if not isinstance(dimm_addr, int):
|
||||
raise AmdSmiParameterException(dimm_addr, int)
|
||||
|
||||
dimm_thermal = amdsmi_wrapper.amdsmi_dimm_thermal_t()
|
||||
|
||||
_check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_thermal_sensor(socket_handle, dimm_thermal))
|
||||
|
||||
return {
|
||||
"dimm_thermal_sensor_value": dimm_thermal.sensor,
|
||||
"dimm_thermal_update_rate": dimm_thermal.update_rate,
|
||||
"dimm_thermal_dimm_addr": dimm_thermal.dimm_addr,
|
||||
"dimm_thermal_temperature": dimm_thermal.temp
|
||||
}
|
||||
|
||||
def amdsmi_set_cpu_xgmi_width(
|
||||
socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, min_width: int, max_width: int
|
||||
):
|
||||
if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle):
|
||||
raise AmdSmiParameterException(
|
||||
socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle
|
||||
)
|
||||
if not isinstance(min_width, int):
|
||||
raise AmdSmiParameterException(min_width, int)
|
||||
if not isinstance(max_width, int):
|
||||
raise AmdSmiParameterException(max_width, int)
|
||||
|
||||
min_width = ctypes.c_uint8(min_width)
|
||||
max_width = ctypes.c_uint8(max_width)
|
||||
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_set_cpu_xgmi_width(
|
||||
socket_handle, min_width, max_width)
|
||||
)
|
||||
|
||||
def amdsmi_init(flag=AmdSmiInitFlags.INIT_AMD_GPUS):
|
||||
if not isinstance(flag, AmdSmiInitFlags):
|
||||
raise AmdSmiParameterException(flag, AmdSmiInitFlags)
|
||||
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele