mem-cache,python: Allow custom TLB and events in each prefetcher.
authorIsaac Sánchez Barrera <isaac.sanchez@bsc.es>
Fri, 7 Aug 2020 10:12:10 +0000 (12:12 +0200)
committerIsaac Sánchez Barrera <isaac.sanchez@bsc.es>
Mon, 17 Aug 2020 11:35:48 +0000 (11:35 +0000)
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 <isaac.sanchez@bsc.es>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/32394
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
src/mem/cache/prefetch/Prefetcher.py

index f131ccf7763f413e649e73732224c71e0cb5abdf..c163028321a1102731b89bfc05d29280207a9361 100644 (file)
@@ -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")