brrip_rp.hh revision 12626
112626Sodanrc@yahoo.com.br/**
212626Sodanrc@yahoo.com.br * Copyright (c) 2018 Inria
312626Sodanrc@yahoo.com.br * All rights reserved.
412626Sodanrc@yahoo.com.br *
512626Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without
612626Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are
712626Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright
812626Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer;
912626Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright
1012626Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the
1112626Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution;
1212626Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its
1312626Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from
1412626Sodanrc@yahoo.com.br * this software without specific prior written permission.
1512626Sodanrc@yahoo.com.br *
1612626Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712626Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812626Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912626Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012626Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112626Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212626Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312626Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412626Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512626Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612626Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712626Sodanrc@yahoo.com.br *
2812626Sodanrc@yahoo.com.br * Authors: Daniel Carvalho
2912626Sodanrc@yahoo.com.br */
3012626Sodanrc@yahoo.com.br
3112626Sodanrc@yahoo.com.br/**
3212626Sodanrc@yahoo.com.br * @file
3312626Sodanrc@yahoo.com.br * Declaration of a Re-Reference Interval Prediction replacement policy.
3412626Sodanrc@yahoo.com.br *
3512626Sodanrc@yahoo.com.br * Not-Recently Used (NRU) is an approximation of LRU that uses a single bit
3612626Sodanrc@yahoo.com.br * to determine if a block is going to be re-referenced in the near or distant
3712626Sodanrc@yahoo.com.br * future.
3812626Sodanrc@yahoo.com.br *
3912626Sodanrc@yahoo.com.br * Re-Reference Interval Prediction (RRIP) is an extension of NRU that uses a
4012626Sodanrc@yahoo.com.br * re-reference prediction value to determine if blocks are going to be re-
4112626Sodanrc@yahoo.com.br * used in the near future or not.
4212626Sodanrc@yahoo.com.br *
4312626Sodanrc@yahoo.com.br * The higher the value of the RRPV, the more distant the block is from
4412626Sodanrc@yahoo.com.br * its next access.
4512626Sodanrc@yahoo.com.br *
4612626Sodanrc@yahoo.com.br * Bimodal Re-Reference Interval Prediction (BRRIP) is an extension of RRIP
4712626Sodanrc@yahoo.com.br * that has a probability of not inserting blocks as the LRU. This probability
4812626Sodanrc@yahoo.com.br * is controlled by the bimodal throtle parameter (btp).
4912626Sodanrc@yahoo.com.br *
5012626Sodanrc@yahoo.com.br * From the original paper, this implementation of RRIP is also called
5112626Sodanrc@yahoo.com.br * Static RRIP (SRRIP), as it always inserts blocks with the same RRPV.
5212626Sodanrc@yahoo.com.br */
5312626Sodanrc@yahoo.com.br
5412626Sodanrc@yahoo.com.br#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
5512626Sodanrc@yahoo.com.br#define __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
5612626Sodanrc@yahoo.com.br
5712626Sodanrc@yahoo.com.br#include "mem/cache/replacement_policies/base.hh"
5812626Sodanrc@yahoo.com.br#include "params/BRRIPRP.hh"
5912626Sodanrc@yahoo.com.br
6012626Sodanrc@yahoo.com.brclass BRRIPRP : public BaseReplacementPolicy
6112626Sodanrc@yahoo.com.br{
6212626Sodanrc@yahoo.com.br  protected:
6312626Sodanrc@yahoo.com.br    /**
6412626Sodanrc@yahoo.com.br     * Maximum Re-Reference Prediction Value possible. A block with this
6512626Sodanrc@yahoo.com.br     * value as the rrpv has the longest possible re-reference interval,
6612626Sodanrc@yahoo.com.br     * that is, it is likely not to be used in the near future, and is
6712626Sodanrc@yahoo.com.br     * among the best eviction candidates.
6812626Sodanrc@yahoo.com.br     * A maxRRPV of 1 implies in a NRU.
6912626Sodanrc@yahoo.com.br     */
7012626Sodanrc@yahoo.com.br    const unsigned maxRRPV;
7112626Sodanrc@yahoo.com.br
7212626Sodanrc@yahoo.com.br    /**
7312626Sodanrc@yahoo.com.br     * The hit priority (HP) policy replaces blocks that do not receive cache
7412626Sodanrc@yahoo.com.br     * hits over any cache block that receives a hit, while the frequency
7512626Sodanrc@yahoo.com.br     * priority (FP) policy replaces infrequently re-referenced blocks.
7612626Sodanrc@yahoo.com.br     */
7712626Sodanrc@yahoo.com.br    const bool hitPriority;
7812626Sodanrc@yahoo.com.br
7912626Sodanrc@yahoo.com.br    /**
8012626Sodanrc@yahoo.com.br     * Bimodal throtle parameter. Value in the range [0,100] used to decide
8112626Sodanrc@yahoo.com.br     * if a new block is inserted with long or distant re-reference.
8212626Sodanrc@yahoo.com.br     */
8312626Sodanrc@yahoo.com.br    const unsigned btp;
8412626Sodanrc@yahoo.com.br
8512626Sodanrc@yahoo.com.br  public:
8612626Sodanrc@yahoo.com.br    /** Convenience typedef. */
8712626Sodanrc@yahoo.com.br    typedef BRRIPRPParams Params;
8812626Sodanrc@yahoo.com.br
8912626Sodanrc@yahoo.com.br    /**
9012626Sodanrc@yahoo.com.br     * Construct and initiliaze this replacement policy.
9112626Sodanrc@yahoo.com.br     */
9212626Sodanrc@yahoo.com.br    BRRIPRP(const Params *p);
9312626Sodanrc@yahoo.com.br
9412626Sodanrc@yahoo.com.br    /**
9512626Sodanrc@yahoo.com.br     * Destructor.
9612626Sodanrc@yahoo.com.br     */
9712626Sodanrc@yahoo.com.br    ~BRRIPRP() {}
9812626Sodanrc@yahoo.com.br
9912626Sodanrc@yahoo.com.br    /**
10012626Sodanrc@yahoo.com.br     * Touch a block to update its replacement data.
10112626Sodanrc@yahoo.com.br     *
10212626Sodanrc@yahoo.com.br     * @param blk Cache block to be touched.
10312626Sodanrc@yahoo.com.br     */
10412626Sodanrc@yahoo.com.br    void touch(CacheBlk *blk) override;
10512626Sodanrc@yahoo.com.br
10612626Sodanrc@yahoo.com.br    /**
10712626Sodanrc@yahoo.com.br     * Reset replacement data for a block. Used when a block is inserted.
10812626Sodanrc@yahoo.com.br     * Sets the insertion tick, and update correspondent replacement data.
10912626Sodanrc@yahoo.com.br     * Set RRPV according to the insertion policy used.
11012626Sodanrc@yahoo.com.br     *
11112626Sodanrc@yahoo.com.br     * @param blk Cache block to be reset.
11212626Sodanrc@yahoo.com.br     */
11312626Sodanrc@yahoo.com.br    void reset(CacheBlk *blk) override;
11412626Sodanrc@yahoo.com.br
11512626Sodanrc@yahoo.com.br    /**
11612626Sodanrc@yahoo.com.br     * Find replacement victim using rrpv.
11712626Sodanrc@yahoo.com.br     *
11812626Sodanrc@yahoo.com.br     * @param cands Replacement candidates, selected by indexing policy.
11912626Sodanrc@yahoo.com.br     * @return Cache block to be replaced.
12012626Sodanrc@yahoo.com.br     */
12112626Sodanrc@yahoo.com.br    CacheBlk* getVictim(const ReplacementCandidates& candidates) override;
12212626Sodanrc@yahoo.com.br};
12312626Sodanrc@yahoo.com.br
12412626Sodanrc@yahoo.com.br#endif // __MEM_CACHE_REPLACEMENT_POLICIES_BRRIP_RP_HH__
125