1/* 2 * Copyright (c) 2018 Metempsy Technology Consulting 3 * All rights reserved. 4 * 5 * Copyright (c) 2006 INRIA (Institut National de Recherche en 6 * Informatique et en Automatique / French National Research Institute 7 * for Computer Science and Applied Mathematics) 8 * 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions are 13 * met: redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer; 15 * redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution; 18 * neither the name of the copyright holders nor the names of its 19 * contributors may be used to endorse or promote products derived from 20 * this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * Author: André Seznec, Pau Cabre, Javier Bueno 35 * 36 */ 37 38/* 39 * 64KB TAGE-SC-L branch predictor (devised by Andre Seznec) 40 * 41 * Most of the code in this file has been adapted from cbp64KB/predictor.h in 42 * http://www.jilp.org/cbp2016/code/AndreSeznecLimited.tar.gz 43 */ 44 45#ifndef __CPU_PRED_TAGE_SC_L_64KB 46#define __CPU_PRED_TAGE_SC_L_64KB 47 48#include "cpu/pred/tage_sc_l.hh" 49#include "params/TAGE_SC_L_64KB.hh" 50#include "params/TAGE_SC_L_64KB_StatisticalCorrector.hh" 51#include "params/TAGE_SC_L_TAGE_64KB.hh" 52 53class TAGE_SC_L_TAGE_64KB : public TAGE_SC_L_TAGE { 54 public: 55 TAGE_SC_L_TAGE_64KB(const TAGE_SC_L_TAGE_64KBParams *p) : TAGE_SC_L_TAGE(p) 56 {} 57 58 int gindex_ext(int index, int bank) const override; 59 60 uint16_t gtag(ThreadID tid, Addr pc, int bank) const override; 61 62 void handleAllocAndUReset( 63 bool alloc, bool taken, TAGEBase::BranchInfo* bi, int nrand) override; 64 65 void handleTAGEUpdate( 66 Addr branch_pc, bool taken, TAGEBase::BranchInfo* bi) override; 67}; 68 69class TAGE_SC_L_64KB_StatisticalCorrector : public StatisticalCorrector 70{ 71 const unsigned numEntriesSecondLocalHistories; 72 const unsigned numEntriesThirdLocalHistories; 73 74 // global branch history variation GEHL 75 const unsigned pnb; 76 const unsigned logPnb; 77 std::vector<int> pm; 78 std::vector<int8_t> * pgehl; 79 std::vector<int8_t> wp; 80 81 // Second local history GEHL 82 const unsigned snb; 83 const unsigned logSnb; 84 std::vector<int> sm; 85 std::vector<int8_t> * sgehl; 86 std::vector<int8_t> ws; 87 88 // Third local history GEHL 89 const unsigned tnb; 90 const unsigned logTnb; 91 std::vector<int> tm; 92 std::vector<int8_t> * tgehl; 93 std::vector<int8_t> wt; 94 95 // Second IMLI GEHL 96 const unsigned imnb; 97 const unsigned logImnb; 98 std::vector<int> imm; 99 std::vector<int8_t> * imgehl; 100 std::vector<int8_t> wim; 101 102 struct SC_64KB_ThreadHistory : public SCThreadHistory 103 { 104 std::vector<int64_t> imHist; 105 }; 106 107 SCThreadHistory *makeThreadHistory() override; 108 109 public: 110 TAGE_SC_L_64KB_StatisticalCorrector( 111 TAGE_SC_L_64KB_StatisticalCorrectorParams *p); 112 113 unsigned getIndBiasBank(Addr branch_pc, BranchInfo* bi, int hitBank, 114 int altBank) const override; 115 116 int gPredictions(ThreadID tid, Addr branch_pc, BranchInfo* bi, 117 int & lsum, int64_t phist) override; 118 119 int gIndexLogsSubstr(int nbr, int i) override; 120 121 void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, 122 BranchInfo * tage_bi, Addr corrTarget) override; 123 124 void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo* bi, 125 int64_t phist) override; 126}; 127 128class TAGE_SC_L_64KB : public TAGE_SC_L 129{ 130 public: 131 TAGE_SC_L_64KB(const TAGE_SC_L_64KBParams *params); 132}; 133 134#endif // __CPU_PRED_TAGE_SC_L_64KB 135 136