Daniel Carvalho has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/24534 )

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

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 <oda...@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24534
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/mem/ruby/structures/RubyPrefetcher.cc
M src/mem/ruby/structures/RubyPrefetcher.hh
2 files changed, 17 insertions(+), 40 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/ruby/structures/RubyPrefetcher.cc b/src/mem/ruby/structures/RubyPrefetcher.cc
index b416269..aa6c7cd 100644
--- a/src/mem/ruby/structures/RubyPrefetcher.cc
+++ b/src/mem/ruby/structures/RubyPrefetcher.cc
@@ -140,36 +140,16 @@
         }
     }

-    // 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 @@

 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 @@
 }

 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 @@
// 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 8e08fdf..b640cc3 100644
--- a/src/mem/ruby/structures/RubyPrefetcher.hh
+++ b/src/mem/ruby/structures/RubyPrefetcher.hh
@@ -181,23 +181,22 @@
          * @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;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/24534
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: If780e848b19056c9213092b6fc8673bd4f37b65f
Gerrit-Change-Number: 24534
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Bradford Beckmann <bradford.beckm...@gmail.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.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

Reply via email to