bip_rp.hh revision 12684
112634Sodanrc@yahoo.com.br/** 212634Sodanrc@yahoo.com.br * Copyright (c) 2018 Inria 312634Sodanrc@yahoo.com.br * All rights reserved. 412634Sodanrc@yahoo.com.br * 512634Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without 612634Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are 712634Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright 812634Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer; 912634Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright 1012634Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the 1112634Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution; 1212634Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its 1312634Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from 1412634Sodanrc@yahoo.com.br * this software without specific prior written permission. 1512634Sodanrc@yahoo.com.br * 1612634Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712634Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812634Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912634Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012634Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112634Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212634Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312634Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412634Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512634Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612634Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712634Sodanrc@yahoo.com.br * 2812634Sodanrc@yahoo.com.br * Authors: Daniel Carvalho 2912634Sodanrc@yahoo.com.br */ 3012634Sodanrc@yahoo.com.br 3112634Sodanrc@yahoo.com.br/** 3212634Sodanrc@yahoo.com.br * @file 3312634Sodanrc@yahoo.com.br * Declaration of a Bimodal Interval Prediction replacement policy. 3412684Sodanrc@yahoo.com.br * Has a probability of when placing new entries, placing them as MRU. 3512634Sodanrc@yahoo.com.br * 3612634Sodanrc@yahoo.com.br * Although both LRU and LIP can be seen as specific cases of BIP 3712634Sodanrc@yahoo.com.br * where the bimodal throtle parameter are 1 and 0, respectively, we 3812634Sodanrc@yahoo.com.br * decide not to inherit from it, and do the other way around (inherit 3912634Sodanrc@yahoo.com.br * from LRU) for efficiency reasons. 4012634Sodanrc@yahoo.com.br * 4112634Sodanrc@yahoo.com.br * In the original paper they use btp = 1/32 ~= 3%. 4212634Sodanrc@yahoo.com.br */ 4312634Sodanrc@yahoo.com.br 4412684Sodanrc@yahoo.com.br#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_BIP_RP_HH__ 4512684Sodanrc@yahoo.com.br#define __MEM_CACHE_REPLACEMENT_POLICIES_BIP_RP_HH__ 4612634Sodanrc@yahoo.com.br 4712634Sodanrc@yahoo.com.br#include "mem/cache/replacement_policies/lru_rp.hh" 4812634Sodanrc@yahoo.com.br#include "params/BIPRP.hh" 4912634Sodanrc@yahoo.com.br 5012634Sodanrc@yahoo.com.brclass BIPRP : public LRURP 5112634Sodanrc@yahoo.com.br{ 5212634Sodanrc@yahoo.com.br protected: 5312634Sodanrc@yahoo.com.br /** 5412634Sodanrc@yahoo.com.br * Bimodal throtle parameter. Value in the range [0,100] used to decide 5512684Sodanrc@yahoo.com.br * if a new entry is inserted at the MRU or LRU position. 5612634Sodanrc@yahoo.com.br */ 5712634Sodanrc@yahoo.com.br const unsigned btp; 5812634Sodanrc@yahoo.com.br 5912634Sodanrc@yahoo.com.br public: 6012634Sodanrc@yahoo.com.br /** Convenience typedef. */ 6112634Sodanrc@yahoo.com.br typedef BIPRPParams Params; 6212634Sodanrc@yahoo.com.br 6312634Sodanrc@yahoo.com.br /** 6412634Sodanrc@yahoo.com.br * Construct and initiliaze this replacement policy. 6512634Sodanrc@yahoo.com.br */ 6612634Sodanrc@yahoo.com.br BIPRP(const Params *p); 6712634Sodanrc@yahoo.com.br 6812634Sodanrc@yahoo.com.br /** 6912634Sodanrc@yahoo.com.br * Destructor. 7012634Sodanrc@yahoo.com.br */ 7112634Sodanrc@yahoo.com.br ~BIPRP() {} 7212634Sodanrc@yahoo.com.br 7312634Sodanrc@yahoo.com.br /** 7412684Sodanrc@yahoo.com.br * Reset replacement data for an entry. Used when an entry is inserted. 7512684Sodanrc@yahoo.com.br * Uses the bimodal throtle parameter to decide whether the new entry 7612634Sodanrc@yahoo.com.br * should be inserted as MRU, or LRU. 7712634Sodanrc@yahoo.com.br * 7812684Sodanrc@yahoo.com.br * @param replacement_data Replacement data to be reset. 7912634Sodanrc@yahoo.com.br */ 8012684Sodanrc@yahoo.com.br void reset(const std::shared_ptr<ReplacementData>& replacement_data) const 8112684Sodanrc@yahoo.com.br override; 8212634Sodanrc@yahoo.com.br}; 8312634Sodanrc@yahoo.com.br 8412684Sodanrc@yahoo.com.br#endif // __MEM_CACHE_REPLACEMENT_POLICIES_BIP_RP_HH__ 85