Daniel Carvalho has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/17532
Change subject: mem-cache: Reduce QueueEntry dependency on address
......................................................................
mem-cache: Reduce QueueEntry dependency on address
QueueEntry is dependent of the address, which belongs to Packet.
This patch reduces this dependency by introducing matching
functions to the Packet class, so that comparing whether an
address matches an entry can be forwarded to the appropriate
targets.
Change-Id: Id7bbd273af7b83dbeed957be2e71a1ff551a6f76
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/mem/cache/mshr.cc
M src/mem/cache/mshr.hh
M src/mem/cache/queue.hh
M src/mem/cache/queue_entry.hh
M src/mem/cache/write_queue_entry.cc
M src/mem/cache/write_queue_entry.hh
M src/mem/packet.cc
M src/mem/packet.hh
8 files changed, 137 insertions(+), 21 deletions(-)
diff --git a/src/mem/cache/mshr.cc b/src/mem/cache/mshr.cc
index a4cbeed..11a461d 100644
--- a/src/mem/cache/mshr.cc
+++ b/src/mem/cache/mshr.cc
@@ -682,3 +682,39 @@
print(str);
return str.str();
}
+
+bool
+MSHR::match(const Addr addr, const bool is_secure) const
+{
+ assert(hasTargets());
+ for (const auto target : targets) {
+ if (target.pkt->match(addr, is_secure, blkSize)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+MSHR::match(const PacketPtr pkt) const
+{
+ assert(hasTargets());
+ for (const auto target : targets) {
+ if (target.pkt->match(pkt, blkSize)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+MSHR::match(const QueueEntry* entry) const
+{
+ assert(hasTargets());
+ for (const auto target : targets) {
+ if (entry->match(target.pkt)) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/src/mem/cache/mshr.hh b/src/mem/cache/mshr.hh
index 9d65d88..2a9e1cf 100644
--- a/src/mem/cache/mshr.hh
+++ b/src/mem/cache/mshr.hh
@@ -546,6 +546,10 @@
* @return string with mshr fields + [deferred]targets
*/
std::string print() const;
+
+ bool match(const Addr addr, const bool is_secure) const override;
+ bool match(const PacketPtr pkt) const override;
+ bool match(const QueueEntry* entry) const override;
};
#endif // __MEM_CACHE_MSHR_HH__
diff --git a/src/mem/cache/queue.hh b/src/mem/cache/queue.hh
index 8c853d2..2d85807 100644
--- a/src/mem/cache/queue.hh
+++ b/src/mem/cache/queue.hh
@@ -196,23 +196,6 @@
}
/**
- * Find any pending requests that overlap the given request.
- *
- * @param blk_addr Block address.
- * @param is_secure True if the target memory space is secure.
- * @return A pointer to the earliest matching entry.
- */
- Entry* findPending(Addr blk_addr, bool is_secure) const
- {
- for (const auto& entry : readyList) {
- if (entry->match(blk_addr, is_secure)) {
- return entry;
- }
- }
- return nullptr;
- }
-
- /**
* Find any pending requests that overlap the given request of a
* different queue.
*
@@ -221,7 +204,12 @@
*/
Entry* findPending(const QueueEntry* entry) const
{
- return findPending(entry->getAddr(), entry->isSecure());
+ for (const auto& list_entry : readyList) {
+ if (list_entry->match(entry)) {
+ return list_entry;
+ }
+ }
+ return nullptr;
}
/**
diff --git a/src/mem/cache/queue_entry.hh b/src/mem/cache/queue_entry.hh
index 3d4b92d..e6c8e24 100644
--- a/src/mem/cache/queue_entry.hh
+++ b/src/mem/cache/queue_entry.hh
@@ -116,9 +116,24 @@
* @param is_secure Whether the target should be in secure space or
not.
* @return True if entry matches given information.
*/
- bool match(const Addr addr, const bool is_secure) const {
- return (getAddr() == addr) && (_isSecure == is_secure);
- }
+ virtual bool match(const Addr addr, const bool is_secure) const = 0;
+
+ /**
+ * Check if entry contains a packet that corresponds to the one being
+ * looked for.
+ *
+ * @param pkt The packet to search for.
+ * @return True if any of its targets' packets matches the given one.
+ */
+ virtual bool match(const PacketPtr pkt) const = 0;
+
+ /**
+ * Check if entry corresponds to the one being looked for.
+ *
+ * @param entry Other entry to compare against.
+ * @return True if entry matches given information.
+ */
+ virtual bool match(const QueueEntry* entry) const = 0;
/**
* Send this queue entry as a downstream packet, with the exact
diff --git a/src/mem/cache/write_queue_entry.cc
b/src/mem/cache/write_queue_entry.cc
index cfc16e9..0a02adb 100644
--- a/src/mem/cache/write_queue_entry.cc
+++ b/src/mem/cache/write_queue_entry.cc
@@ -141,6 +141,42 @@
return cache.sendWriteQueuePacket(this);
}
+bool
+WriteQueueEntry::match(const Addr addr, const bool is_secure) const
+{
+ assert(hasTargets());
+ for (const auto target : targets) {
+ if (target.pkt->match(addr, is_secure, blkSize)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+WriteQueueEntry::match(const PacketPtr pkt) const
+{
+ assert(hasTargets());
+ for (const auto target : targets) {
+ if (target.pkt->match(pkt, blkSize)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+WriteQueueEntry::match(const QueueEntry* entry) const
+{
+ assert(hasTargets());
+ for (const auto target : targets) {
+ if (entry->match(target.pkt)) {
+ return true;
+ }
+ }
+ return false;
+}
+
void
WriteQueueEntry::print(std::ostream &os, int verbosity,
const std::string &prefix) const
diff --git a/src/mem/cache/write_queue_entry.hh
b/src/mem/cache/write_queue_entry.hh
index 800ba4f..a84a2eb 100644
--- a/src/mem/cache/write_queue_entry.hh
+++ b/src/mem/cache/write_queue_entry.hh
@@ -207,6 +207,10 @@
* @return string with mshr fields
*/
std::string print() const;
+
+ bool match(const Addr addr, const bool is_secure) const override;
+ bool match(const PacketPtr pkt) const override;
+ bool match(const QueueEntry* entry) const override;
};
#endif // __MEM_CACHE_WRITE_QUEUE_ENTRY_HH__
diff --git a/src/mem/packet.cc b/src/mem/packet.cc
index e1c760c..7e04a05 100644
--- a/src/mem/packet.cc
+++ b/src/mem/packet.cc
@@ -390,6 +390,18 @@
return str.str();
}
+bool
+Packet::match(const Addr addr, const bool is_secure, const int blk_size)
const
+{
+ return (getBlockAddr(blk_size) == addr) && (isSecure() == is_secure);
+}
+
+bool
+Packet::match(const PacketPtr pkt, const int blk_size) const
+{
+ return match(pkt->getBlockAddr(blk_size), pkt->isSecure(), blk_size);
+}
+
Packet::PrintReqState::PrintReqState(std::ostream &_os, int _verbosity)
: curPrefixPtr(new std::string("")), os(_os), verbosity(_verbosity)
{
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index 2bcbf4d..2705d46 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -972,6 +972,27 @@
flags.set(VALID_SIZE);
}
+ /**
+ * Check if packet corresponds to a given address and address space.
+ *
+ * @param addr The address to compare against.
+ * @param is_secure Whether addr belongs to the secure address space.
+ * @param blk_size Block size in bytes.
+ * @return Whether packet matches description.
+ */
+ bool match(const Addr addr, const bool is_secure, const int blk_size)
+ const;
+
+ /**
+ * Check if this packet refers to the same address-secure bit as the
+ * given packet.
+ *
+ * @param addr The address to compare against.
+ * @param is_secure Whether addr belongs to the secure address space.
+ * @param blk_size Block size in bytes.
+ * @return Whether packet matches description.
+ */
+ bool match(const PacketPtr pkt, const int blk_size) const;
public:
/**
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/17532
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: Id7bbd273af7b83dbeed957be2e71a1ff551a6f76
Gerrit-Change-Number: 17532
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev