Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/8981

Change subject: mem-cache: BRRIP Replacement Policy
......................................................................

mem-cache: BRRIP Replacement Policy

Implementation of a Bimodal RRIP replacement policy.

Change-Id: Iba716eb5df2bf2be156e765f889d94f6ad00c91b
---
M src/mem/cache/replacement_policies/ReplacementPolicies.py
M src/mem/cache/replacement_policies/SConscript
A src/mem/cache/replacement_policies/brrip_rp.cc
A src/mem/cache/replacement_policies/brrip_rp.hh
4 files changed, 142 insertions(+), 0 deletions(-)



diff --git a/src/mem/cache/replacement_policies/ReplacementPolicies.py b/src/mem/cache/replacement_policies/ReplacementPolicies.py
index 5798ae8..6306b0e 100644
--- a/src/mem/cache/replacement_policies/ReplacementPolicies.py
+++ b/src/mem/cache/replacement_policies/ReplacementPolicies.py
@@ -52,3 +52,10 @@
     max_RRPV = Param.Unsigned(3, "Maximum RRPV possible")
     hit_priority = Param.Bool(False,
         "Prioritize evicting blocks that havent had a hit recently")
+
+class BRRIPRP(RRIPRP):
+    type = 'BRRIPRP'
+    cxx_class = 'BRRIPRP'
+    cxx_header = "mem/cache/replacement_policies/brrip_rp.hh"
+    btp = Param.Percent(3,
+        "Percentage of blocks to be inserted with long RRPV")
diff --git a/src/mem/cache/replacement_policies/SConscript b/src/mem/cache/replacement_policies/SConscript
index ebe5397..9a29de0 100644
--- a/src/mem/cache/replacement_policies/SConscript
+++ b/src/mem/cache/replacement_policies/SConscript
@@ -33,6 +33,7 @@
 SimObject('ReplacementPolicies.py')

 Source('base.cc')
+Source('brrip_rp.cc')
 Source('lru_rp.cc')
 Source('random_rp.cc')
 Source('rrip_rp.cc')
diff --git a/src/mem/cache/replacement_policies/brrip_rp.cc b/src/mem/cache/replacement_policies/brrip_rp.cc
new file mode 100644
index 0000000..ed565d4
--- /dev/null
+++ b/src/mem/cache/replacement_policies/brrip_rp.cc
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2018 Inria
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Daniel Carvalho
+ */
+
+#include "mem/cache/replacement_policies/brrip_rp.hh"
+
+#include "base/random.hh"
+#include "debug/CacheRepl.hh"
+
+BRRIPRP::BRRIPRP(const Params *p)
+    : RRIPRP(p), btp(p->btp)
+{
+}
+
+void
+BRRIPRP::reset(CacheBlk *blk)
+{
+    RRIPRP::reset(blk);
+
+    // Reset RRPV
+    // Blocks are inserted as "long re-reference" if lower than btp,
+    // "distant re-reference" otherwise
+ blk->replData.rrpv = maxRRPV-(random_mt.random<unsigned>(1, 100) <= btp);
+}
+
+BRRIPRP*
+BRRIPRPParams::create()
+{
+    return new BRRIPRP(this);
+}
diff --git a/src/mem/cache/replacement_policies/brrip_rp.hh b/src/mem/cache/replacement_policies/brrip_rp.hh
new file mode 100644
index 0000000..83fcc94
--- /dev/null
+++ b/src/mem/cache/replacement_policies/brrip_rp.hh
@@ -0,0 +1,78 @@
+/**
+ * Copyright (c) 2018 Inria
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Daniel Carvalho
+ */
+
+/**
+ * @file
+ * Declaration of a Bimodal RRIP replacement policy.
+ * BRRIP is an extension of RRIP that has a probability of inserting blocks
+ * with long re-reference interval.
+
+ */
+
+#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
+#define __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
+
+#include "mem/cache/replacement_policies/rrip_rp.hh"
+#include "params/BRRIPRP.hh"
+
+class BRRIPRP : public RRIPRP
+{
+  protected:
+    /**
+     * Bimodal throtle parameter. Value in the range [0,100] used to decide
+     * if a new block is inserted with long or distant re-reference.
+     */
+    const unsigned btp;
+
+  public:
+    /** Convenience typedef. */
+    typedef BRRIPRPParams Params;
+
+    /**
+     * Construct and initiliaze this replacement policy.
+     */
+    BRRIPRP(const Params *p);
+
+    /**
+     * Destructor.
+     */
+    ~BRRIPRP() {}
+
+    /**
+     * Reset replacement data for a block. Used when a block is inserted.
+     * Sets the insertion tick, and update correspondent replacement data.
+     * Set RRPV according to the insertion policy used.
+     *
+     * @param blk Cache block to be reset.
+     */
+    void reset(CacheBlk *blk) override;
+};
+
+#endif // __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__

--
To view, visit https://gem5-review.googlesource.com/8981
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Iba716eb5df2bf2be156e765f889d94f6ad00c91b
Gerrit-Change-Number: 8981
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to