From 82c587bd8834fb0700414cb6d81e76f46d588d8f Mon Sep 17 00:00:00 2001 From: Zhantong Qiu Date: Fri, 6 Jan 2023 17:25:26 -0800 Subject: [PATCH] stdlib: Allow se_binary_workload to setup LoopPoints Added a set_se_looppoint_workload function to take in information for workload and a stdlib LoopPoint object that stores all the information the workload needed to run the LoopPoint sampling method. Added a get_looppoint function to return the stdlib LoopPoint object. Change-Id: I7afc5c4c743256f7df97345f331b6f72b7a5fd07 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67196 Maintainer: Bobby Bruce Reviewed-by: Bobby Bruce Tested-by: kokoro --- .../components/boards/se_binary_workload.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/python/gem5/components/boards/se_binary_workload.py b/src/python/gem5/components/boards/se_binary_workload.py index 31931106c9..404a78458f 100644 --- a/src/python/gem5/components/boards/se_binary_workload.py +++ b/src/python/gem5/components/boards/se_binary_workload.py @@ -25,6 +25,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from .abstract_board import AbstractBoard + from ...resources.resource import ( FileResource, AbstractResource, @@ -34,6 +35,8 @@ from ...resources.resource import ( SimpointDirectoryResource, ) +from gem5.utils.looppoint import LoopPoint + from m5.objects import SEWorkload, Process from typing import Optional, List, Union @@ -170,3 +173,47 @@ class SEBinaryWorkload: if getattr(self, "_simpoint_resource", None): return self._simpoint_resource raise Exception("This board does not have a simpoint set.") + + def set_se_looppoint_workload( + self, + binary: AbstractResource, + arguments: List[str] = [], + looppoint: Optional[Union[AbstractResource, LoopPoint]] = None, + checkpoint: Optional[Union[Path, AbstractResource]] = None, + ) -> None: + """Set up the system to run a LoopPoint workload. + + **Limitations** + * Dynamically linked executables are partially supported when the host + ISA and the simulated ISA are the same. + + :param binary: The resource encapsulating the binary to be run. + :param arguments: The input arguments for the binary + :param looppoint: The LoopPoint object that contain all the information + gather from the LoopPoint files and a LoopPointManager that will raise + exit events for LoopPoints + """ + + if isinstance(looppoint, AbstractResource): + self._looppoint_object = LoopPoint(looppoint) + else: + assert isinstance(looppoint, LoopPoint) + self._looppoint_object = looppoint + + self._looppoint_object.setup_processor(self.get_processor()) + + # Call set_se_binary_workload after LoopPoint setup is complete + self.set_se_binary_workload( + binary=binary, + arguments=arguments, + checkpoint=checkpoint, + ) + + def get_looppoint(self) -> LoopPoint: + """ + Returns the LoopPoint object set. If no LoopPoint object has been set + an exception is thrown. + """ + if getattr(self, "_looppoint_object", None): + return self._looppoint_object + raise Exception("This board does not have a looppoint set.")