bip_rp.cc revision 12634
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#include "mem/cache/replacement_policies/bip_rp.hh"
3212634Sodanrc@yahoo.com.br
3312634Sodanrc@yahoo.com.br#include "base/random.hh"
3412634Sodanrc@yahoo.com.br#include "debug/CacheRepl.hh"
3512634Sodanrc@yahoo.com.br
3612634Sodanrc@yahoo.com.brBIPRP::BIPRP(const Params *p)
3712634Sodanrc@yahoo.com.br    : LRURP(p), btp(p->btp)
3812634Sodanrc@yahoo.com.br{
3912634Sodanrc@yahoo.com.br}
4012634Sodanrc@yahoo.com.br
4112634Sodanrc@yahoo.com.brvoid
4212634Sodanrc@yahoo.com.brBIPRP::reset(CacheBlk *blk)
4312634Sodanrc@yahoo.com.br{
4412634Sodanrc@yahoo.com.br    BaseReplacementPolicy::reset(blk);
4512634Sodanrc@yahoo.com.br
4612634Sodanrc@yahoo.com.br    // Blocks are inserted as MRU if lower than btp, LRU otherwise
4712634Sodanrc@yahoo.com.br    if (random_mt.random<unsigned>(1, 100) <= btp) {
4812634Sodanrc@yahoo.com.br        blk->lastTouchTick = curTick();
4912634Sodanrc@yahoo.com.br    } else {
5012634Sodanrc@yahoo.com.br        // Make their timestamps as old as possible, so that they become LRU
5112634Sodanrc@yahoo.com.br        blk->lastTouchTick = 0;
5212634Sodanrc@yahoo.com.br    }
5312634Sodanrc@yahoo.com.br}
5412634Sodanrc@yahoo.com.br
5512634Sodanrc@yahoo.com.brBIPRP*
5612634Sodanrc@yahoo.com.brBIPRPParams::create()
5712634Sodanrc@yahoo.com.br{
5812634Sodanrc@yahoo.com.br    return new BIPRP(this);
5912634Sodanrc@yahoo.com.br}
60