Hoa Nguyen has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/58789 )
Change subject: stdlib: Add checkpoint to Simulator
......................................................................
stdlib: Add checkpoint to Simulator
Change-Id: I58b686b6b4f69260ab45709c6ef0bddf4539f0c4
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
---
M src/python/gem5/simulate/simulator.py
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/python/gem5/simulate/simulator.py
b/src/python/gem5/simulate/simulator.py
index 1645dfc..7e5db87 100644
--- a/src/python/gem5/simulate/simulator.py
+++ b/src/python/gem5/simulate/simulator.py
@@ -32,6 +32,7 @@
from m5.util import warn
import os
+from pathlib import Path
from typing import Optional, List, Tuple, Dict, Generator, Union
from .exit_event_generators import (
@@ -76,6 +77,7 @@
Dict[Union[str, ExitEvent], Generator[Optional[bool], None,
None]]
] = None,
expected_execution_order: Optional[List[ExitEvent]] = None,
+ checkpoint_path: Optional[Path] = None,
) -> None:
"""
:param board: The board to be simulated.
@@ -177,6 +179,8 @@
self._last_exit_event = None
self._exit_event_count = 0
+ self._checkpoint_path = checkpoint_path
+
def get_stats(self) -> Dict:
"""
Obtain the current simulation statistics as a Dictionary,
conforming
@@ -277,7 +281,10 @@
m5.ticks.fixGlobalFrequency()
root.sim_quantum = m5.ticks.fromSeconds(0.001)
- m5.instantiate()
+ if self._checkpoint_path:
+ m5.instantiate(self._checkpoint_path)
+ else:
+ m5.instantiate()
self._instantiated = True
def run(self, max_ticks: int = m5.MaxTick) -> None:
@@ -347,3 +354,7 @@
# run loop.
if exit_on_completion:
return
+
+ def save_checkpoint(self, checkpoint_folder: Path) -> None:
+ m5.checkpoint(str(checkpoint_folder))
+
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/58789
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: I58b686b6b4f69260ab45709c6ef0bddf4539f0c4
Gerrit-Change-Number: 58789
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s