Zhantong Qiu has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/67197?usp=email )

Change subject: stdlib: Added LoopPoint checkpoint specific generator
......................................................................

stdlib: Added LoopPoint checkpoint specific generator

Added looppoint_save_checkpoint_generator to take checkpoints for
LoopPoint methodology.
Users can decide to update the relative counts storing in the LoopPoint
module and exit when all the target PC-count pairs are encountered or
not.

Change-Id: Id1cf1516f4fa838e20a67530e94b361e42ca09f3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67197
Reviewed-by: Bobby Bruce <bbr...@ucdavis.edu>
Maintainer: Bobby Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/python/gem5/simulate/exit_event_generators.py
1 file changed, 63 insertions(+), 0 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/gem5/simulate/exit_event_generators.py b/src/python/gem5/simulate/exit_event_generators.py
index 738e128..82eba17 100644
--- a/src/python/gem5/simulate/exit_event_generators.py
+++ b/src/python/gem5/simulate/exit_event_generators.py
@@ -29,6 +29,7 @@
 from ..components.processors.abstract_processor import AbstractProcessor
from ..components.processors.switchable_processor import SwitchableProcessor
 from ..resources.resource import SimpointResource
+from gem5.utils.looppoint import LoopPoint
 from m5.util import warn
 from pathlib import Path

@@ -167,3 +168,46 @@
             yield False
         else:
             yield True
+
+
+def looppoint_save_checkpoint_generator(
+    checkpoint_dir: Path,
+    looppoint: LoopPoint,
+    update_relatives: bool = True,
+    exit_when_empty: bool = True,
+):
+    """
+    A generator for taking a checkpoint for LoopPoint. It will save the
+    checkpoints in the checkpoint_dir path with the Region id.
+    (i.e. "cpt.Region10) It only takes a checkpoint if the current PC Count
+ pair is a significant PC Count Pair. This is determined in the LoopPoint
+    module. The simulation loop continues after exiting this generator.
+    :param checkpoint_dir: where to save the checkpoints
+    :param loopoint: the looppoint object used in the configuration script
+ :param update_relative: if the generator should update the relative count + information in the output json file, then it should be True. It is default
+    as True.
+ :param exit_when_empty: if the generator should exit the simulation loop if + all PC paris have been discovered, then it should be True. It is default as
+    True.
+    """
+    if exit_when_empty:
+        total_pairs = len(looppoint.get_targets())
+    else:
+        total_pairs = -1
+        # it will never equal to 0 if exit_when_empty is false
+
+    while total_pairs != 0:
+        region = looppoint.get_current_region()
+ # if it is a significant PC Count pair, then the get_current_region() + # will return an integer greater than 0. By significant PC Count pair,
+        # it means the PC Count pair that indicates where to take the
+        # checkpoint at. This is determined in the LoopPoint module.
+        if region != -1:
+            if update_relatives:
+                looppoint.update_relatives_counts()
+ m5.checkpoint((checkpoint_dir / f"cpt.Region{region}").as_posix())
+        total_pairs -= 1
+        yield False
+
+    yield True

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/67197?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: Id1cf1516f4fa838e20a67530e94b361e42ca09f3
Gerrit-Change-Number: 67197
Gerrit-PatchSet: 16
Gerrit-Owner: Zhantong Qiu <zt...@ucdavis.edu>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Zhantong Qiu <zt...@ucdavis.edu>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to