Melissa Jost has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/64178?usp=email )
Change subject: WIP: Changed SimPoint class to accept CustomResources in
constructor
......................................................................
WIP: Changed SimPoint class to accept CustomResources in constructor
Change-Id: If8a382f2bdf5b0e73582d40376014b351c4caf4e
---
M configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
M src/python/gem5/utils/simpoint.py
2 files changed, 74 insertions(+), 22 deletions(-)
diff --git
a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
index e3b3c4c..3eeecfd 100644
--- a/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
+++ b/configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py
@@ -25,18 +25,18 @@
# 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
+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,
+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 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
+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
cache hierarchy, can be changed when restoring checkpoints.
Usage
@@ -50,9 +50,22 @@
./build/X86/gem5.opt \
configs/example/gem5_library/checkpoints/simpoints-se-restore.py
```
+If passing in a CustomResource, make sure the files in the directory
+you pass in are called simpoint.txt for SimPoint list, and weight.txt
+for the weight list.
+
+To pass the file path on the command line, run:
+```
+scons build/X86/gem5.opt
+./build/X86/gem5.opt \
+ configs/example/gem5_library/checkpoints/simpoints-se-checkpoint.py \
+ --simpoint [path to directory containing simpoint.txt and weight.txt]
+```
"""
import argparse
+import os
+
from gem5.simulate.exit_event import ExitEvent
from gem5.simulate.simulator import Simulator
from gem5.utils.requires import requires
@@ -61,7 +74,7 @@
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.resource import Resource, CustomResource
from pathlib import Path
from gem5.components.cachehierarchies.classic.no_cache import NoCache
from gem5.utils.simpoint import SimPoint
@@ -69,19 +82,33 @@
save_checkpoint_generator,
)
-parser = argparse.ArgumentParser()
+requires(isa_required=ISA.X86)
+
+parser = argparse.ArgumentParser(
+ description="An example simpoint workload file path"
+)
+
+# The arguments accepted are: a. file path to a directory containing
+# simpoint_list and weight_list
parser.add_argument(
- "--checkpoint-path",
+ "--simpoint",
type=str,
- required=False,
- default="se_checkpoint_folder/",
- help="The directory to store the checkpoint.",
+ required=True,
+ help="Input the full path to the simpoint directory",
)
args = parser.parse_args()
-requires(isa_required=ISA.X86)
+# We expect the user to input the full path to the simpoint directory.
+if args.simpoint[0] != "/":
+ # We need to get the absolute path to this file. We assume that the
file is
+ # present on the current working directory.
+ args.simpoint = os.path.abspath(args.simpoint)
+
+if not os.path.exists(args.simpoint):
+ warn("Simpoint file path not found!")
+ fatal("The simpoint is not found at {}".format(args.simpoint))
# When taking a checkpoint, the cache state is not saved, so the cache
# hierarchy can be changed completely when restoring from a checkpoint.
@@ -109,11 +136,15 @@
cache_hierarchy=cache_hierarchy,
)
+# simpoint list, weight list, plus metadata
+resourceOne = CustomResource(
+ args.simpoint,
+ {"additional_metadata": {"simpoint_interval":
1000000, "warmup_interval": 1000000}}
+)
+
+# make a path to a directory with two files, only use one resource
simpoint = SimPoint(
- simpoint_list=[2, 3, 5, 15],
- weight_list=[0.1, 0.2, 0.4, 0.3],
- simpoint_interval=1000000,
- warmup_interval=1000000,
+ simpoint_resource = resourceOne,
)
board.set_se_binary_workload(
@@ -122,7 +153,7 @@
simpoint=simpoint,
)
-dir = Path(args.checkpoint_path)
+dir = Path("se_checkpoint_folder/")
dir.mkdir(exist_ok=True)
simulator = Simulator(
diff --git a/src/python/gem5/utils/simpoint.py
b/src/python/gem5/utils/simpoint.py
index 9e50b2a..bef0b44 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,16 @@
(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.txt")
+ weight_file_path = Path(simpoint_directory + "/weight.txt")
+ 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:
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/64178?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: If8a382f2bdf5b0e73582d40376014b351c4caf4e
Gerrit-Change-Number: 64178
Gerrit-PatchSet: 1
Gerrit-Owner: Melissa Jost <melissakj...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org