Daniel Carvalho has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/24540 )
Change subject: mem-cache: Use CircularQueue in PIF prefetcher
......................................................................
mem-cache: Use CircularQueue in PIF prefetcher
Use CircularQueue for PIF's history buffer, and change the indexing
storage to a CQ iterator.
Change-Id: I75bbb75a6be41bd063f662baedbd4c9de33644de
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24540
Reviewed-by: Nikos Nikoleris <nikos.nikole...@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikole...@arm.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/mem/cache/prefetch/pif.cc
M src/mem/cache/prefetch/pif.hh
2 files changed, 13 insertions(+), 29 deletions(-)
Approvals:
Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/mem/cache/prefetch/pif.cc b/src/mem/cache/prefetch/pif.cc
index 8491062..6a2983b 100644
--- a/src/mem/cache/prefetch/pif.cc
+++ b/src/mem/cache/prefetch/pif.cc
@@ -41,12 +41,11 @@
precSize(p->prec_spatial_region_bits),
succSize(p->succ_spatial_region_bits),
maxCompactorEntries(p->compactor_entries),
- maxStreamAddressBufferEntries(p->stream_address_buffer_entries),
historyBuffer(p->history_buffer_size),
- historyBufferTail(0),
index(p->index_assoc, p->index_entries, p->index_indexing_policy,
p->index_replacement_policy),
- streamAddressBuffer(), listenersPC()
+ streamAddressBuffer(p->stream_address_buffer_entries),
+ listenersPC()
{
}
@@ -169,8 +168,8 @@
// updating the trigger address and resetting the vector bits
if (!is_in_temporal_compactor) {
// Insert the spatial entry into the history buffer and
update
- // the 'index' table to point to the new entry
- historyBuffer[historyBufferTail] = spatialCompactor;
+ // the 'iterator' table to point to the new entry
+ historyBuffer.push_back(spatialCompactor);
IndexEntry *idx_entry =
index.findEntry(spatialCompactor.trigger, false);
@@ -182,12 +181,8 @@
index.insertEntry(spatialCompactor.trigger, false,
idx_entry);
}
- idx_entry->historyIndex = historyBufferTail;
-
- historyBufferTail++;
- if (historyBufferTail == historyBuffer.size()) {
- historyBufferTail = 0;
- }
+ idx_entry->historyIt =
+ historyBuffer.getIterator(historyBuffer.tail());
// Reset the spatial compactor fields with the new address
spatialCompactor = CompactorEntry(pc, precSize, succSize);
@@ -206,13 +201,7 @@
// comparing the access against the active Stream Address Buffers
for (auto &sabEntry : streamAddressBuffer) {
if (sabEntry->hasAddress(addr, lBlkSize)) {
- // Advance to the next entry (first check if we have reached
the
- // end of the history buffer)
- if (sabEntry == &(historyBuffer[historyBuffer.size() - 1])) {
- sabEntry = &(historyBuffer[0]);
- } else {
- sabEntry++;
- }
+ sabEntry++;
sabEntry->getPredictedAddresses(lBlkSize, addresses);
// We are done
return;
@@ -227,13 +216,9 @@
index.accessEntry(idx_entry);
// Trigger address from the 'index' table and index to the history
// buffer
- const unsigned int hb_entry = idx_entry->historyIndex;
- CompactorEntry *entry = &historyBuffer[hb_entry];
+ auto entry = idx_entry->historyIt;
// Track the block in the Stream Address Buffer
- if (streamAddressBuffer.size() == maxStreamAddressBufferEntries) {
- streamAddressBuffer.pop_front();
- }
streamAddressBuffer.push_back(entry);
entry->getPredictedAddresses(lBlkSize, addresses);
diff --git a/src/mem/cache/prefetch/pif.hh b/src/mem/cache/prefetch/pif.hh
index 9fef296..e3d34fb 100644
--- a/src/mem/cache/prefetch/pif.hh
+++ b/src/mem/cache/prefetch/pif.hh
@@ -40,6 +40,7 @@
#include <deque>
#include <vector>
+#include "base/circular_queue.hh"
#include "mem/cache/prefetch/associative_set.hh"
#include "mem/cache/prefetch/queued.hh"
@@ -55,8 +56,6 @@
const unsigned int succSize;
/** Number of entries used for the temporal compactor */
const unsigned int maxCompactorEntries;
- /** Max number of entries to be used in the Stream Address Buffer
*/
- const unsigned int maxStreamAddressBufferEntries;
/**
* The compactor tracks retired instructions addresses, leveraging
the
@@ -127,12 +126,12 @@
* History buffer is a circular buffer that stores the sequence of
* retired instructions in FIFO order.
*/
- std::vector<CompactorEntry> historyBuffer;
- unsigned int historyBufferTail;
+ using HistoryBuffer = CircularQueue<CompactorEntry>;
+ HistoryBuffer historyBuffer;
struct IndexEntry : public TaggedEntry
{
- unsigned int historyIndex;
+ HistoryBuffer::iterator historyIt;
};
/**
* The index table is a small cache-like structure that facilitates
@@ -146,7 +145,7 @@
* history buffer, initiallly set to the pointer taken from the
index
* table
*/
- std::deque<CompactorEntry*> streamAddressBuffer;
+ CircularQueue<HistoryBuffer::iterator> streamAddressBuffer;
/**
* Updates the prefetcher structures upon an instruction retired
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/24540
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I75bbb75a6be41bd063f662baedbd4c9de33644de
Gerrit-Change-Number: 24540
Gerrit-PatchSet: 3
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Ivan Pizarro <ivan.piza...@metempsy.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s