Use different sysfs for soc_pstate and xmgi_plpd

The sysfs is changed to use the pm_policy folder with multiple
dpm_policy files.

Change-Id: I40fac8de2d0cb127950d238b8196f6d2416778d0
このコミットが含まれているのは:
Maisam Arif
2024-05-23 10:31:37 -05:00
committed by Maisam Arif
コミット e5d1ba4621
16個のファイルの変更219行の追加157行の削除
+88 -8
ファイルの表示
@@ -774,8 +774,28 @@ GPU: 0
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY: N/A
XGMI_PLPD: N/A
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 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
PROCESS_ISOLATION: N/A
NUMA:
NODE: 0
@@ -879,8 +899,28 @@ GPU: 1
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY: N/A
XGMI_PLPD: N/A
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 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
PROCESS_ISOLATION: N/A
NUMA:
NODE: 1
@@ -984,8 +1024,28 @@ GPU: 2
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY: N/A
XGMI_PLPD: N/A
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 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
PROCESS_ISOLATION: N/A
NUMA:
NODE: 2
@@ -1089,8 +1149,28 @@ GPU: 3
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY: N/A
XGMI_PLPD: N/A
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
POLICY_ID: 0
POLICY_DESCRIPTION: pstate_default
POLICY_ID: 1
POLICY_DESCRIPTION: soc_pstate_0
POLICY_ID: 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
PROCESS_ISOLATION: N/A
NUMA:
NODE: 3
+32 -32
ファイルの表示
@@ -245,7 +245,7 @@ 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, xgmi_plpd=None, process_isolation=None):
soc_pstate=None, xgmi_plpd=None, process_isolation=None):
"""Get Static information for target gpu
Args:
@@ -268,7 +268,7 @@ class AMDSMICommands():
dfc_ucode (bool, optional): Value override for args.dfc_ucode. Defaults to None.
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.
soc_pstate (bool, optional): Value override for args.soc_pstate. Defaults to None.
xgmi_plpd (bool, optional): Value override for args.xgmi_plpd. Defaults to None.
process_isolation (bool, optional): Value override for args.process_isolation. Defaults to None.
Returns:
@@ -307,13 +307,12 @@ class AMDSMICommands():
args.partition = partition
if limit:
args.limit = limit
if policy:
args.policy = policy
if soc_pstate:
args.soc_pstate = soc_pstate
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]
current_platform_args += ["ras", "limit", "partition", "soc_pstate", "xgmi_plpd"]
current_platform_values += [args.ras, args.limit, args.partition, args.soc_pstate, args.xgmi_plpd]
if self.helpers.is_linux() and not self.helpers.is_virtual_os():
if numa:
@@ -638,15 +637,15 @@ class AMDSMICommands():
static_dict['partition'] = {"compute_partition": compute_partition,
"memory_partition": memory_partition}
if 'policy' in current_platform_args:
if args.policy:
if 'soc_pstate' in current_platform_args:
if args.soc_pstate:
try:
policy_info = amdsmi_interface.amdsmi_get_dpm_policy(args.gpu)
policy_info = amdsmi_interface.amdsmi_get_soc_pstate(args.gpu)
except amdsmi_exception.AmdSmiLibraryException as e:
policy_info = "N/A"
logging.debug("Failed to get policy info for gpu %s | %s", gpu_id, e.get_error_info())
logging.debug("Failed to get soc pstate policy info for gpu %s | %s", gpu_id, e.get_error_info())
static_dict['dpm_policy'] = policy_info
static_dict['soc_pstate'] = policy_info
if 'xgmi_plpd' in current_platform_args:
if args.xgmi_plpd:
try:
@@ -802,7 +801,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, xgmi_plpd = None, process_isolation=None):
interface_ver=None, soc_pstate=None, xgmi_plpd = None, process_isolation=None):
"""Get Static information for target gpu and cpu
Args:
@@ -825,7 +824,7 @@ class AMDSMICommands():
num_vf (bool, optional): Value override for args.num_vf. Defaults to None.
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.
soc_pstate (bool, optional): Value override for args.soc_pstate. Defaults to None.
xgmi_plpd (bool, optional): Value override for args.xgmi_plpd. Defaults to None.
process_isolation (bool, optional): Value override for args.process_isolation. Defaults to None.
Raises:
@@ -853,7 +852,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", "xgmi_plpd",
"dfc_ucode", "fb_info", "num_vf", "soc_pstate", "xgmi_plpd",
"process_isolation"]
for attr in gpu_attributes:
if hasattr(args, attr):
@@ -884,7 +883,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, soc_pstate,
process_isolation)
elif self.helpers.is_amd_hsmp_initialized(): # Only CPU is initialized
if args.cpu == None:
@@ -899,7 +898,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, xgmi_plpd,
dfc_ucode, fb_info, num_vf, soc_pstate, xgmi_plpd,
process_isolation)
@@ -3387,7 +3386,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, xgmi_plpd = None,
memory_partition=None, power_cap=None, soc_pstate=None, xgmi_plpd = None,
process_isolation=None):
"""Issue reset commands to target gpu(s)
@@ -3402,7 +3401,7 @@ class AMDSMICommands():
compute_partition (amdsmi_interface.AmdSmiComputePartitionType, optional): Value override for args.compute_partition. Defaults to None.
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.
soc_pstate (int, optional): Value override for args.soc_pstate. Defaults to None.
xgmi_plpd (int, optional): Value override for args.xgmi_plpd. Defaults to None.
process_isolation (int, optional): Value override for args.process_isolation. Defaults to None.
Raises:
@@ -3429,8 +3428,8 @@ class AMDSMICommands():
args.memory_partition = memory_partition
if power_cap:
args.power_cap = power_cap
if dpm_policy:
args.dpm_policy = dpm_policy
if soc_pstate:
args.soc_pstate = soc_pstate
if xgmi_plpd:
args.xgmi_plpd = xgmi_plpd
if process_isolation:
@@ -3455,7 +3454,7 @@ class AMDSMICommands():
args.memory_partition,
args.perf_determinism is not None,
args.power_cap is not None,
args.dpm_policy is not None,
args.soc_pstate is not None,
args.xgmi_plpd is not None,
args.process_isolation is not None]):
command = " ".join(sys.argv[1:])
@@ -3551,14 +3550,14 @@ class AMDSMICommands():
if min_power_cap == 0:
min_power_cap = 1
self.logger.store_output(args.gpu, 'powercap', f"Power cap must be between {min_power_cap} and {max_power_cap}")
if isinstance(args.dpm_policy, int):
if isinstance(args.soc_pstate, int):
try:
amdsmi_interface.amdsmi_set_dpm_policy(args.gpu, args.dpm_policy)
amdsmi_interface.amdsmi_set_soc_pstate(args.gpu, args.soc_pstate)
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 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}")
raise ValueError(f"Unable to set dpm soc pstate policy to {args.soc_pstate} on {gpu_string}") from e
self.logger.store_output(args.gpu, 'socpstate', f"Successfully soc pstate dpm policy to id {args.soc_pstate}")
if isinstance(args.xgmi_plpd, int):
try:
amdsmi_interface.amdsmi_set_xgmi_plpd(args.gpu, args.xgmi_plpd)
@@ -3566,7 +3565,7 @@ class AMDSMICommands():
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}")
self.logger.store_output(args.gpu, 'xgmiplpd', f"Successfully set per-link power down policy to id {args.xgmi_plpd}")
if isinstance(args.process_isolation, int):
status_string = "Enabled" if args.process_isolation else "Disabled"
result = f"Requested process isolation to {status_string}" # This should not print out
@@ -3597,7 +3596,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, xgmi_plpd=None,
soc_boost_limit=None, core=None, core_boost_limit=None, soc_pstate=None, xgmi_plpd=None,
process_isolation=None):
"""Issue reset commands to target gpu(s)
@@ -3627,7 +3626,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.
soc_pstate (int, optional): Value override for args.soc_pstate. Defaults to None.
xgmi_plpd (int, optional): Value override for args.xgmi_plpd. Defaults to None.
process_isolation (int, optional): Value override for args.process_isolation. Defaults to None.
Raises:
@@ -3649,7 +3648,8 @@ 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", "xgmi_plpd", "process_isolation"]
"memory_partition", "power_cap", "soc_pstate", "xgmi_plpd", "process_isolation",
]
for attr in gpu_attributes:
if hasattr(args, attr):
if getattr(args, attr) is not None:
@@ -3704,7 +3704,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, xgmi_plpd,
memory_partition, power_cap, soc_pstate, xgmi_plpd,
process_isolation)
elif self.helpers.is_amd_hsmp_initialized(): # Only CPU is initialized
if args.cpu == None and args.core == None:
@@ -3724,7 +3724,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, xgmi_plpd,
memory_partition, power_cap, soc_pstate, xgmi_plpd,
process_isolation)
+4 -4
ファイルの表示
@@ -543,7 +543,7 @@ class AMDSMIParser(argparse.ArgumentParser):
vram_help = "All vram information"
cache_help = "All cache information"
board_help = "All board information"
dpm_policy_help = "The available DPM policy"
soc_pstate_help = "The available soc pstate policy"
xgmi_plpd_help = "The available XGMI per-link power down policy"
process_isolation_help = "The process isolation status"
@@ -586,7 +586,7 @@ class AMDSMIParser(argparse.ArgumentParser):
static_parser.add_argument('-r', '--ras', action='store_true', required=False, help=ras_help)
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('-P', '--soc-pstate', action='store_true', required=False, help=soc_pstate_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():
@@ -969,7 +969,7 @@ class AMDSMIParser(argparse.ArgumentParser):
set_compute_partition_help = f"Set one of the following the compute partition modes:\n\t{compute_partition_choices_str}"
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 = "Set the GPU DPM policy using policy id\n"
set_soc_pstate_help = "Set the GPU soc pstate policy using policy id\n"
set_xgmi_plpd_help = "Set the GPU XGMI per-link power down policy using policy id\n"
set_process_isolation_help = "Enable or disable the GPU process isolation: 0 for disable and 1 for enable.\n"
@@ -1008,7 +1008,7 @@ class AMDSMIParser(argparse.ArgumentParser):
set_value_parser.add_argument('-C', '--compute-partition', action='store', choices=self.helpers.get_compute_partition_types(), type=str.upper, required=False, help=set_compute_partition_help, metavar='PARTITION')
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('-p', '--soc-pstate', action='store', required=False, type=self._not_negative_int, help=set_soc_pstate_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')
set_value_parser.add_argument('-R', '--process-isolation', action='store', choices=[0,1], type=self._not_negative_int, required=False, help=set_process_isolation_help, metavar='STATUS')
+4 -4
ファイルの表示
@@ -607,7 +607,7 @@ GPU: 0
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY:
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -725,7 +725,7 @@ GPU: 1
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY:
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -843,7 +843,7 @@ GPU: 2
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY:
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
@@ -961,7 +961,7 @@ GPU: 3
PARTITION:
COMPUTE_PARTITION: SPX
MEMORY_PARTITION: NPS1
DPM_POLICY:
SOC_PSTATE:
NUM_SUPPORTED: 4
CURRENT_ID: 1
POLICIES:
+6 -6
ファイルの表示
@@ -2705,7 +2705,7 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_dpm_policy
### amdsmi_get_soc_pstate
Description: Get dpm policy information.
@@ -2722,7 +2722,7 @@ Field | Description
`current_id` | current policy id
`policies` | list of dictionaries containing possible policies
Exceptions that can be thrown by `amdsmi_get_dpm_policy` function:
Exceptions that can be thrown by `amdsmi_get_soc_pstate` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
@@ -2737,13 +2737,13 @@ try:
print("No GPUs on machine")
else:
for device in devices:
dpm_policies = amdsmi_get_dpm_policy(device)
dpm_policies = amdsmi_get_soc_pstate(device)
print(dpm_policies)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_dpm_policy
### amdsmi_set_soc_pstate
Description: Set the dpm policy to corresponding policy_id. Typically following: 0(default),1,2,3
@@ -2754,7 +2754,7 @@ Input parameters:
Output: None
Exceptions that can be thrown by `amdsmi_set_dpm_policy` function:
Exceptions that can be thrown by `amdsmi_set_soc_pstate` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
@@ -2769,7 +2769,7 @@ try:
print("No GPUs on machine")
else:
for device in devices:
amdsmi_set_dpm_policy(device, 0)
amdsmi_set_soc_pstate(device, 0)
except AmdSmiException as e:
print(e)
```
+2 -2
ファイルの表示
@@ -333,10 +333,10 @@ int main() {
<< "W\n\n";
amdsmi_dpm_policy_t policy;
ret = amdsmi_get_dpm_policy(processor_handles[j], &policy);
ret = amdsmi_get_soc_pstate(processor_handles[j], &policy);
if (ret != AMDSMI_STATUS_NOT_SUPPORTED) {
CHK_AMDSMI_RET(ret)
std::cout << "\t amdsmi_get_dpm_policy total:" << policy.num_supported
std::cout << "\t amdsmi_get_soc_pstate total:" << policy.num_supported
<<" current:" << policy.current << "\n";
for (int x=0; x < policy.num_supported; x++) {
std::cout << x <<": (" << policy.policies[x].policy_id
+10 -10
ファイルの表示
@@ -3384,45 +3384,45 @@ amdsmi_status_t amdsmi_set_clk_freq(amdsmi_processor_handle processor_handle,
amdsmi_clk_type_t clk_type, uint64_t freq_bitmask);
/**
* @brief Get the dpm policy for the processor
* @brief Get the soc pstate policy for the processor
*
* @platform{gpu_bm_linux} @platform{guest_1vf}
*
* @details Given a processor handle @p processor_handle, this function will write
* current dpm policy settings to @p policy. All the processors at the same socket
* current soc pstate policy 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 dpm policy for this processor.
* @param[in, out] policy the soc pstate policy 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_dpm_policy(amdsmi_processor_handle processor_handle,
amdsmi_status_t amdsmi_get_soc_pstate(amdsmi_processor_handle processor_handle,
amdsmi_dpm_policy_t* policy);
/**
* @brief Set the dpm policy for the processor
* @brief Set the soc pstate policy for the processor
*
* @platform{gpu_bm_linux} @platform{guest_1vf}
*
* @details Given a processor handle @p processor_handle and a dpm policy @p policy_id,
* this function will set the dpm policy for this processor. All the processors at
* @details Given a processor handle @p processor_handle and a soc pstate policy @p policy_id,
* this function will set the soc pstate policy 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] policy_id the dpm policy id to set. The id is the id in
* @param[in] policy_id the soc pstate policy id to set. The id is the id in
* amdsmi_dpm_policy_entry_t, which can be obtained by calling
* amdsmi_get_dpm_policy()
* amdsmi_get_soc_pstate()
*
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
*/
amdsmi_status_t amdsmi_set_dpm_policy(amdsmi_processor_handle processor_handle,
amdsmi_status_t amdsmi_set_soc_pstate(amdsmi_processor_handle processor_handle,
uint32_t policy_id);
/**
+6 -6
ファイルの表示
@@ -2747,7 +2747,7 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_dpm_policy
### amdsmi_get_soc_pstate
Description: Get dpm policy information.
@@ -2764,7 +2764,7 @@ Field | Description
`current_id` | current policy id
`policies` | list of dictionaries containing possible policies
Exceptions that can be thrown by `amdsmi_get_dpm_policy` function:
Exceptions that can be thrown by `amdsmi_get_soc_pstate` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
@@ -2779,13 +2779,13 @@ try:
print("No GPUs on machine")
else:
for device in devices:
dpm_policies = amdsmi_get_dpm_policy(device)
dpm_policies = amdsmi_get_soc_pstate(device)
print(dpm_policies)
except AmdSmiException as e:
print(e)
```
### amdsmi_set_dpm_policy
### amdsmi_set_soc_pstate
Description: Set the dpm policy to corresponding policy_id. Typically following: 0(default),1,2,3
@@ -2796,7 +2796,7 @@ Input parameters:
Output: None
Exceptions that can be thrown by `amdsmi_set_dpm_policy` function:
Exceptions that can be thrown by `amdsmi_set_soc_pstate` function:
* `AmdSmiLibraryException`
* `AmdSmiRetryException`
@@ -2811,7 +2811,7 @@ try:
print("No GPUs on machine")
else:
for device in devices:
amdsmi_set_dpm_policy(device, 0)
amdsmi_set_soc_pstate(device, 0)
except AmdSmiException as e:
print(e)
```
+1 -1
ファイルの表示
@@ -134,7 +134,7 @@ from .amdsmi_interface import amdsmi_set_gpu_fan_speed
from .amdsmi_interface import amdsmi_reset_gpu_fan
from .amdsmi_interface import amdsmi_set_clk_freq
from .amdsmi_interface import amdsmi_set_gpu_overdrive_level
from .amdsmi_interface import amdsmi_set_dpm_policy
from .amdsmi_interface import amdsmi_set_soc_pstate
from .amdsmi_interface import amdsmi_set_xgmi_plpd
from .amdsmi_interface import amdsmi_set_gpu_clear_sram_data
from .amdsmi_interface import amdsmi_set_gpu_process_isolation
+4 -4
ファイルの表示
@@ -2786,7 +2786,7 @@ def amdsmi_set_clk_freq(
)
def amdsmi_set_dpm_policy(
def amdsmi_set_soc_pstate(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
policy_id: int,
):
@@ -2795,7 +2795,7 @@ def amdsmi_set_dpm_policy(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
_check_res(
amdsmi_wrapper.amdsmi_set_dpm_policy(
amdsmi_wrapper.amdsmi_set_soc_pstate(
processor_handle, policy_id
)
)
@@ -3405,7 +3405,7 @@ def amdsmi_get_clk_freq(
}
def amdsmi_get_dpm_policy(
def amdsmi_get_soc_pstate(
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
) -> Dict[str, Any]:
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
@@ -3415,7 +3415,7 @@ def amdsmi_get_dpm_policy(
policy = amdsmi_wrapper.amdsmi_dpm_policy_t()
_check_res(
amdsmi_wrapper.amdsmi_get_dpm_policy(
amdsmi_wrapper.amdsmi_get_soc_pstate(
processor_handle, ctypes.byref(policy)
)
)
+9 -9
ファイルの表示
@@ -1519,7 +1519,7 @@ struct_amdsmi_dpm_policy_entry_t._fields_ = [
('policy_description', ctypes.c_char * 32),
]
amdsmi_dpm_policy_entry_t = struct_amdsmi_dpm_policy_entry_t
struct_amdsmi_dpm_policy_entry_t = struct_amdsmi_dpm_policy_entry_t
class struct_amdsmi_dpm_policy_t(Structure):
pass
@@ -2082,12 +2082,12 @@ amdsmi_set_gpu_overdrive_level.argtypes = [amdsmi_processor_handle, uint32_t]
amdsmi_set_clk_freq = _libraries['libamd_smi.so'].amdsmi_set_clk_freq
amdsmi_set_clk_freq.restype = amdsmi_status_t
amdsmi_set_clk_freq.argtypes = [amdsmi_processor_handle, amdsmi_clk_type_t, uint64_t]
amdsmi_get_dpm_policy = _libraries['libamd_smi.so'].amdsmi_get_dpm_policy
amdsmi_get_dpm_policy.restype = amdsmi_status_t
amdsmi_get_dpm_policy.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_dpm_policy_t)]
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_soc_pstate = _libraries['libamd_smi.so'].amdsmi_get_soc_pstate
amdsmi_get_soc_pstate.restype = amdsmi_status_t
amdsmi_get_soc_pstate.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_dpm_policy_t)]
amdsmi_set_soc_pstate = _libraries['libamd_smi.so'].amdsmi_set_soc_pstate
amdsmi_set_soc_pstate.restype = amdsmi_status_t
amdsmi_set_soc_pstate.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)]
@@ -2619,7 +2619,7 @@ __all__ = \
'amdsmi_get_cpu_socket_power', 'amdsmi_get_cpu_socket_power_cap',
'amdsmi_get_cpu_socket_power_cap_max',
'amdsmi_get_cpu_socket_temperature', 'amdsmi_get_cpucore_handles',
'amdsmi_get_cpusocket_handles', 'amdsmi_get_dpm_policy',
'amdsmi_get_cpusocket_handles', 'amdsmi_get_soc_pstate',
'amdsmi_get_energy_count', 'amdsmi_get_esmi_err_msg',
'amdsmi_get_fw_info', 'amdsmi_get_gpu_activity',
'amdsmi_get_gpu_asic_info', 'amdsmi_get_gpu_available_counters',
@@ -2703,7 +2703,7 @@ __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_clear_sram_data',
'amdsmi_set_soc_pstate', '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',
+3 -3
ファイルの表示
@@ -3353,7 +3353,7 @@ rsmi_status_t rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind,
*
* @return ::RSMI_STATUS_SUCCESS is returned upon successful call, non-zero on fail
*/
rsmi_status_t rsmi_dev_dpm_policy_get(uint32_t dv_ind,
rsmi_status_t rsmi_dev_soc_pstate_get(uint32_t dv_ind,
rsmi_dpm_policy_t* policy);
/**
@@ -3371,7 +3371,7 @@ rsmi_status_t rsmi_dev_dpm_policy_get(uint32_t dv_ind,
*
* @return ::RSMI_STATUS_SUCCESS is returned upon successful call, non-zero on fail
*/
rsmi_status_t rsmi_dev_dpm_policy_set(uint32_t dv_ind,
rsmi_status_t rsmi_dev_soc_pstate_set(uint32_t dv_ind,
uint32_t policy_id);
/**
@@ -3406,7 +3406,7 @@ rsmi_status_t rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
* @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_soc_pstate_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
+2 -1
ファイルの表示
@@ -101,6 +101,8 @@ enum DevKFDNodePropTypes {
enum DevInfoTypes {
kDevPerfLevel,
kDevSocPstate,
kDevXgmiPlpd,
kDevProcessIsolation,
kDevShaderClean,
kDevOverDriveLevel,
@@ -175,7 +177,6 @@ enum DevInfoTypes {
kDevNumaNode,
kDevGpuMetrics,
kDevPmMetrics,
kDevDPMPolicy,
kDevRegMetrics,
kDevGpuReset,
kDevAvailableComputePartition,
+30 -54
ファイルの表示
@@ -2142,27 +2142,6 @@ rsmi_status_t rsmi_dev_gpu_clear_sram_data(uint32_t dv_ind,
CATCH
}
rsmi_status_t
rsmi_dev_dpm_policy_set(uint32_t dv_ind,
uint32_t policy_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("soc_pstate ");
value += std::to_string(policy_id);
int ret = dev->writeDevInfo(amd::smi::kDevDPMPolicy , value);
return amd::smi::ErrnoToRsmiStatus(ret);
CATCH
}
rsmi_status_t
rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
rsmi_dpm_policy_t* policy) {
@@ -2181,7 +2160,7 @@ rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
LOG_TRACE(ss);
DEVICE_MUTEX
ret = GetDevValueVec(amd::smi::kDevDPMPolicy, dv_ind, &val_vec);
ret = GetDevValueVec(amd::smi::kDevXgmiPlpd, dv_ind, &val_vec);
if (ret == RSMI_STATUS_FILE_ERROR) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", GetDevValueVec() ret was RSMI_STATUS_FILE_ERROR "
@@ -2199,21 +2178,14 @@ rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
/*
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*
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;
@@ -2250,17 +2222,13 @@ rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
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.";
<< ", Unexpected pstat data: cannot find the current xgmi_plpd policy.";
LOG_ERROR(ss);
return RSMI_STATUS_UNEXPECTED_DATA;
}
// Cannot find it
return RSMI_STATUS_SUCCESS;
CATCH
@@ -2279,16 +2247,15 @@ rsmi_dev_xgmi_plpd_set(uint32_t dv_ind,
DEVICE_MUTEX
GET_DEV_FROM_INDX
std::string value("xgmi ");
value += std::to_string(plpd_id);
int ret = dev->writeDevInfo(amd::smi::kDevDPMPolicy , value);
std::string value = std::to_string(plpd_id);
int ret = dev->writeDevInfo(amd::smi::kDevXgmiPlpd , value);
return amd::smi::ErrnoToRsmiStatus(ret);
CATCH
}
rsmi_status_t
rsmi_dev_dpm_policy_get(uint32_t dv_ind,
rsmi_dev_soc_pstate_get(uint32_t dv_ind,
rsmi_dpm_policy_t* policy) {
rsmi_status_t ret;
std::vector<std::string> val_vec;
@@ -2305,7 +2272,7 @@ rsmi_dev_dpm_policy_get(uint32_t dv_ind,
LOG_TRACE(ss);
DEVICE_MUTEX
ret = GetDevValueVec(amd::smi::kDevDPMPolicy, dv_ind, &val_vec);
ret = GetDevValueVec(amd::smi::kDevSocPstate, dv_ind, &val_vec);
if (ret == RSMI_STATUS_FILE_ERROR) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", GetDevValueVec() ret was RSMI_STATUS_FILE_ERROR "
@@ -2323,22 +2290,15 @@ rsmi_dev_dpm_policy_get(uint32_t dv_ind,
/*
It will reply on the number but no string as it may vary from soc to soc.
The current pstate marked with *
soc pstate
0 : soc_pstate_default
1 : soc_pstate_0
2 : soc_pstate_1*
3 : soc_pstate_2
*/
bool see_soc_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 == "soc pstate") {
see_soc_pstate = true;
continue;
}
if (see_soc_pstate == false) continue;
// Get tokens: <integer> : <string *>
std::vector<std::string> tokens;
@@ -2375,10 +2335,6 @@ rsmi_dev_dpm_policy_get(uint32_t dv_ind,
policy->num_supported++;
} // end for
if (!see_soc_pstate) {
return RSMI_STATUS_NOT_SUPPORTED;
}
if (!see_current) {
ss << __PRETTY_FUNCTION__ << " | ======= end ======="
<< ", Unexpected pstat data: cannot find the current policy.";
@@ -2391,6 +2347,26 @@ rsmi_dev_dpm_policy_get(uint32_t dv_ind,
CATCH
}
rsmi_status_t
rsmi_dev_soc_pstate_set(uint32_t dv_ind,
uint32_t policy_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 = std::to_string(policy_id);
int ret = dev->writeDevInfo(amd::smi::kDevSocPstate , value);
return amd::smi::ErrnoToRsmiStatus(ret);
CATCH
}
static std::vector<std::string> pci_name_files = {
"/usr/share/misc/pci.ids",
"/usr/share/hwdata/pci.ids",
+14 -9
ファイルの表示
@@ -82,6 +82,8 @@ static const char *kDevPCieVendorIDFName = "vendor";
// Device sysfs file names
static const char *kDevPerfLevelFName = "power_dpm_force_performance_level";
static const char *kDevSocPstateFName = "pm_policy/soc_pstate";
static const char *kDevXgmiPlpdFName = "pm_policy/xgmi_plpd";
static const char *kDevProcessIsolationFName = "enforce_isolation";
static const char *kDevShaderCleanFName = "run_cleaner_shader";
static const char *kDevDevProdNameFName = "product_name";
@@ -138,7 +140,6 @@ static const char *kDevAvailableComputePartitionFName =
"available_compute_partition";
static const char *kDevComputePartitionFName = "current_compute_partition";
static const char *kDevMemoryPartitionFName = "current_memory_partition";
static const char* kDevDPMPolicyFName = "pm_policy"; // The PM policy for pstat and XGMI
// Firmware version files
static const char *kDevFwVersionAsdFName = "fw_version/asd_fw_version";
@@ -318,7 +319,8 @@ static const std::map<DevInfoTypes, const char *> kDevAttribNameMap = {
{kDevNumaNode, kDevNumaNodeFName},
{kDevGpuMetrics, kDevGpuMetricsFName},
{kDevPmMetrics, kDevPmMetricsFName},
{kDevDPMPolicy, kDevDPMPolicyFName},
{kDevSocPstate, kDevSocPstateFName},
{kDevXgmiPlpd, kDevXgmiPlpdFName},
{kDevProcessIsolation, kDevProcessIsolationFName},
{kDevShaderClean, kDevShaderCleanFName},
{kDevRegMetrics, kDevRegMetricsFName},
@@ -478,7 +480,8 @@ Device::devInfoTypesStrings = {
{kDevComputePartition, "kDevComputePartition"},
{kDevMemoryPartition, "kDevMemoryPartition"},
{kDevPCieVendorID, "kDevPCieVendorID"},
{kDevDPMPolicy, "kDevDPMPolicy"},
{kDevSocPstate, "kDevSocPstate"},
{kDevXgmiPlpd, "kDevXgmiPlpd"},
{kDevProcessIsolation, "kDevProcessIsolation"},
{kDevShaderClean, "kDevShaderClean"},
};
@@ -522,6 +525,10 @@ static const std::map<const char *, dev_depends_t> kDevFuncDependsMap = {
{"rsmi_dev_perf_level_set", {{kDevPerfLevelFName}, {}}},
{"rsmi_dev_perf_level_set_v1", {{kDevPerfLevelFName}, {}}},
{"rsmi_dev_perf_level_get", {{kDevPerfLevelFName}, {}}},
{"rsmi_dev_soc_pstate_set", {{kDevSocPstateFName}, {}}},
{"rsmi_dev_soc_pstate_get", {{kDevSocPstateFName}, {}}},
{"rsmi_dev_xgmi_plpd_set", {{kDevXgmiPlpdFName}, {}}},
{"rsmi_dev_xgmi_plpd_get", {{kDevXgmiPlpdFName}, {}}},
{"rsmi_dev_process_isolation_set", {{kDevProcessIsolationFName}, {}}},
{"rsmi_dev_process_isolation_get", {{kDevProcessIsolationFName}, {}}},
{"rsmi_dev_gpu_shader_clean", {{kDevShaderCleanFName}, {}}},
@@ -545,10 +552,6 @@ 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_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}, {}}},
@@ -948,6 +951,8 @@ int Device::writeDevInfo(DevInfoTypes type, std::string val) {
sysfs_path += kDevAttribNameMap.at(type);
switch (type) {
case kDevGPUMClk:
case kDevSocPstate:
case kDevXgmiPlpd:
case kDevProcessIsolation:
case kDevShaderClean:
case kDevDCEFClk:
@@ -956,7 +961,6 @@ int Device::writeDevInfo(DevInfoTypes type, std::string val) {
case kDevPCIEClk:
case kDevPowerODVoltage:
case kDevSOCClk:
case kDevDPMPolicy:
return writeDevInfoStr(type, val);
case kDevComputePartition:
case kDevMemoryPartition:
@@ -1223,6 +1227,8 @@ int Device::readDevInfo(DevInfoTypes type, std::vector<std::string> *val) {
switch (type) {
case kDevGPUMClk:
case kDevSocPstate:
case kDevXgmiPlpd:
case kDevProcessIsolation:
case kDevGPUSClk:
case kDevDCEFClk:
@@ -1239,7 +1245,6 @@ int Device::readDevInfo(DevInfoTypes type, std::vector<std::string> *val) {
case kDevErrCntHDP:
case kDevErrCntXGMIWAFL:
case kDevMemPageBad:
case kDevDPMPolicy:
return readDevInfoMultiLineStr(type, val);
break;
+4 -4
ファイルの表示
@@ -1409,19 +1409,19 @@ amdsmi_status_t amdsmi_set_clk_freq(amdsmi_processor_handle processor_handle,
static_cast<rsmi_clk_type_t>(clk_type), freq_bitmask);
}
amdsmi_status_t amdsmi_set_dpm_policy(amdsmi_processor_handle processor_handle,
amdsmi_status_t amdsmi_set_soc_pstate(amdsmi_processor_handle processor_handle,
uint32_t policy) {
AMDSMI_CHECK_INIT();
return rsmi_wrapper(rsmi_dev_dpm_policy_set, processor_handle,
return rsmi_wrapper(rsmi_dev_soc_pstate_set, processor_handle,
policy);
}
amdsmi_status_t amdsmi_get_dpm_policy(amdsmi_processor_handle processor_handle,
amdsmi_status_t amdsmi_get_soc_pstate(amdsmi_processor_handle processor_handle,
amdsmi_dpm_policy_t* policy) {
AMDSMI_CHECK_INIT();
return rsmi_wrapper(rsmi_dev_dpm_policy_get, processor_handle,
return rsmi_wrapper(rsmi_dev_soc_pstate_get, processor_handle,
reinterpret_cast<rsmi_dpm_policy_t*>(policy));
}