stdlib,configs: Update simpoint example to use the Workload
With the inclusion of the "x86-print-this-15000-with-simpoints"
workloads (introduced here:
https://gem5-review.googlesource.com/c/public/gem5-resources/+/64531)
This patch utilizes this workload for the simpoint examples.
Change-Id: I5e2c4a48206fd7108a33a4a64ac64235ea9f1f33
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64552
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
index bc30a02..d2d1af7 100644
--- a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
+++ b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
@@ -25,15 +25,10 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
-This configuation script shows an example of how to take checkpoints for
-SimPoints using the gem5 stdlib. SimPoints, SimPoints interval length,
-SimPoints weights, and the warmup instruction length are passed into the gem5
-SimPoint module. The gem5 SimPoint module will calculate where to take
-checkpoints based of the SimPoints, SimPoints interval length, and the warmup
-instruction length. In SE mode, when you pass in a SimPoint object to the
-set_se_binary_workload, it will schedule exit events for SimPoints in the init
-stage of the core. With the Simulator module and the exit event generator,
-checkpoints will be taken for the SimPoints.
+This configuration script shows an example of how to take checkpoints for
+SimPoints using the gem5 stdlib. Simpoints are set via a Workload and the
+gem5 SimPoint module will calculate where to take checkpoints based of the
+SimPoints, SimPoints interval length, and the warmup instruction length.
This scipt builds a simple board with the gem5 stdlib with no cache and a
simple memory structure to take checkpoints. Some of the components, such as
@@ -53,6 +48,7 @@
"""
import argparse
+
from gem5.simulate.exit_event import ExitEvent
from gem5.simulate.simulator import Simulator
from gem5.utils.requires import requires
@@ -61,15 +57,20 @@
from gem5.components.processors.simple_processor import SimpleProcessor
from gem5.components.processors.cpu_types import CPUTypes
from gem5.isas import ISA
-from gem5.resources.resource import Resource
+from gem5.resources.workload import Workload
from pathlib import Path
from gem5.components.cachehierarchies.classic.no_cache import NoCache
-from gem5.utils.simpoint import SimPoint
from gem5.simulate.exit_event_generators import (
save_checkpoint_generator,
)
-parser = argparse.ArgumentParser()
+requires(isa_required=ISA.X86)
+
+parser = argparse.ArgumentParser(
+ description="An example simpoint workload file path"
+)
+
+# The lone arguments is a file path to a directory to store the checkpoints.
parser.add_argument(
"--checkpoint-path",
@@ -81,8 +82,6 @@
args = parser.parse_args()
-requires(isa_required=ISA.X86)
-
# When taking a checkpoint, the cache state is not saved, so the cache
# hierarchy can be changed completely when restoring from a checkpoint.
# By using NoCache() to take checkpoints, it can slightly improve the
@@ -109,18 +108,7 @@
cache_hierarchy=cache_hierarchy,
)
-simpoint = SimPoint(
- simpoint_list=[2, 3, 5, 15],
- weight_list=[0.1, 0.2, 0.4, 0.3],
- simpoint_interval=1000000,
- warmup_interval=1000000,
-)
-
-board.set_se_simpoint_workload(
- binary=Resource("x86-print-this"),
- arguments=["print this", 15000],
- simpoint=simpoint,
-)
+board.set_workload(Workload("x86-print-this-15000-with-simpoints"))
dir = Path(args.checkpoint_path)
dir.mkdir(exist_ok=True)
diff --git a/configs/example/gem5_library/checkpoints/simpoints-se-restore.py b/configs/example/gem5_library/checkpoints/simpoints-se-restore.py
index aacddd7..decf9ea 100644
--- a/configs/example/gem5_library/checkpoints/simpoints-se-restore.py
+++ b/configs/example/gem5_library/checkpoints/simpoints-se-restore.py
@@ -25,17 +25,17 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
-This configuation script shows an example of how to restore a checkpoint that
+This configuration script shows an example of how to restore a checkpoint that
was taken for SimPoints in the
configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py.
The SimPoints, SimPoints interval length, and the warmup instruction length
are passed into the SimPoint module, so the SimPoint object will store and
calculate the warmup instruction length for each SimPoints based on the
-avaliable instructions before reaching the start of the SimPoint. With the
+available instructions before reaching the start of the SimPoint. With the
Simulator module, exit event will be generated to stop when the warmup session
ends and the SimPoints interval ends.
-This scipt builds a more complex board than the board used for taking
+This script builds a more complex board than the board used for taking
checkpoint.
Usage
@@ -49,9 +49,9 @@
./build/X86/gem5.opt \
configs/example/gem5_library/checkpoints/simpoints-se-restore.py
```
+
"""
-import imp
from gem5.simulate.exit_event import ExitEvent
from gem5.simulate.simulator import Simulator
from gem5.utils.requires import requires
@@ -64,8 +64,8 @@
from gem5.components.processors.cpu_types import CPUTypes
from gem5.isas import ISA
from gem5.resources.resource import Resource
+from gem5.resources.workload import Workload
-from gem5.utils.simpoint import SimPoint
from pathlib import Path
from m5.stats import reset, dump
@@ -96,18 +96,7 @@
cache_hierarchy=cache_hierarchy,
)
-simpoint = SimPoint(
- simpoint_list=[2, 3, 5, 15],
- weight_list=[0.1, 0.2, 0.4, 0.3],
- simpoint_interval=1000000,
- warmup_interval=1000000,
-)
-
-board.set_se_simpoint_workload(
- binary=Resource("x86-print-this"),
- arguments=["print this", 15000],
- simpoint=simpoint,
-)
+board.set_workload(Workload("x86-print-this-15000-with-simpoints"))
# Here we obtain the checkpoints from gem5 resources, but these are generated
# from `configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py`.If
diff --git a/src/python/gem5/utils/simpoint.py b/src/python/gem5/utils/simpoint.py
index 11d1087..9e861cc 100644
--- a/src/python/gem5/utils/simpoint.py
+++ b/src/python/gem5/utils/simpoint.py
@@ -27,6 +27,7 @@
from m5.util import fatal
from pathlib import Path
from typing import List, Tuple
+from gem5.resources.resource import Resource, CustomResource
class SimPoint:
@@ -38,7 +39,8 @@
def __init__(
self,
- simpoint_interval: int,
+ simpoint_resource: CustomResource = None,
+ simpoint_interval: int = None,
simpoint_file_path: Path = None,
weight_file_path: Path = None,
simpoint_list: List[int] = None,
@@ -67,6 +69,24 @@
(sorted by SimPoints in ascending order) is strongly suggested.
The warmup_list only works correctly with sorted simpoint_list.
"""
+
+ # initalize input if you're passing in a CustomResource
+ if simpoint_resource is not None:
+ simpoint_directory = str(simpoint_resource.get_local_path())
+
+ simpoint_file_path = Path(simpoint_directory + "/simpoint.simpt")
+ weight_file_path = Path(simpoint_directory + "/simpoint.weight")
+ simpoint_interval = (
+ simpoint_resource.get_metadata()
+ .get("additional_metadata")
+ .get("simpoint_interval")
+ )
+ warmup_interval = (
+ simpoint_resource.get_metadata()
+ .get("additional_metadata")
+ .get("warmup_interval")
+ )
+
self._simpoint_interval = simpoint_interval
if simpoint_file_path is None or weight_file_path is None: