From 7740fd7714f0a17ef3e68b1dd91d030b704fbffc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isaac=20S=C3=A1nchez=20Barrera?= Date: Fri, 7 Aug 2020 12:12:10 +0200 Subject: [PATCH] mem-cache,python: Allow custom TLB and events in each prefetcher. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The `BasePrefetcher` python class had members `_events` and `_tlbs` defined as lists, meaning that any call to `list.append` on them would affect `_events` and `_tlbs` for all prefetchers, not just the calling object. This change redefines them as instance members to fix the problem. Change-Id: I68feb1d6d78e2fa5e8775afba8c81c6dd0de6c60 Signed-off-by: Isaac Sánchez Barrera Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32394 Maintainer: Jason Lowe-Power Tested-by: kokoro Reviewed-by: Jason Lowe-Power Reviewed-by: Nikos Nikoleris --- src/mem/cache/prefetch/Prefetcher.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mem/cache/prefetch/Prefetcher.py b/src/mem/cache/prefetch/Prefetcher.py index f131ccf77..c16302832 100644 --- a/src/mem/cache/prefetch/Prefetcher.py +++ b/src/mem/cache/prefetch/Prefetcher.py @@ -80,7 +80,11 @@ class BasePrefetcher(ClockedObject): use_virtual_addresses = Param.Bool(False, "Use virtual addresses for prefetching") - _events = [] + def __init__(self, **kwargs): + super(BasePrefetcher, self).__init__(**kwargs) + self._events = [] + self._tlbs = [] + def addEvent(self, newObject): self._events.append(newObject) @@ -90,7 +94,7 @@ class BasePrefetcher(ClockedObject): for tlb in self._tlbs: self.getCCObject().addTLB(tlb.getCCObject()) for event in self._events: - event.register() + event.register() self.getCCObject().regProbeListeners() def listenFromProbe(self, simObj, *probeNames): @@ -99,7 +103,7 @@ class BasePrefetcher(ClockedObject): if len(probeNames) <= 0: raise TypeError("probeNames must have at least one element") self.addEvent(HWPProbeEvent(self, simObj, *probeNames)) - _tlbs = [] + def registerTLB(self, simObj): if not isinstance(simObj, SimObject): raise TypeError("argument must be a SimObject type") -- 2.30.2