gem5-dev@gem5.org

The gem5 Developer List

View all threads

[S] Change in gem5/gem5[develop]: stdlib: Patch to fix restoring with LoopPoint resource

ZQ
Zhantong Qiu (Gerrit)
Thu, Apr 20, 2023 8:42 PM

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

Change subject: stdlib: Patch to fix restoring with LoopPoint resource
......................................................................

stdlib: Patch to fix restoring with LoopPoint resource

This patch added a new variable _restore in the Looppoint class to only
take the relative count for either both the start and end or only the
end of the simulation region in the restoring region depending on if
there exists a warmup region or not.

Change-Id: I9827971f1dc608305004673b24d5d672e807efcb

M src/python/gem5/resources/looppoint.py
1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/python/gem5/resources/looppoint.py
b/src/python/gem5/resources/looppoint.py
index 684faef..f09f466 100644
--- a/src/python/gem5/resources/looppoint.py
+++ b/src/python/gem5/resources/looppoint.py
@@ -70,6 +70,10 @@
"""Returns the PcCountPair for this Region PC value."""
return PcCountPair(self.get_pc(), self.get_global())

  • def get_relative_pc_count_pair(self) -> PcCountPair:
  •    """Returns the relative PcCountPair for this Region PC value."""
    
  •    return PcCountPair(self.get_pc(), self.get_relative())
    
  • def update_relative_count(self, manager: PcCountTrackerManager) ->  
    

None:
"""Updates the relative count."""
self._relative = int(
@@ -164,6 +168,14 @@
self.get_end().get_pc_count_pair(),
]

  • def get_relative_pc_count_pairs(self) -> List[PcCountPair]:
  •    """Returns the relative PC count pairs for the start and
    
  •    end LoopointRegionPCs."""
    
  •    return [
    
  •        self.get_start().get_relative_pc_count_pair(),
    
  •        self.get_end().get_relative_pc_count_pair(),
    
  •    ]
    
  • def update_relatives_counts(
        self, manager: PcCountTrackerManager, include_start: bool = False
    ) -> None:
    

@@ -229,6 +241,19 @@
pc_count_pairs.extend(self.get_warmup().get_pc_count_pairs())
return pc_count_pairs

  • def get_relative_pc_count_pairs(self) -> List[PcCountPair]:
  •    """Returns the relative PC count pairs for this Looppoint region.
    
  •    If the region has warmup region, then returns the relative PC count
    
  •    pair of both start and end of the simulation region, otherwise,
    
  •    only return the relative PC count pair of the end of the simulation
    
  •    region."""
    
  •    relative_pc_count_pairs = (
    
  •        self.get_simulation().get_relative_pc_count_pairs()
    
  •    )
    
  •    if not self.get_warmup():
    
  •        return [relative_pc_count_pairs[1]]
    
  •    return relative_pc_count_pairs
    
  • def update_relatives_counts(self, manager: PcCountTrackerManager) ->  
    

None:
"""Updates the relative counds of this Looppoint region."""
self.get_simulation().update_relatives_counts(
@@ -262,6 +287,7 @@
:param regions: A dictionary mapping the region_ids with the
LooppointRegions.
"""

  •    self._restore = False
        self._regions = regions
        self._manager = PcCountTrackerManager()
        self._manager.targets = self.get_targets()
    

@@ -271,6 +297,8 @@
structure containing a single target region via its ID. This
function
will remove all irrelevant regions."""

  •    self._restore = True
    
  •     if region_id not in self._regions:
            raise Exception(f"Region ID '{region_id}' cannot be found.")
    

@@ -345,10 +373,18 @@
def get_targets(self) -> List[PcCountPair]:
"""Returns the complete list of target PcCountPairs. That is, the
PcCountPairs each region starts with as well as the relevant warmup

  •    intervals."""
    
  •    intervals.
    
  •    If it is restoring, it returns the relative PC Count pairs of the
    
  •    simulation region."""
        targets = []
    
  •    for rid in self.get_regions():
    
  •        targets.extend(self.get_regions()[rid].get_pc_count_pairs())
    
  •    if self._restore:
    
  •        for rid in self.get_regions():
    
  •            targets.extend(
    
  •                self.get_regions()[rid].get_relative_pc_count_pairs()
    
  •            )
    
  •    else:
    
  •        for rid in self.get_regions():
    

targets.extend(self.get_regions()[rid].get_pc_count_pairs())

      return targets

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/69997?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9827971f1dc608305004673b24d5d672e807efcb
Gerrit-Change-Number: 69997
Gerrit-PatchSet: 1
Gerrit-Owner: Zhantong Qiu ztqiu@ucdavis.edu

Zhantong Qiu has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/69997?usp=email ) Change subject: stdlib: Patch to fix restoring with LoopPoint resource ...................................................................... stdlib: Patch to fix restoring with LoopPoint resource This patch added a new variable _restore in the Looppoint class to only take the relative count for either both the start and end or only the end of the simulation region in the restoring region depending on if there exists a warmup region or not. Change-Id: I9827971f1dc608305004673b24d5d672e807efcb --- M src/python/gem5/resources/looppoint.py 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/python/gem5/resources/looppoint.py b/src/python/gem5/resources/looppoint.py index 684faef..f09f466 100644 --- a/src/python/gem5/resources/looppoint.py +++ b/src/python/gem5/resources/looppoint.py @@ -70,6 +70,10 @@ """Returns the PcCountPair for this Region PC value.""" return PcCountPair(self.get_pc(), self.get_global()) + def get_relative_pc_count_pair(self) -> PcCountPair: + """Returns the relative PcCountPair for this Region PC value.""" + return PcCountPair(self.get_pc(), self.get_relative()) + def update_relative_count(self, manager: PcCountTrackerManager) -> None: """Updates the relative count.""" self._relative = int( @@ -164,6 +168,14 @@ self.get_end().get_pc_count_pair(), ] + def get_relative_pc_count_pairs(self) -> List[PcCountPair]: + """Returns the relative PC count pairs for the start and + end LoopointRegionPCs.""" + return [ + self.get_start().get_relative_pc_count_pair(), + self.get_end().get_relative_pc_count_pair(), + ] + def update_relatives_counts( self, manager: PcCountTrackerManager, include_start: bool = False ) -> None: @@ -229,6 +241,19 @@ pc_count_pairs.extend(self.get_warmup().get_pc_count_pairs()) return pc_count_pairs + def get_relative_pc_count_pairs(self) -> List[PcCountPair]: + """Returns the relative PC count pairs for this Looppoint region. + If the region has warmup region, then returns the relative PC count + pair of both start and end of the simulation region, otherwise, + only return the relative PC count pair of the end of the simulation + region.""" + relative_pc_count_pairs = ( + self.get_simulation().get_relative_pc_count_pairs() + ) + if not self.get_warmup(): + return [relative_pc_count_pairs[1]] + return relative_pc_count_pairs + def update_relatives_counts(self, manager: PcCountTrackerManager) -> None: """Updates the relative counds of this Looppoint region.""" self.get_simulation().update_relatives_counts( @@ -262,6 +287,7 @@ :param regions: A dictionary mapping the region_ids with the LooppointRegions. """ + self._restore = False self._regions = regions self._manager = PcCountTrackerManager() self._manager.targets = self.get_targets() @@ -271,6 +297,8 @@ structure containing a single target region via its ID. This function will remove all irrelevant regions.""" + self._restore = True + if region_id not in self._regions: raise Exception(f"Region ID '{region_id}' cannot be found.") @@ -345,10 +373,18 @@ def get_targets(self) -> List[PcCountPair]: """Returns the complete list of target PcCountPairs. That is, the PcCountPairs each region starts with as well as the relevant warmup - intervals.""" + intervals. + If it is restoring, it returns the relative PC Count pairs of the + simulation region.""" targets = [] - for rid in self.get_regions(): - targets.extend(self.get_regions()[rid].get_pc_count_pairs()) + if self._restore: + for rid in self.get_regions(): + targets.extend( + self.get_regions()[rid].get_relative_pc_count_pairs() + ) + else: + for rid in self.get_regions(): + targets.extend(self.get_regions()[rid].get_pc_count_pairs()) return targets -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/69997?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-MessageType: newchange Gerrit-Project: public/gem5 Gerrit-Branch: develop Gerrit-Change-Id: I9827971f1dc608305004673b24d5d672e807efcb Gerrit-Change-Number: 69997 Gerrit-PatchSet: 1 Gerrit-Owner: Zhantong Qiu <ztqiu@ucdavis.edu>