From: Daniel R. Carvalho Date: Sat, 21 Dec 2019 21:53:44 +0000 (+0100) Subject: mem-ruby: Simplify Ruby prefetcher's filter access functions X-Git-Tag: develop-gem5-snapshot~658 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf0b292829e4ba4ff4f2825dfc7fecb9d95c2a08;p=gem5.git 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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24534 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/mem/ruby/structures/RubyPrefetcher.cc b/src/mem/ruby/structures/RubyPrefetcher.cc index b416269e3..aa6c7cd7b 100644 --- a/src/mem/ruby/structures/RubyPrefetcher.cc +++ b/src/mem/ruby/structures/RubyPrefetcher.cc @@ -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* 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* 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 diff --git a/src/mem/ruby/structures/RubyPrefetcher.hh b/src/mem/ruby/structures/RubyPrefetcher.hh index 8e08fdf62..b640cc3f3 100644 --- a/src/mem/ruby/structures/RubyPrefetcher.hh +++ b/src/mem/ruby/structures/RubyPrefetcher.hh @@ -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* 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;