From f1be0c808aea6b0af0f7ca74d2ab489bd4b5241c Mon Sep 17 00:00:00 2001 From: Melissa Jost Date: Wed, 12 Oct 2022 14:28:17 -0700 Subject: [PATCH] stdlib: Added set_se_simpoint_workload to SEBinaryWorkload Change-Id: I815d4aff655e96619a44fc6fc04b674a794056a2 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64432 Reviewed-by: Melissa Jost Tested-by: kokoro Maintainer: Bobby Bruce --- .../checkpoints/simpoints-se-checkpoint.py | 2 +- .../checkpoints/simpoints-se-restore.py | 6 +- .../components/boards/se_binary_workload.py | 56 ++++++++++++++----- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py index e3b3c4c272..bc30a024eb 100644 --- a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py +++ b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py @@ -116,7 +116,7 @@ simpoint = SimPoint( warmup_interval=1000000, ) -board.set_se_binary_workload( +board.set_se_simpoint_workload( binary=Resource("x86-print-this"), arguments=["print this", 15000], simpoint=simpoint, diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-restore.py b/configs/example/gem5_library/checkpoints/simpoints-se-restore.py index 4d49d9d4e1..82b56b59b9 100644 --- a/configs/example/gem5_library/checkpoints/simpoints-se-restore.py +++ b/configs/example/gem5_library/checkpoints/simpoints-se-restore.py @@ -103,8 +103,10 @@ simpoint = SimPoint( warmup_interval=1000000, ) -board.set_se_binary_workload( - binary=Resource("x86-print-this"), arguments=["print this", 15000] +board.set_se_simpoint_workload( + binary=Resource("x86-print-this"), + arguments=["print this", 15000], + simpoint=simpoint, ) # Here we obtain the checkpoints from gem5 resources, but these are generated diff --git a/src/python/gem5/components/boards/se_binary_workload.py b/src/python/gem5/components/boards/se_binary_workload.py index afd7cefbda..545dc40a39 100644 --- a/src/python/gem5/components/boards/se_binary_workload.py +++ b/src/python/gem5/components/boards/se_binary_workload.py @@ -30,7 +30,7 @@ from gem5.utils.simpoint import SimPoint from m5.objects import SEWorkload, Process -from typing import Optional, List +from typing import Optional, List, Union from m5.util import warn from pathlib import Path @@ -57,7 +57,6 @@ class SEBinaryWorkload: stdout_file: Optional[Path] = None, stderr_file: Optional[Path] = None, arguments: List[str] = [], - simpoint: SimPoint = None, ) -> None: """Set up the system to run a specific binary. @@ -66,16 +65,11 @@ class SEBinaryWorkload: * Dynamically linked executables are partially supported when the host ISA and the simulated ISA are the same. - **Warning:** SimPoints only works with one core - :param binary: The resource encapsulating the binary to be run. :param exit_on_work_items: Whether the simulation should exit on work items. True by default. :param stdin_file: The input file for the binary :param arguments: The input arguments for the binary - :param simpoint: The SimPoint object that contains the list of - SimPoints starting instructions, the list of weights, and the SimPoints - interval """ # We assume this this is in a multiple-inheritance setup with an @@ -102,12 +96,46 @@ class SEBinaryWorkload: for core in self.get_processor().get_cores(): core.set_workload(process) - if simpoint is not None: - if self.get_processor().get_num_cores() > 1: - warn("SimPoints only works with one core") - self.get_processor().get_cores()[0].set_simpoint( - inst_starts=simpoint.get_simpoint_start_insts(), init=True - ) - # Set whether to exit on work items for the se_workload self.exit_on_work_items = exit_on_work_items + + def set_se_simpoint_workload( + self, + binary: AbstractResource, + arguments: List[str] = [], + simpoint: Union[AbstractResource, SimPoint] = None, + ) -> None: + """Set up the system to run a SimPoint workload. + + **Limitations** + * Only supports single threaded applications. + * Dynamically linked executables are partially supported when the host + ISA and the simulated ISA are the same. + + **Warning:** SimPoints only works with one core + + :param binary: The resource encapsulating the binary to be run. + :param arguments: The input arguments for the binary + :param simpoint: The SimPoint object or Resource that contains the list of + SimPoints starting instructions, the list of weights, and the SimPoints + interval + """ + + # convert input to SimPoint if necessary + if isinstance(simpoint, AbstractResource): + simpoint_object = SimPoint(simpoint) + else: + assert isinstance(simpoint, SimPoint) + simpoint_object = simpoint + + if self.get_processor().get_num_cores() > 1: + warn("SimPoints only works with one core") + self.get_processor().get_cores()[0].set_simpoint( + inst_starts=simpoint_object.get_simpoint_start_insts(), init=True + ) + + # Call set_se_binary_workload after SimPoint setup is complete + self.set_se_binary_workload( + binary=binary, + arguments=arguments, + )