Skip to content

Commit

Permalink
Added setting of shield
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Nov 18, 2024
1 parent ae418f1 commit 347e371
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
41 changes: 32 additions & 9 deletions rebench/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 = {}

Expand Down
5 changes: 4 additions & 1 deletion rebench/denoise_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 347e371

Please sign in to comment.