Skip to content

Commit

Permalink
Add support for explicitly request a specific scaling governor
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 5f46f38 commit 2b2e637
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
32 changes: 25 additions & 7 deletions rebench/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def _reset_shielding() -> Union[str, bool]:
# For intel_pstate systems, there's only powersave and performance
SCALING_GOVERNOR_POWERSAVE = "powersave"
SCALING_GOVERNOR_PERFORMANCE = "performance"
DEFAULT_SCALING_GOVERNOR = SCALING_GOVERNOR_PERFORMANCE


def _read_scaling_governor() -> Optional[str]:
Expand All @@ -201,10 +202,12 @@ def _read_scaling_governor() -> Optional[str]:


def _set_scaling_governor(governor, num_cores) -> str:
assert governor in (SCALING_GOVERNOR_POWERSAVE, SCALING_GOVERNOR_PERFORMANCE), (
"The scaling governor is expected to be 'performance' or 'powersave', but was "
+ governor
)
if governor not in (SCALING_GOVERNOR_POWERSAVE, SCALING_GOVERNOR_PERFORMANCE):
print(
"The scaling governor is expected to be 'performance' or 'powersave', but was "
+ governor
)
sys.exit(EXIT_CODE_INVALID_SETTINGS)

if not num_cores:
return "failed: num-cores not set"
Expand Down Expand Up @@ -368,9 +371,8 @@ def _minimize_noise(args) -> dict:
result["no_turbo"] = "succeeded" if r is True else r

if args.use_scaling_governor:
result["scaling_governor"] = _set_scaling_governor(
SCALING_GOVERNOR_PERFORMANCE, num_cores
)
scaling_governor = args.scaling_governor or DEFAULT_SCALING_GOVERNOR
result["scaling_governor"] = _set_scaling_governor(scaling_governor, num_cores)

if args.use_mini_perf_sampling:
r = _configure_perf_sampling(args.for_profiling)
Expand Down Expand Up @@ -515,6 +517,14 @@ def _shell_options():
dest="use_scaling_governor",
help="Don't try setting scaling governor",
)
parser.add_argument(
"-g",
"--governor",
action="store",
default=None,
dest="scaling_governor",
help=f"Scaling Governor to set. Default value is '{DEFAULT_SCALING_GOVERNOR}'.",
)
parser.add_argument(
"-P",
"--without-min-perf-sampling",
Expand Down Expand Up @@ -564,6 +574,7 @@ def _shell_options():
EXIT_CODE_NUM_CORES_UNSET = 2
EXIT_CODE_NO_COMMAND_SELECTED = 3
EXIT_CODE_EXEC_FAILED = 4
EXIT_CODE_INVALID_SETTINGS = 5


def _report_init(result: dict, args):
Expand Down Expand Up @@ -630,6 +641,13 @@ def main_func():

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

result = {}

if args.command == "init":
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
from .denoise import paths, DEFAULT_SCALING_GOVERNOR
from .model.denoise import Denoise
from .output import output_as_str
from .ui import escape_braces
Expand Down Expand Up @@ -120,6 +120,9 @@ def _add_denoise_options(cmd: list[str], requested: Denoise):
options_to_disable += "S"
if not requested.requested_scaling_governor:
options_to_disable += "G"
elif requested.scaling_governor != DEFAULT_SCALING_GOVERNOR:
cmd.append("-g")
cmd.append(requested.scaling_governor)
if not requested.requested_no_turbo:
options_to_disable += "T"
if not requested.requested_minimize_perf_sampling:
Expand Down

0 comments on commit 2b2e637

Please sign in to comment.