mru_rp.hh revision 12601
112601Sodanrc@yahoo.com.br/** 212601Sodanrc@yahoo.com.br * Copyright (c) 2018 Inria 312601Sodanrc@yahoo.com.br * All rights reserved. 412601Sodanrc@yahoo.com.br * 512601Sodanrc@yahoo.com.br * Redistribution and use in source and binary forms, with or without 612601Sodanrc@yahoo.com.br * modification, are permitted provided that the following conditions are 712601Sodanrc@yahoo.com.br * met: redistributions of source code must retain the above copyright 812601Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer; 912601Sodanrc@yahoo.com.br * redistributions in binary form must reproduce the above copyright 1012601Sodanrc@yahoo.com.br * notice, this list of conditions and the following disclaimer in the 1112601Sodanrc@yahoo.com.br * documentation and/or other materials provided with the distribution; 1212601Sodanrc@yahoo.com.br * neither the name of the copyright holders nor the names of its 1312601Sodanrc@yahoo.com.br * contributors may be used to endorse or promote products derived from 1412601Sodanrc@yahoo.com.br * this software without specific prior written permission. 1512601Sodanrc@yahoo.com.br * 1612601Sodanrc@yahoo.com.br * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712601Sodanrc@yahoo.com.br * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812601Sodanrc@yahoo.com.br * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912601Sodanrc@yahoo.com.br * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012601Sodanrc@yahoo.com.br * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112601Sodanrc@yahoo.com.br * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212601Sodanrc@yahoo.com.br * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312601Sodanrc@yahoo.com.br * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412601Sodanrc@yahoo.com.br * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512601Sodanrc@yahoo.com.br * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612601Sodanrc@yahoo.com.br * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712601Sodanrc@yahoo.com.br * 2812601Sodanrc@yahoo.com.br * Authors: Daniel Carvalho 2912601Sodanrc@yahoo.com.br */ 3012601Sodanrc@yahoo.com.br 3112601Sodanrc@yahoo.com.br/** 3212601Sodanrc@yahoo.com.br * @file 3312601Sodanrc@yahoo.com.br * Declaration of a Most Recently Used replacement policy. 3412601Sodanrc@yahoo.com.br * The victim is chosen using the timestamp. The block that was accessed the 3512601Sodanrc@yahoo.com.br * last is the one chosen to be replaced. 3612601Sodanrc@yahoo.com.br */ 3712601Sodanrc@yahoo.com.br 3812601Sodanrc@yahoo.com.br#ifndef __MEM_CACHE_REPLACEMENT_POLICIES_MRU_RP_HH__ 3912601Sodanrc@yahoo.com.br#define __MEM_CACHE_REPLACEMENT_POLICIES_MRU_RP_HH__ 4012601Sodanrc@yahoo.com.br 4112601Sodanrc@yahoo.com.br#include "mem/cache/replacement_policies/base.hh" 4212601Sodanrc@yahoo.com.br#include "params/MRURP.hh" 4312601Sodanrc@yahoo.com.br 4412601Sodanrc@yahoo.com.brclass MRURP : public BaseReplacementPolicy 4512601Sodanrc@yahoo.com.br{ 4612601Sodanrc@yahoo.com.br public: 4712601Sodanrc@yahoo.com.br /** Convenience typedef. */ 4812601Sodanrc@yahoo.com.br typedef MRURPParams Params; 4912601Sodanrc@yahoo.com.br 5012601Sodanrc@yahoo.com.br /** 5112601Sodanrc@yahoo.com.br * Construct and initiliaze this replacement policy. 5212601Sodanrc@yahoo.com.br */ 5312601Sodanrc@yahoo.com.br MRURP(const Params *p); 5412601Sodanrc@yahoo.com.br 5512601Sodanrc@yahoo.com.br /** 5612601Sodanrc@yahoo.com.br * Destructor. 5712601Sodanrc@yahoo.com.br */ 5812601Sodanrc@yahoo.com.br ~MRURP() {} 5912601Sodanrc@yahoo.com.br 6012601Sodanrc@yahoo.com.br /** 6112601Sodanrc@yahoo.com.br * Touch a block to update its last touch tick. 6212601Sodanrc@yahoo.com.br * 6312601Sodanrc@yahoo.com.br * @param blk Cache block to be touched. 6412601Sodanrc@yahoo.com.br */ 6512601Sodanrc@yahoo.com.br void touch(CacheBlk *blk); 6612601Sodanrc@yahoo.com.br 6712601Sodanrc@yahoo.com.br /** 6812601Sodanrc@yahoo.com.br * Reset replacement data for a block. Used when a block is inserted. 6912601Sodanrc@yahoo.com.br * Sets its last touch tick as the current tick. 7012601Sodanrc@yahoo.com.br * 7112601Sodanrc@yahoo.com.br * @param blk Cache block to be reset. 7212601Sodanrc@yahoo.com.br */ 7312601Sodanrc@yahoo.com.br void reset(CacheBlk *blk); 7412601Sodanrc@yahoo.com.br 7512601Sodanrc@yahoo.com.br /** 7612601Sodanrc@yahoo.com.br * Find replacement victim using access timestamps. 7712601Sodanrc@yahoo.com.br * @param cands Replacement candidates, selected by indexing policy. 7812601Sodanrc@yahoo.com.br * @return Cache block to be replaced. 7912601Sodanrc@yahoo.com.br */ 8012601Sodanrc@yahoo.com.br CacheBlk* getVictim(ReplacementCandidates& candidates) override; 8112601Sodanrc@yahoo.com.br}; 8212601Sodanrc@yahoo.com.br 8312601Sodanrc@yahoo.com.br#endif // __MEM_CACHE_REPLACEMENT_POLICIES_MRU_RP_HH__ 84