From e90bd5feb9a7d6672b231190783433bf3f7d6706 Mon Sep 17 00:00:00 2001 From: Richard Cooper Date: Thu, 6 Apr 2023 11:41:06 +0100 Subject: [PATCH] configs: Add `--with-pmu` option to the simple Arm FS configs Add an option to add a PMU to the CPUs in `starter_fs.py` and `baremetal.py`. By default PMUs will not be added. Also adds an `--arm-ppi-number` option. Each PMU will be connected to its core using the specified PPI. Change-Id: I9cfb5781f211338919550f2320a7133d88801f6a Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69957 Tested-by: kokoro Reviewed-by: Jason Lowe-Power Maintainer: Bobby Bruce --- configs/example/arm/baremetal.py | 26 ++++++++++++++++++++++++++ configs/example/arm/starter_fs.py | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/configs/example/arm/baremetal.py b/configs/example/arm/baremetal.py index 8ffd2b48e0..be72ebec4c 100644 --- a/configs/example/arm/baremetal.py +++ b/configs/example/arm/baremetal.py @@ -157,6 +157,11 @@ def create(args): workload_class = workloads.workload_list.get(args.workload) system.workload = workload_class(object_file, system) + if args.with_pmu: + for cluster in system.cpu_cluster: + interrupt_numbers = [args.pmu_ppi_number] * len(cluster) + cluster.addPMUs(interrupt_numbers) + if args.exit_on_uart_eot: for uart in system.realview.uart: uart.end_on_eot = True @@ -182,6 +187,15 @@ def run(args): break +def arm_ppi_arg(int_num: int) -> int: + """Argparse argument parser for valid Arm PPI numbers.""" + # PPIs (1056 <= int_num <= 1119) are not yet supported by gem5 + int_num = int(int_num) + if 16 <= int_num <= 31: + return int_num + raise ValueError(f"{int_num} is not a valid Arm PPI number") + + def main(): parser = argparse.ArgumentParser(epilog=__doc__) @@ -257,6 +271,18 @@ def main(): default="stdoutput", help="Destination for the Tarmac trace output. [Default: stdoutput]", ) + parser.add_argument( + "--with-pmu", + action="store_true", + help="Add a PMU to each core in the cluster.", + ) + parser.add_argument( + "--pmu-ppi-number", + type=arm_ppi_arg, + default=23, + help="The number of the PPI to use to connect each PMU to its core. " + "Must be an integer and a valid PPI number (16 <= int_num <= 31).", + ) parser.add_argument( "--exit-on-uart-eot", action="store_true", diff --git a/configs/example/arm/starter_fs.py b/configs/example/arm/starter_fs.py index ebed18864d..07280bd204 100644 --- a/configs/example/arm/starter_fs.py +++ b/configs/example/arm/starter_fs.py @@ -177,6 +177,11 @@ def create(args): ] system.workload.command_line = " ".join(kernel_cmd) + if args.with_pmu: + for cluster in system.cpu_cluster: + interrupt_numbers = [args.pmu_ppi_number] * len(cluster) + cluster.addPMUs(interrupt_numbers) + return system @@ -198,6 +203,15 @@ def run(args): break +def arm_ppi_arg(int_num: int) -> int: + """Argparse argument parser for valid Arm PPI numbers.""" + # PPIs (1056 <= int_num <= 1119) are not yet supported by gem5 + int_num = int(int_num) + if 16 <= int_num <= 31: + return int_num + raise ValueError(f"{int_num} is not a valid Arm PPI number") + + def main(): parser = argparse.ArgumentParser(epilog=__doc__) @@ -272,6 +286,18 @@ def main(): default="stdoutput", help="Destination for the Tarmac trace output. [Default: stdoutput]", ) + parser.add_argument( + "--with-pmu", + action="store_true", + help="Add a PMU to each core in the cluster.", + ) + parser.add_argument( + "--pmu-ppi-number", + type=arm_ppi_arg, + default=23, + help="The number of the PPI to use to connect each PMU to its core. " + "Must be an integer and a valid PPI number (16 <= int_num <= 31).", + ) parser.add_argument("--checkpoint", action="store_true") parser.add_argument("--restore", type=str, default=None)