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 <mkjost@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
index e3b3c4c..bc30a02 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 @@
     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 4d49d9d..82b56b5 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 @@
     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 afd7cef..545dc40 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 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 @@
         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 @@
         * 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 @@
         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,
+        )