Daniel Carvalho has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/17536 )

Change subject: mem: Allow packet to provide its own addr range
......................................................................

mem: Allow packet to provide its own addr range

Add a getter to Packet to allow it to provide its own addr
range.

Change-Id: I2128ea3b71906502d10d9376b050a62407defd23
Signed-off-by: Daniel R. Carvalho <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17536
Tested-by: kokoro <[email protected]>
Reviewed-by: Nikos Nikoleris <[email protected]>
Maintainer: Nikos Nikoleris <[email protected]>
---
M src/mem/abstract_mem.cc
M src/mem/coherent_xbar.cc
M src/mem/noncoherent_xbar.cc
M src/mem/packet.cc
M src/mem/packet.hh
M src/mem/physical.cc
6 files changed, 25 insertions(+), 22 deletions(-)

Approvals:
  Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
  kokoro: Statistics mismatch



diff --git a/src/mem/abstract_mem.cc b/src/mem/abstract_mem.cc
index f0d6269..3f2d507 100644
--- a/src/mem/abstract_mem.cc
+++ b/src/mem/abstract_mem.cc
@@ -339,8 +339,7 @@
       return;
     }

-    assert(AddrRange(pkt->getAddr(),
- pkt->getAddr() + (pkt->getSize() - 1)).isSubset(range));
+    assert(pkt->getAddrRange().isSubset(range));

     uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();

@@ -430,8 +429,7 @@
 void
 AbstractMemory::functionalAccess(PacketPtr pkt)
 {
-    assert(AddrRange(pkt->getAddr(),
-                     pkt->getAddr() + pkt->getSize() - 1).isSubset(range));
+    assert(pkt->getAddrRange().isSubset(range));

     uint8_t *hostAddr = pmemAddr + pkt->getAddr() - range.start();

diff --git a/src/mem/coherent_xbar.cc b/src/mem/coherent_xbar.cc
index 96e855f..839d95b 100644
--- a/src/mem/coherent_xbar.cc
+++ b/src/mem/coherent_xbar.cc
@@ -152,8 +152,7 @@
     assert(is_express_snoop == cache_responding);

     // determine the destination based on the destination address range
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    PortID master_port_id = findPort(addr_range);
+    PortID master_port_id = findPort(pkt->getAddrRange());

     // test if the crossbar should be considered occupied for the current
     // port, and exclude express snoops from the check
@@ -552,9 +551,7 @@
     // device responsible for the address range something is
     // wrong, hence there is nothing further to do as the packet
     // would be going back to where it came from
-    AddrRange addr_range M5_VAR_USED =
-        RangeSize(pkt->getAddr(), pkt->getSize());
-    assert(findPort(addr_range) == master_port_id);
+    assert(findPort(pkt->getAddrRange()) == master_port_id);
 }

 bool
@@ -785,8 +782,7 @@

     // even if we had a snoop response, we must continue and also
     // perform the actual request at the destination
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    PortID master_port_id = findPort(addr_range);
+    PortID master_port_id = findPort(pkt->getAddrRange());

     if (sink_packet) {
         DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
@@ -1013,7 +1009,7 @@
             }
         }

- PortID dest_id = findPort(RangeSize(pkt->getAddr(), pkt->getSize()));
+        PortID dest_id = findPort(pkt->getAddrRange());

         masterPorts[dest_id]->sendFunctional(pkt);
     }
diff --git a/src/mem/noncoherent_xbar.cc b/src/mem/noncoherent_xbar.cc
index a7b6b0f..730c2b2 100644
--- a/src/mem/noncoherent_xbar.cc
+++ b/src/mem/noncoherent_xbar.cc
@@ -108,8 +108,7 @@
     assert(!pkt->isExpressSnoop());

     // determine the destination based on the address
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    PortID master_port_id = findPort(addr_range);
+    PortID master_port_id = findPort(pkt->getAddrRange());

     // test if the layer should be considered occupied for the current
     // port
@@ -255,8 +254,7 @@
     unsigned int pkt_cmd = pkt->cmdToIndex();

     // determine the destination port
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    PortID master_port_id = findPort(addr_range);
+    PortID master_port_id = findPort(pkt->getAddrRange());

     // stats updates for the request
     pktCount[slave_port_id][master_port_id]++;
@@ -308,8 +306,7 @@
     }

     // determine the destination port
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    PortID dest_id = findPort(addr_range);
+    PortID dest_id = findPort(pkt->getAddrRange());

     // forward the request to the appropriate destination
     masterPorts[dest_id]->sendFunctional(pkt);
diff --git a/src/mem/packet.cc b/src/mem/packet.cc
index e1c760c..7172219 100644
--- a/src/mem/packet.cc
+++ b/src/mem/packet.cc
@@ -227,6 +227,12 @@
       InvalidCmd, "InvalidateResp" }
 };

+AddrRange
+Packet::getAddrRange() const
+{
+    return RangeSize(getAddr(), getSize());
+}
+
 bool
Packet::trySatisfyFunctional(Printable *obj, Addr addr, bool is_secure, int size,
                         uint8_t *_data)
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index 2bcbf4d..4e3ea15 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -57,6 +57,7 @@
 #include <cassert>
 #include <list>

+#include "base/addr_range.hh"
 #include "base/cast.hh"
 #include "base/compiler.hh"
 #include "base/flags.hh"
@@ -736,6 +737,13 @@

unsigned getSize() const { assert(flags.isSet(VALID_SIZE)); return size; }

+    /**
+     * Get address range to which this packet belongs.
+     *
+     * @return Address range of this packet.
+     */
+    AddrRange getAddrRange() const;
+
     Addr getOffset(unsigned int blk_size) const
     {
         return getAddr() & Addr(blk_size - 1);
diff --git a/src/mem/physical.cc b/src/mem/physical.cc
index 2806204..afe5f7a 100644
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -278,8 +278,7 @@
 PhysicalMemory::access(PacketPtr pkt)
 {
     assert(pkt->isRequest());
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    const auto& m = addrMap.contains(addr_range);
+    const auto& m = addrMap.contains(pkt->getAddrRange());
     assert(m != addrMap.end());
     m->second->access(pkt);
 }
@@ -288,8 +287,7 @@
 PhysicalMemory::functionalAccess(PacketPtr pkt)
 {
     assert(pkt->isRequest());
-    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
-    const auto& m = addrMap.contains(addr_range);
+    const auto& m = addrMap.contains(pkt->getAddrRange());
     assert(m != addrMap.end());
     m->second->functionalAccess(pkt);
 }

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

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I2128ea3b71906502d10d9376b050a62407defd23
Gerrit-Change-Number: 17536
Gerrit-PatchSet: 4
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Nikos Nikoleris <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to