Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/5243

Change subject: mem: Use the caching built into AddrRangeMap in the crossbar model.
......................................................................

mem: Use the caching built into AddrRangeMap in the crossbar model.

Use that instead of caching built into the crossbar.

Change-Id: If5a5355a0a1a6e532b14efc88a319de4c023f8c1
---
M src/mem/coherent_xbar.cc
M src/mem/noncoherent_xbar.cc
M src/mem/xbar.cc
M src/mem/xbar.hh
4 files changed, 3 insertions(+), 64 deletions(-)



diff --git a/src/mem/coherent_xbar.cc b/src/mem/coherent_xbar.cc
index 7c3a4e3..3cd56bb 100644
--- a/src/mem/coherent_xbar.cc
+++ b/src/mem/coherent_xbar.cc
@@ -97,8 +97,6 @@
                                            csprintf(".respLayer%d", i)));
         snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
     }
-
-    clearPortCache();
 }

 CoherentXBar::~CoherentXBar()
diff --git a/src/mem/noncoherent_xbar.cc b/src/mem/noncoherent_xbar.cc
index eeaa4fb..6921536 100644
--- a/src/mem/noncoherent_xbar.cc
+++ b/src/mem/noncoherent_xbar.cc
@@ -88,8 +88,6 @@
         respLayers.push_back(new RespLayer(*bp, *this,
                                            csprintf(".respLayer%d", i)));
     }
-
-    clearPortCache();
 }

 NoncoherentXBar::~NoncoherentXBar()
diff --git a/src/mem/xbar.cc b/src/mem/xbar.cc
index b7826fd..ca1a847 100644
--- a/src/mem/xbar.cc
+++ b/src/mem/xbar.cc
@@ -327,18 +327,10 @@
     // 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.find(addr);
-    if (i != portMap.end()) {
-        dest_id = i->second;
-        updatePortCache(dest_id, i->first);
-        return dest_id;
-    }
+    if (i != portMap.end())
+        return i->second;

     // Check if this matches the default range
     if (useDefaultRange) {
@@ -517,8 +509,6 @@
         for (const auto& s: slavePorts)
             s->sendRangeChange();
     }
-
-    clearPortCache();
 }

 AddrRangeList
diff --git a/src/mem/xbar.hh b/src/mem/xbar.hh
index f826e14..2b7e7ed 100644
--- a/src/mem/xbar.hh
+++ b/src/mem/xbar.hh
@@ -319,7 +319,7 @@
     /** 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 @@
      */
     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.
      *

--
To view, visit https://gem5-review.googlesource.com/5243
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If5a5355a0a1a6e532b14efc88a319de4c023f8c1
Gerrit-Change-Number: 5243
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to