From 02a01747bd880c9c837c74e3bd09b91374ca9b27 Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 1 Jun 2022 21:16:50 +0800 Subject: [PATCH] Disable clock and voltage range reading/displaying when pp_od_clk_voltage reading is not possible --- GPUmodules/GPUmodule.py | 24 +++++++++++++++--------- README.md | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/GPUmodules/GPUmodule.py b/GPUmodules/GPUmodule.py index 2740a3d..57e0f1b 100755 --- a/GPUmodules/GPUmodule.py +++ b/GPUmodules/GPUmodule.py @@ -709,18 +709,20 @@ def param_is_active(self, parameter_name: str) -> bool: if parameter_name in self.read_skip: return False return True - def disable_param_read(self, parameter_name: str) -> None: + def disable_param_read(self, parameter_name: Union[Tuple[str, ...], str, None]) -> None: """ Disable further reading of the specified parameter. - :param parameter_name: + :param parameter_name: A single parameter name to be disabled. :return: """ - if self.param_is_active(parameter_name): - message = 'Warning: Can not read parameter: {}, ' \ - 'disabling for this GPU: {}'.format(parameter_name, self.prm.card_num) - env.GUT_CONST.process_message(message, log_flag=True) - self.read_disabled.append(parameter_name) + if isinstance(parameter_name, str): parameter_name = (parameter_name, ) + for target_param in parameter_name: + if self.param_is_active(target_param): + message = 'Warning: Can not read parameter: {}, ' \ + 'disabling for this GPU: {}'.format(target_param, self.prm.card_num) + env.GUT_CONST.process_message(message, log_flag=True) + self.read_disabled.append(target_param) def get_params_value(self, name: str, num_as_int: bool = False) -> Union[int, float, str, list, None, datetime]: """ @@ -2177,7 +2179,8 @@ def set_gpu_list(self, clinfo_flag: bool = False) -> bool: pp_od_file_details = file_ptr.read() except OSError as except_err: pp_od_file_details = '{} not readable'.format(pp_od_clk_voltage_file) - self[gpu_uuid].disable_param_read('pp_od_clk_voltage') + self[gpu_uuid].disable_param_read(('pp_od_clk_voltage', 'sclk_f_range', + 'mclk_f_range', 'vddc_range')) message = 'Error: system support issue for {}: [{}]'.format(pcie_id, except_err) LOGGER.debug(message) print(message) @@ -2186,7 +2189,8 @@ def set_gpu_list(self, clinfo_flag: bool = False) -> bool: else: LOGGER.debug('%s exists, opened, and read.', pp_od_clk_voltage_file) if not pp_od_file_details: - self[gpu_uuid].disable_param_read('pp_od_clk_voltage') + self[gpu_uuid].disable_param_read(('pp_od_clk_voltage', 'sclk_f_range', + 'mclk_f_range', 'vddc_range')) LOGGER.debug('%s exists, but empty on read.', pp_od_clk_voltage_file) gpu_type = GpuItem.GPU_Type.Unsupported readable = True @@ -2214,6 +2218,8 @@ def set_gpu_list(self, clinfo_flag: bool = False) -> bool: gpu_type = GpuItem.GPU_Type.Legacy if not os.path.isfile(pp_od_clk_voltage_file): + self[gpu_uuid].disable_param_read(('pp_od_clk_voltage', 'sclk_f_range', + 'mclk_f_range', 'vddc_range')) LOGGER.debug('%s file does not exist', pp_od_clk_voltage_file) # Set GPU parameters diff --git a/README.md b/README.md index da2156b..85a9c86 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ parameters to be written to the GPU. The default behavior is to only write chan * Fixed placement of read pstate data in *gpu-ls* for complete P-state details in the output. * Improved implementation of Vddc Range for CurvePts type AMD GPU. * Optimized by GPU type skip lists. +* Disable clock and voltage range reading/displaying when pp_od_clk_voltage reading is not possible. ## Development Plans