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()
{
}
// 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);
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);
// 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;
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);
#include <deque>
#include <vector>
+#include "base/circular_queue.hh"
#include "mem/cache/prefetch/associative_set.hh"
#include "mem/cache/prefetch/queued.hh"
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
* 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
* 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