mem-ruby: Simplify Ruby prefetcher's filter access functions

The signatures request many things that do not need to be passed
around.

Change-Id: If780e848b19056c9213092b6fc8673bd4f37b65f
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24534
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Daniel R. Carvalho
2019-12-21 22:53:44 +01:00
committed by Daniel Carvalho
parent 453a334c8a
commit bf0b292829
2 changed files with 17 additions and 40 deletions

View File

@@ -140,36 +140,16 @@ RubyPrefetcher::observeMiss(Addr address, const RubyRequestType& type)
}
}
// check to see if this address is in the unit stride filter
bool alloc = false;
bool hit = accessUnitFilter(&unitFilter, line_addr, 1, alloc);
if (alloc) {
// allocate a new prefetch stream
initializeStream(line_addr, 1, getLRUindex(), type);
}
if (hit) {
// Check if address is in any of the stride filters
if (accessUnitFilter(&unitFilter, line_addr, 1, type)) {
DPRINTF(RubyPrefetcher, " *** hit in unit stride buffer\n");
return;
}
hit = accessUnitFilter(&negativeFilter, line_addr, -1, alloc);
if (alloc) {
// allocate a new prefetch stream
initializeStream(line_addr, -1, getLRUindex(), type);
}
if (hit) {
if (accessUnitFilter(&negativeFilter, line_addr, -1, type)) {
DPRINTF(RubyPrefetcher, " *** hit in unit negative unit buffer\n");
return;
}
// check to see if this address is in the non-unit stride filter
int stride = 0; // NULL value
hit = accessNonunitFilter(line_addr, &stride, alloc);
if (alloc) {
assert(stride != 0); // ensure non-zero stride prefetches
initializeStream(line_addr, stride, getLRUindex(), type);
}
if (hit) {
if (accessNonunitFilter(line_addr, type)) {
DPRINTF(RubyPrefetcher, " *** hit in non-unit stride buffer\n");
return;
}
@@ -310,17 +290,15 @@ RubyPrefetcher::getPrefetchEntry(Addr address, uint32_t &index)
bool
RubyPrefetcher::accessUnitFilter(CircularQueue<UnitFilterEntry>* const filter,
Addr line_addr, int stride, bool &alloc)
Addr line_addr, int stride, const RubyRequestType& type)
{
//reset the alloc flag
alloc = false;
for (auto& entry : *filter) {
if (entry.addr == line_addr) {
entry.addr = makeNextStrideAddress(entry.addr, stride);
entry.hits++;
if (entry.hits >= m_train_misses) {
alloc = true;
// Allocate a new prefetch stream
initializeStream(line_addr, stride, getLRUindex(), type);
}
return true;
}
@@ -334,11 +312,9 @@ RubyPrefetcher::accessUnitFilter(CircularQueue<UnitFilterEntry>* const filter,
}
bool
RubyPrefetcher::accessNonunitFilter(Addr line_addr, int *stride, bool &alloc)
RubyPrefetcher::accessNonunitFilter(Addr line_addr,
const RubyRequestType& type)
{
//reset the alloc flag
alloc = false;
/// look for non-unit strides based on a (user-defined) page size
Addr page_addr = pageAddress(line_addr);
@@ -359,12 +335,14 @@ RubyPrefetcher::accessNonunitFilter(Addr line_addr, int *stride, bool &alloc)
// This stride HAS to be the multiplicative constant of
// dataBlockBytes (bc makeNextStrideAddress is
// calculated based on this multiplicative constant!)
*stride = entry.stride /
const int stride = entry.stride /
RubySystem::getBlockSizeBytes();
// clear this filter entry
entry.clear();
alloc = true;
initializeStream(line_addr, stride, getLRUindex(),
type);
}
} else {
// If delta didn't match reset entry's hit count

View File

@@ -181,23 +181,22 @@ class RubyPrefetcher : public SimObject
* @param filter Unit filter being accessed.
* @param line_addr Address being accessed, block aligned.
* @param stride The stride value.
* @param alloc Whether a stream should be allocated on a hit.
* @param type Type of the request that generated the access.
* @return True if a corresponding entry was found.
*/
bool accessUnitFilter(CircularQueue<UnitFilterEntry>* const filter,
Addr line_addr, int stride, bool &alloc);
Addr line_addr, int stride, const RubyRequestType& type);
/**
* Access a non-unit stride filter to determine if there is a hit, and
* update it otherwise.
*
* @param line_addr Address being accessed, block aligned.
* @param stride The stride value.
* @param alloc Whether a stream should be allocated on a hit.
* @param type Type of the request that generated the access.
* @return True if a corresponding entry was found and its stride is
* not zero.
*/
bool accessNonunitFilter(Addr line_addr, int *stride, bool &alloc);
bool accessNonunitFilter(Addr line_addr, const RubyRequestType& type);
/// determine the page aligned address
Addr pageAddress(Addr addr) const;