mem: Use the caching built into AddrRangeMap in the xbar
authorGabe Black <gabeblack@google.com>
Thu, 19 Oct 2017 03:50:57 +0000 (20:50 -0700)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Tue, 19 Jun 2018 14:24:25 +0000 (14:24 +0000)
Use that instead of caching built into the crossbar.

Change-Id: If5a5355a0a1a6e532b14efc88a319de4c023f8c1
Reviewed-on: https://gem5-review.googlesource.com/5243
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/coherent_xbar.cc
src/mem/noncoherent_xbar.cc
src/mem/xbar.cc
src/mem/xbar.hh

index 02b3122d94f88632d980dbccdab2ed8566c54e0c..872ee5c0df24381edd416477331ca9bbe7a1bbd6 100644 (file)
@@ -99,8 +99,6 @@ CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
                                            csprintf(".respLayer%d", i)));
         snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
     }
-
-    clearPortCache();
 }
 
 CoherentXBar::~CoherentXBar()
index 94649eaffeacbb328583947914d1a6406bce9156..3ff991fdb72d1d395c90fd63e9a845ea11612fea 100644 (file)
@@ -88,8 +88,6 @@ NoncoherentXBar::NoncoherentXBar(const NoncoherentXBarParams *p)
         respLayers.push_back(new RespLayer(*bp, *this,
                                            csprintf(".respLayer%d", i)));
     }
-
-    clearPortCache();
 }
 
 NoncoherentXBar::~NoncoherentXBar()
index 1984a94aab1e4b3d04cf98768e3c61353efbb02f..c3a5c83fe0aabdcb7149d258cf7dbd4d0a93785d 100644 (file)
@@ -327,17 +327,10 @@ BaseXBar::findPort(Addr addr)
     // ranges of all connected slave modules
     assert(gotAllAddrRanges);
 
-    // Check the cache
-    PortID dest_id = checkPortCache(addr);
-    if (dest_id != InvalidPortID)
-        return dest_id;
-
     // Check the address map interval tree
     auto i = portMap.contains(addr);
     if (i != portMap.end()) {
-        dest_id = i->second;
-        updatePortCache(dest_id, i->first);
-        return dest_id;
+        return i->second;
     }
 
     // Check if this matches the default range
@@ -518,8 +511,6 @@ BaseXBar::recvRangeChange(PortID master_port_id)
         for (const auto& s: slavePorts)
             s->sendRangeChange();
     }
-
-    clearPortCache();
 }
 
 AddrRangeList
index f826e142acdab03bcdc2fd5f0af75901b961d7fe..2b7e7ed48740a0a57aa598fdeb9b0bc09c8fc6a5 100644 (file)
@@ -319,7 +319,7 @@ class BaseXBar : public MemObject
     /** the width of the xbar in bytes */
     const uint32_t width;
 
-    AddrRangeMap<PortID> portMap;
+    AddrRangeMap<PortID, 3> portMap;
 
     /**
      * Remember where request packets came from so that we can route
@@ -350,53 +350,6 @@ class BaseXBar : public MemObject
      */
     PortID findPort(Addr addr);
 
-    // Cache for the findPort function storing recently used ports from portMap
-    struct PortCache {
-        bool valid;
-        PortID id;
-        AddrRange range;
-    };
-
-    PortCache portCache[3];
-
-    // Checks the cache and returns the id of the port that has the requested
-    // address within its range
-    inline PortID checkPortCache(Addr addr) const {
-        if (portCache[0].valid && portCache[0].range.contains(addr)) {
-            return portCache[0].id;
-        }
-        if (portCache[1].valid && portCache[1].range.contains(addr)) {
-            return portCache[1].id;
-        }
-        if (portCache[2].valid && portCache[2].range.contains(addr)) {
-            return portCache[2].id;
-        }
-
-        return InvalidPortID;
-    }
-
-    // Clears the earliest entry of the cache and inserts a new port entry
-    inline void updatePortCache(short id, const AddrRange& range) {
-        portCache[2].valid = portCache[1].valid;
-        portCache[2].id    = portCache[1].id;
-        portCache[2].range = portCache[1].range;
-
-        portCache[1].valid = portCache[0].valid;
-        portCache[1].id    = portCache[0].id;
-        portCache[1].range = portCache[0].range;
-
-        portCache[0].valid = true;
-        portCache[0].id    = id;
-        portCache[0].range = range;
-    }
-
-    // Clears the cache. Needs to be called in constructor.
-    inline void clearPortCache() {
-        portCache[2].valid = false;
-        portCache[1].valid = false;
-        portCache[0].valid = false;
-    }
-
     /**
      * Return the address ranges the crossbar is responsible for.
      *