Process isolation and clean shader

A few APIs and command line options are added to support process
isolation and clean shader.

Change-Id: I98ad3fc9fc7429799a21798b7fca1c307de7f403
This commit is contained in:
Bill(Shuzhou) Liu
2024-04-08 10:35:24 -05:00
committed by Shuzhou Liu
parent 1ae3a5b6cb
commit 7d2ab7970d
12 changed files with 611 additions and 53 deletions
+161
View File
@@ -1963,6 +1963,98 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_process_isolation
Description: Get the status of the Process Isolation
Input parameters:
* `processor_handle` handle for the given device
Output: integer corresponding to isolation_status; 0 - disabled, 1 - enabled
Exceptions that can be thrown by `amdsmi_get_gpu_process_isolation` 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:
isolate = amdsmi_get_gpu_process_isolation(device)
print("Process Isolation Status: ", isolate)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_gpu_process_isolation
Description: Enable/disable the system Process Isolation for the given device handle.
Input parameters:
* `processor_handle` handle for the given device
* `pisolate` the process isolation status to set. 0 is the process isolation disabled, and 1 is the process isolation enabled.
Output: None
Exceptions that can be thrown by `amdsmi_set_gpu_process_isolation` 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_gpu_process_isolation(device, 1)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_gpu_clear_sram_data
Description: Clear the SRAM data of the given device. This can be called between user logins to prevent information leak.
Input parameters:
* `processor_handle` handle for the given device
* `sclean` the clean flag. Only 1 will take effect and other number are reserved for future usage.
Output: None
Exceptions that can be thrown by `amdsmi_set_gpu_clear_sram_data` 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_gpu_clear_sram_data(device, 1)
except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_overdrive_level
Description: Get the overdrive percent associated with the device with provided
@@ -2602,6 +2694,75 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_dpm_policy
Description: Get dpm policy information.
Input parameters:
* `processor_handle` handle for the given device
* `policy_id` the policy id to set.
Output: Dictionary with fields
Field | Description
---|---
`num_supported` | total number of supported policies
`current_id` | current policy id
`policies` | list of dictionaries containing possible policies
Exceptions that can be thrown by `amdsmi_get_dpm_policy` 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:
dpm_policies = amdsmi_get_dpm_policy(device)
print(dpm_policies)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_dpm_policy
Description: Set the dpm policy to corresponding policy_id. Typically following: 0(default),1,2,3
Input parameters:
* `processor_handle` handle for the given device
* `policy_id` the policy id to set.
Output: None
Exceptions that can be thrown by `amdsmi_set_dpm_policy` 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_dpm_policy(device, 0)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_xgmi_plpd
Description: Set the xgmi per-link power down policy parameter for the processor
+55 -1
View File
@@ -2734,6 +2734,7 @@ def amdsmi_set_clk_freq(
)
)
def amdsmi_set_dpm_policy(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
policy_id: int,
@@ -2748,6 +2749,7 @@ def amdsmi_set_dpm_policy(
)
)
def amdsmi_set_xgmi_plpd(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
policy_id: int,
@@ -2762,6 +2764,37 @@ def amdsmi_set_xgmi_plpd(
)
)
def amdsmi_set_gpu_process_isolation(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
pisolate: 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_gpu_process_isolation(
processor_handle, pisolate
)
)
def amdsmi_set_gpu_clear_sram_data(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
sclean: 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_gpu_clear_sram_data(
processor_handle, sclean
)
)
def amdsmi_set_gpu_overdrive_level(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, overdrive_value: int
):
@@ -2793,6 +2826,7 @@ def amdsmi_get_gpu_bdf_id(processor_handle: amdsmi_wrapper.amdsmi_processor_hand
return bdfid.value
def amdsmi_set_gpu_pci_bandwidth(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, bitmask: int
) -> None:
@@ -3089,7 +3123,6 @@ def amdsmi_set_gpu_od_volt_info(
)
def amdsmi_get_gpu_fan_rpms(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle, sensor_idx: int
) -> int:
@@ -3320,6 +3353,7 @@ def amdsmi_get_clk_freq(
"frequency": list(freq.frequency)[: freq.num_supported - 1],
}
def amdsmi_get_dpm_policy(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
@@ -3351,6 +3385,7 @@ def amdsmi_get_dpm_policy(
"policies": polices,
}
def amdsmi_get_xgmi_plpd(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
@@ -3382,6 +3417,25 @@ def amdsmi_get_xgmi_plpd(
"plpds": polices,
}
def amdsmi_get_gpu_process_isolation(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> int:
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
pisolate = ctypes.c_uint32()
_check_res(
amdsmi_wrapper.amdsmi_get_gpu_process_isolation(
processor_handle, ctypes.byref(pisolate)
)
)
return pisolate.value
def amdsmi_get_gpu_od_volt_info(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
+17 -7
View File
@@ -2076,6 +2076,15 @@ amdsmi_get_xgmi_plpd.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_
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_gpu_process_isolation = _libraries['libamd_smi.so'].amdsmi_get_gpu_process_isolation
amdsmi_get_gpu_process_isolation.restype = amdsmi_status_t
amdsmi_get_gpu_process_isolation.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)]
amdsmi_set_gpu_process_isolation = _libraries['libamd_smi.so'].amdsmi_set_gpu_process_isolation
amdsmi_set_gpu_process_isolation.restype = amdsmi_status_t
amdsmi_set_gpu_process_isolation.argtypes = [amdsmi_processor_handle, uint32_t]
amdsmi_set_gpu_clear_sram_data = _libraries['libamd_smi.so'].amdsmi_set_gpu_clear_sram_data
amdsmi_set_gpu_clear_sram_data.restype = amdsmi_status_t
amdsmi_set_gpu_clear_sram_data.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)]
@@ -2589,7 +2598,7 @@ __all__ = \
'amdsmi_get_gpu_pci_throughput', 'amdsmi_get_gpu_perf_level',
'amdsmi_get_gpu_pm_metrics_info',
'amdsmi_get_gpu_power_profile_presets',
'amdsmi_get_gpu_process_list',
'amdsmi_get_gpu_process_isolation', 'amdsmi_get_gpu_process_list',
'amdsmi_get_gpu_ras_block_features_enabled',
'amdsmi_get_gpu_ras_feature_info',
'amdsmi_get_gpu_reg_table_info', 'amdsmi_get_gpu_revision',
@@ -2646,18 +2655,19 @@ __all__ = \
'amdsmi_set_cpu_socket_boostlimit',
'amdsmi_set_cpu_socket_lclk_dpm_level',
'amdsmi_set_cpu_socket_power_cap', 'amdsmi_set_cpu_xgmi_width',
'amdsmi_set_dpm_policy', 'amdsmi_set_gpu_clk_range',
'amdsmi_set_gpu_compute_partition',
'amdsmi_set_dpm_policy', 'amdsmi_set_gpu_clear_sram_data',
'amdsmi_set_gpu_clk_range', 'amdsmi_set_gpu_compute_partition',
'amdsmi_set_gpu_event_notification_mask',
'amdsmi_set_gpu_fan_speed', 'amdsmi_set_gpu_memory_partition',
'amdsmi_set_gpu_od_clk_info', 'amdsmi_set_gpu_od_volt_info',
'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_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_set_gpu_process_isolation', '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',