From 347e37162758e628f3763f94abc95a24ab689d62 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Mon, 18 Nov 2024 22:54:19 +0000 Subject: [PATCH] Added setting of shield Signed-off-by: Stefan Marr --- rebench/denoise.py | 41 ++++++++++++++++++++++++++++++--------- rebench/denoise_client.py | 5 ++++- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/rebench/denoise.py b/rebench/denoise.py index 7067f224..3d1ea92a 100644 --- a/rebench/denoise.py +++ b/rebench/denoise.py @@ -140,11 +140,14 @@ def _get_core_spec(num_cores) -> str: # pylint: disable-next=too-many-return-statements -def _activate_shielding(num_cores) -> str: +def _activate_shielding(shield, num_cores) -> str: if not num_cores: return "failed: num-cores not set" - core_spec = _get_core_spec(num_cores) + if shield == "basic": + core_spec = _get_core_spec(num_cores) + else: + core_spec = shield if not paths.has_cset(): return "failed: cset-path not set" @@ -182,6 +185,7 @@ def _reset_shielding() -> Union[str, bool]: except CalledProcessError: return "failed: CalledProcessError" +DEFAULT_SHIELD = "basic" # For intel_pstate systems, there's only powersave and performance SCALING_GOVERNOR_POWERSAVE = "powersave" @@ -364,7 +368,8 @@ def _minimize_noise(args) -> dict: result = {} if args.use_shielding: - result["shielding"] = _activate_shielding(num_cores) + shield = args.shield or DEFAULT_SHIELD + result["shielding"] = _activate_shielding(shield, num_cores) if args.use_no_turbo: r = _set_no_turbo(True) @@ -501,6 +506,14 @@ def _shell_options(): dest="use_shielding", help="Don't try shielding cores", ) + parser.add_argument( + "-s", + "--shield", + action="store", + default=None, + dest="shield", + help=f"Shielding specification. Default is '{DEFAULT_SHIELD}'.", + ) parser.add_argument( "-T", "--without-no-turbo", @@ -635,18 +648,28 @@ def _any_failed(result: dict): return any(str(v).startswith("failed") for v in result.values()) +def _check_for_inconsistent_settings(args): + if args.use_shielding is False and args.shield is not None: + print( + "Error: -s|--shield can only be set " + "when -S|--without-shielding is not set." + ) + sys.exit(EXIT_CODE_INVALID_SETTINGS) + + if args.use_scaling_governor is False and args.scaling_governor is not None: + print( + "Error: -g|--governor can only be set " + "when -G|--without-scaling-governor is not set." + ) + sys.exit(EXIT_CODE_INVALID_SETTINGS) + def main_func(): arg_parser = _shell_options() args, remaining_args = arg_parser.parse_known_args() paths.set_cset(args.cset_path) - if args.use_scaling_governor is False and args.scaling_governor is not None: - print( - "Error: Option -g|--governor can only be set " - "when --without-scaling-governor is not set." - ) - return EXIT_CODE_INVALID_SETTINGS + _check_for_inconsistent_settings(args) result = {} diff --git a/rebench/denoise_client.py b/rebench/denoise_client.py index 50809ee3..06a94136 100644 --- a/rebench/denoise_client.py +++ b/rebench/denoise_client.py @@ -6,7 +6,7 @@ from typing import Optional, Tuple from cpuinfo import get_cpu_info -from .denoise import paths, DEFAULT_SCALING_GOVERNOR +from .denoise import paths, DEFAULT_SCALING_GOVERNOR, DEFAULT_SHIELD from .model.denoise import Denoise from .output import output_as_str from .ui import escape_braces @@ -118,6 +118,9 @@ def _add_denoise_options(cmd: list[str], requested: Denoise): options_to_disable += "N" if not requested.requested_shield: options_to_disable += "S" + elif requested.shield != DEFAULT_SHIELD: + cmd.append("-s") + cmd.append(requested.shield) if not requested.requested_scaling_governor: options_to_disable += "G" elif requested.scaling_governor != DEFAULT_SCALING_GOVERNOR: