|
64 | 64 | BenchmarkResults, BenchmarkRun,
|
65 | 65 | execute_cmd,
|
66 | 66 | execute_cmd_and_get_output,
|
| 67 | + get_android_device_model, |
67 | 68 | IREE_PRETTY_NAMES_TO_DRIVERS)
|
68 | 69 |
|
69 | 70 | # All benchmarks' relative path against root build directory.
|
@@ -547,12 +548,25 @@ def filter_and_run_benchmarks(
|
547 | 548 | return (benchmark_files, captures, errors)
|
548 | 549 |
|
549 | 550 |
|
550 |
| -def set_frequency_scaling_governor(governor: str): |
| 551 | +def set_cpu_frequency_scaling_governor(governor: str): |
551 | 552 | git_root = execute_cmd_and_get_output(["git", "rev-parse", "--show-toplevel"])
|
552 | 553 | cpu_script = os.path.join(
|
553 | 554 | git_root, "build_tools/benchmarks/set_android_scaling_governor.sh")
|
554 |
| - adb_push_to_tmp_dir(cpu_script) |
555 |
| - adb_execute(["su", "root", "./set_android_scaling_governor.sh", governor]) |
| 555 | + android_path = adb_push_to_tmp_dir(cpu_script) |
| 556 | + adb_execute(["su", "root", android_path, governor]) |
| 557 | + |
| 558 | + |
| 559 | +def set_gpu_frequency_scaling_policy(policy: str): |
| 560 | + git_root = execute_cmd_and_get_output(["git", "rev-parse", "--show-toplevel"]) |
| 561 | + device_model = get_android_device_model() |
| 562 | + if device_model == "Pixel-6": |
| 563 | + gpu_script = os.path.join( |
| 564 | + git_root, "build_tools/benchmarks/set_pixel6_gpu_scaling_policy.sh") |
| 565 | + else: |
| 566 | + raise RuntimeError( |
| 567 | + f"Unsupported device '{device_model}' for setting GPU scaling policy") |
| 568 | + android_path = adb_push_to_tmp_dir(gpu_script) |
| 569 | + adb_execute(["su", "root", android_path, policy]) |
556 | 570 |
|
557 | 571 |
|
558 | 572 | def parse_arguments():
|
@@ -617,6 +631,10 @@ def check_exe_path(path):
|
617 | 631 | "--pin_cpu_freq",
|
618 | 632 | action="store_true",
|
619 | 633 | help="Pin CPU frequency for all cores to the maximum. Requires root")
|
| 634 | + parser.add_argument("--pin-gpu-freq", |
| 635 | + "--pin_gpu_freq", |
| 636 | + action="store_true", |
| 637 | + help="Pin GPU frequency to the maximum. Requires root") |
620 | 638 | parser.add_argument(
|
621 | 639 | "--keep_going",
|
622 | 640 | "--keep-going",
|
@@ -658,8 +676,11 @@ def main(args):
|
658 | 676 | "need to update the map")
|
659 | 677 |
|
660 | 678 | if args.pin_cpu_freq:
|
661 |
| - set_frequency_scaling_governor("performance") |
662 |
| - atexit.register(set_frequency_scaling_governor, "schedutil") |
| 679 | + set_cpu_frequency_scaling_governor("performance") |
| 680 | + atexit.register(set_cpu_frequency_scaling_governor, "schedutil") |
| 681 | + if args.pin_gpu_freq: |
| 682 | + set_gpu_frequency_scaling_policy("always_on") |
| 683 | + atexit.register(set_gpu_frequency_scaling_policy, "coarse_demand") |
663 | 684 |
|
664 | 685 | previous_benchmarks = None
|
665 | 686 | previous_captures = None
|
|
0 commit comments