BranchPredictor.py revision 14034
19480Snilay@cs.wisc.edu# Copyright (c) 2012 Mark D. Hill and David A. Wood 210785Sgope@wisc.edu# Copyright (c) 2015 The University of Wisconsin 39480Snilay@cs.wisc.edu# All rights reserved. 49480Snilay@cs.wisc.edu# 59480Snilay@cs.wisc.edu# Redistribution and use in source and binary forms, with or without 69480Snilay@cs.wisc.edu# modification, are permitted provided that the following conditions are 79480Snilay@cs.wisc.edu# met: redistributions of source code must retain the above copyright 89480Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer; 99480Snilay@cs.wisc.edu# redistributions in binary form must reproduce the above copyright 109480Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer in the 119480Snilay@cs.wisc.edu# documentation and/or other materials provided with the distribution; 129480Snilay@cs.wisc.edu# neither the name of the copyright holders nor the names of its 139480Snilay@cs.wisc.edu# contributors may be used to endorse or promote products derived from 149480Snilay@cs.wisc.edu# this software without specific prior written permission. 159480Snilay@cs.wisc.edu# 169480Snilay@cs.wisc.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179480Snilay@cs.wisc.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189480Snilay@cs.wisc.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199480Snilay@cs.wisc.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209480Snilay@cs.wisc.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219480Snilay@cs.wisc.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229480Snilay@cs.wisc.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239480Snilay@cs.wisc.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249480Snilay@cs.wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259480Snilay@cs.wisc.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269480Snilay@cs.wisc.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279480Snilay@cs.wisc.edu# 2810785Sgope@wisc.edu# Authors: Nilay Vaish and Dibakar Gope 299480Snilay@cs.wisc.edu 309480Snilay@cs.wisc.edufrom m5.SimObject import SimObject 319480Snilay@cs.wisc.edufrom m5.params import * 3213432Spau.cabre@metempsy.comfrom m5.proxy import * 339480Snilay@cs.wisc.edu 3413957Sjairo.balart@metempsy.comclass IndirectPredictor(SimObject): 3513957Sjairo.balart@metempsy.com type = 'IndirectPredictor' 3613957Sjairo.balart@metempsy.com cxx_class = 'IndirectPredictor' 3713957Sjairo.balart@metempsy.com cxx_header = "cpu/pred/indirect.hh" 3813957Sjairo.balart@metempsy.com abstract = True 3913957Sjairo.balart@metempsy.com 4013957Sjairo.balart@metempsy.com numThreads = Param.Unsigned(Parent.numThreads, "Number of threads") 4113957Sjairo.balart@metempsy.com 4213957Sjairo.balart@metempsy.comclass SimpleIndirectPredictor(IndirectPredictor): 4313957Sjairo.balart@metempsy.com type = 'SimpleIndirectPredictor' 4413957Sjairo.balart@metempsy.com cxx_class = 'SimpleIndirectPredictor' 4513957Sjairo.balart@metempsy.com cxx_header = "cpu/pred/simple_indirect.hh" 4613957Sjairo.balart@metempsy.com 4713957Sjairo.balart@metempsy.com indirectHashGHR = Param.Bool(True, "Hash branch predictor GHR") 4813957Sjairo.balart@metempsy.com indirectHashTargets = Param.Bool(True, "Hash path history targets") 4913957Sjairo.balart@metempsy.com indirectSets = Param.Unsigned(256, "Cache sets for indirect predictor") 5013957Sjairo.balart@metempsy.com indirectWays = Param.Unsigned(2, "Ways for indirect predictor") 5113957Sjairo.balart@metempsy.com indirectTagSize = Param.Unsigned(16, "Indirect target cache tag bits") 5213957Sjairo.balart@metempsy.com indirectPathLength = Param.Unsigned(3, 5313957Sjairo.balart@metempsy.com "Previous indirect targets to use for path history") 5413957Sjairo.balart@metempsy.com indirectGHRBits = Param.Unsigned(13, "Indirect GHR number of bits") 5513957Sjairo.balart@metempsy.com instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by") 5613957Sjairo.balart@metempsy.com 579480Snilay@cs.wisc.educlass BranchPredictor(SimObject): 589480Snilay@cs.wisc.edu type = 'BranchPredictor' 599480Snilay@cs.wisc.edu cxx_class = 'BPredUnit' 609480Snilay@cs.wisc.edu cxx_header = "cpu/pred/bpred_unit.hh" 6110785Sgope@wisc.edu abstract = True 629480Snilay@cs.wisc.edu 6313432Spau.cabre@metempsy.com numThreads = Param.Unsigned(Parent.numThreads, "Number of threads") 6410785Sgope@wisc.edu BTBEntries = Param.Unsigned(4096, "Number of BTB entries") 6510785Sgope@wisc.edu BTBTagSize = Param.Unsigned(16, "Size of the BTB tags, in bits") 6610785Sgope@wisc.edu RASSize = Param.Unsigned(16, "RAS size") 6710785Sgope@wisc.edu instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by") 6810785Sgope@wisc.edu 6913957Sjairo.balart@metempsy.com indirectBranchPred = Param.IndirectPredictor(SimpleIndirectPredictor(), 7013957Sjairo.balart@metempsy.com "Indirect branch predictor, set to NULL to disable indirect predictions") 7110785Sgope@wisc.edu 7210785Sgope@wisc.educlass LocalBP(BranchPredictor): 7310785Sgope@wisc.edu type = 'LocalBP' 7410785Sgope@wisc.edu cxx_class = 'LocalBP' 7510785Sgope@wisc.edu cxx_header = "cpu/pred/2bit_local.hh" 7610785Sgope@wisc.edu 779480Snilay@cs.wisc.edu localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 789480Snilay@cs.wisc.edu localCtrBits = Param.Unsigned(2, "Bits per counter") 7910785Sgope@wisc.edu 8010785Sgope@wisc.edu 8110785Sgope@wisc.educlass TournamentBP(BranchPredictor): 8210785Sgope@wisc.edu type = 'TournamentBP' 8310785Sgope@wisc.edu cxx_class = 'TournamentBP' 8410785Sgope@wisc.edu cxx_header = "cpu/pred/tournament.hh" 8510785Sgope@wisc.edu 8610785Sgope@wisc.edu localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 8710785Sgope@wisc.edu localCtrBits = Param.Unsigned(2, "Bits per counter") 8810785Sgope@wisc.edu localHistoryTableSize = Param.Unsigned(2048, "size of local history table") 899480Snilay@cs.wisc.edu globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 909480Snilay@cs.wisc.edu globalCtrBits = Param.Unsigned(2, "Bits per counter") 919480Snilay@cs.wisc.edu choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 929480Snilay@cs.wisc.edu choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 939480Snilay@cs.wisc.edu 949480Snilay@cs.wisc.edu 9510785Sgope@wisc.educlass BiModeBP(BranchPredictor): 9610785Sgope@wisc.edu type = 'BiModeBP' 9710785Sgope@wisc.edu cxx_class = 'BiModeBP' 9810785Sgope@wisc.edu cxx_header = "cpu/pred/bi_mode.hh" 9910785Sgope@wisc.edu 10010785Sgope@wisc.edu globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 10110785Sgope@wisc.edu globalCtrBits = Param.Unsigned(2, "Bits per counter") 10210785Sgope@wisc.edu choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 10310785Sgope@wisc.edu choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 10410785Sgope@wisc.edu 10513626Sjairo.balart@metempsy.comclass TAGEBase(SimObject): 10613626Sjairo.balart@metempsy.com type = 'TAGEBase' 10713626Sjairo.balart@metempsy.com cxx_class = 'TAGEBase' 10813626Sjairo.balart@metempsy.com cxx_header = "cpu/pred/tage_base.hh" 10913626Sjairo.balart@metempsy.com 11013626Sjairo.balart@metempsy.com numThreads = Param.Unsigned(Parent.numThreads, "Number of threads") 11113626Sjairo.balart@metempsy.com instShiftAmt = Param.Unsigned(Parent.instShiftAmt, 11213626Sjairo.balart@metempsy.com "Number of bits to shift instructions by") 11313454Spau.cabre@metempsy.com 11413454Spau.cabre@metempsy.com nHistoryTables = Param.Unsigned(7, "Number of history tables") 11513494Spau.cabre@metempsy.com minHist = Param.Unsigned(5, "Minimum history size of TAGE") 11613494Spau.cabre@metempsy.com maxHist = Param.Unsigned(130, "Maximum history size of TAGE") 11713454Spau.cabre@metempsy.com 11813454Spau.cabre@metempsy.com tagTableTagWidths = VectorParam.Unsigned( 11913454Spau.cabre@metempsy.com [0, 9, 9, 10, 10, 11, 11, 12], "Tag size in TAGE tag tables") 12013454Spau.cabre@metempsy.com logTagTableSizes = VectorParam.Int( 12113454Spau.cabre@metempsy.com [13, 9, 9, 9, 9, 9, 9, 9], "Log2 of TAGE table sizes") 12213454Spau.cabre@metempsy.com logRatioBiModalHystEntries = Param.Unsigned(2, 12313454Spau.cabre@metempsy.com "Log num of prediction entries for a shared hysteresis bit " \ 12413454Spau.cabre@metempsy.com "for the Bimodal") 12513454Spau.cabre@metempsy.com 12613454Spau.cabre@metempsy.com tagTableCounterBits = Param.Unsigned(3, "Number of tag table counter bits") 12713454Spau.cabre@metempsy.com tagTableUBits = Param.Unsigned(2, "Number of tag table u bits") 12813454Spau.cabre@metempsy.com 12913454Spau.cabre@metempsy.com histBufferSize = Param.Unsigned(2097152, 13013454Spau.cabre@metempsy.com "A large number to track all branch histories(2MEntries default)") 13113454Spau.cabre@metempsy.com 13213454Spau.cabre@metempsy.com pathHistBits = Param.Unsigned(16, "Path history size") 13313454Spau.cabre@metempsy.com logUResetPeriod = Param.Unsigned(18, 13413454Spau.cabre@metempsy.com "Log period in number of branches to reset TAGE useful counters") 13513626Sjairo.balart@metempsy.com numUseAltOnNa = Param.Unsigned(1, "Number of USE_ALT_ON_NA counters") 13613685Sjavier.bueno@metempsy.com useAltOnNaBits = Param.Unsigned(4, "Size of the USE_ALT_ON_NA counter(s)") 13713454Spau.cabre@metempsy.com 13813626Sjairo.balart@metempsy.com maxNumAlloc = Param.Unsigned(1, 13913626Sjairo.balart@metempsy.com "Max number of TAGE entries allocted on mispredict") 14013626Sjairo.balart@metempsy.com 14113626Sjairo.balart@metempsy.com # List of enabled TAGE tables. If empty, all are enabled 14213626Sjairo.balart@metempsy.com noSkip = VectorParam.Bool([], "Vector of enabled TAGE tables") 14313626Sjairo.balart@metempsy.com 14413626Sjairo.balart@metempsy.com speculativeHistUpdate = Param.Bool(True, 14513626Sjairo.balart@metempsy.com "Use speculative update for histories") 14613626Sjairo.balart@metempsy.com 14713626Sjairo.balart@metempsy.com# TAGE branch predictor as described in https://www.jilp.org/vol8/v8paper1.pdf 14813626Sjairo.balart@metempsy.com# The default sizes below are for the 8C-TAGE configuration (63.5 Kbits) 14913626Sjairo.balart@metempsy.comclass TAGE(BranchPredictor): 15013626Sjairo.balart@metempsy.com type = 'TAGE' 15113626Sjairo.balart@metempsy.com cxx_class = 'TAGE' 15213626Sjairo.balart@metempsy.com cxx_header = "cpu/pred/tage.hh" 15313626Sjairo.balart@metempsy.com tage = Param.TAGEBase(TAGEBase(), "Tage object") 15413626Sjairo.balart@metempsy.com 15513626Sjairo.balart@metempsy.comclass LTAGE_TAGE(TAGEBase): 15613626Sjairo.balart@metempsy.com nHistoryTables = 12 15713626Sjairo.balart@metempsy.com minHist = 4 15813626Sjairo.balart@metempsy.com maxHist = 640 15913626Sjairo.balart@metempsy.com tagTableTagWidths = [0, 7, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15] 16013626Sjairo.balart@metempsy.com logTagTableSizes = [14, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9] 16113626Sjairo.balart@metempsy.com logUResetPeriod = 19 16213454Spau.cabre@metempsy.com 16313627Sjavier.bueno@metempsy.comclass LoopPredictor(SimObject): 16413627Sjavier.bueno@metempsy.com type = 'LoopPredictor' 16513627Sjavier.bueno@metempsy.com cxx_class = 'LoopPredictor' 16613627Sjavier.bueno@metempsy.com cxx_header = 'cpu/pred/loop_predictor.hh' 16713454Spau.cabre@metempsy.com 16811784Sarthur.perais@inria.fr logSizeLoopPred = Param.Unsigned(8, "Log size of the loop predictor") 16913444Spau.cabre@metempsy.com withLoopBits = Param.Unsigned(7, "Size of the WITHLOOP counter") 17013442Spau.cabre@metempsy.com loopTableAgeBits = Param.Unsigned(8, "Number of age bits per loop entry") 17113442Spau.cabre@metempsy.com loopTableConfidenceBits = Param.Unsigned(2, 17213442Spau.cabre@metempsy.com "Number of confidence bits per loop entry") 17313442Spau.cabre@metempsy.com loopTableTagBits = Param.Unsigned(14, "Number of tag bits per loop entry") 17413442Spau.cabre@metempsy.com loopTableIterBits = Param.Unsigned(14, "Nuber of iteration bits per loop") 17513444Spau.cabre@metempsy.com logLoopTableAssoc = Param.Unsigned(2, "Log loop predictor associativity") 17613442Spau.cabre@metempsy.com 17713493Spau.cabre@metempsy.com # Parameters for enabling modifications to the loop predictor 17813627Sjavier.bueno@metempsy.com # They have been copied from TAGE-GSC-IMLI 17913627Sjavier.bueno@metempsy.com # (http://www.irisa.fr/alf/downloads/seznec/TAGE-GSC-IMLI.tar) 18013493Spau.cabre@metempsy.com # 18113493Spau.cabre@metempsy.com # All of them should be disabled to match the original LTAGE implementation 18213493Spau.cabre@metempsy.com # (http://hpca23.cse.tamu.edu/taco/camino/cbp2/cbp-src/realistic-seznec.h) 18313493Spau.cabre@metempsy.com 18413493Spau.cabre@metempsy.com # Add speculation 18513493Spau.cabre@metempsy.com useSpeculation = Param.Bool(False, "Use speculation") 18613493Spau.cabre@metempsy.com 18713493Spau.cabre@metempsy.com # Add hashing for calculating the loop table index 18813493Spau.cabre@metempsy.com useHashing = Param.Bool(False, "Use hashing") 18913493Spau.cabre@metempsy.com 19013493Spau.cabre@metempsy.com # Add a direction bit to the loop table entries 19113493Spau.cabre@metempsy.com useDirectionBit = Param.Bool(False, "Use direction info") 19213493Spau.cabre@metempsy.com 19313627Sjavier.bueno@metempsy.com # If true, use random to decide whether to allocate or not, and only try 19413627Sjavier.bueno@metempsy.com # with one entry 19513627Sjavier.bueno@metempsy.com restrictAllocation = Param.Bool(False, 19613627Sjavier.bueno@metempsy.com "Restrict the allocation conditions") 19713627Sjavier.bueno@metempsy.com 19813627Sjavier.bueno@metempsy.com initialLoopIter = Param.Unsigned(1, "Initial iteration number") 19913627Sjavier.bueno@metempsy.com initialLoopAge = Param.Unsigned(255, "Initial age value") 20013627Sjavier.bueno@metempsy.com optionalAgeReset = Param.Bool(True, 20113627Sjavier.bueno@metempsy.com "Reset age bits optionally in some cases") 20213627Sjavier.bueno@metempsy.com 20313685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE(TAGEBase): 20413685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_TAGE' 20513685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_TAGE' 20613685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l.hh" 20713685Sjavier.bueno@metempsy.com abstract = True 20813685Sjavier.bueno@metempsy.com tagTableTagWidths = [0] 20913685Sjavier.bueno@metempsy.com numUseAltOnNa = 16 21013685Sjavier.bueno@metempsy.com pathHistBits = 27 21113685Sjavier.bueno@metempsy.com maxNumAlloc = 2 21213685Sjavier.bueno@metempsy.com logUResetPeriod = 10 21313685Sjavier.bueno@metempsy.com useAltOnNaBits = 5 21413685Sjavier.bueno@metempsy.com # TODO No speculation implemented as of now 21513685Sjavier.bueno@metempsy.com speculativeHistUpdate = False 21613685Sjavier.bueno@metempsy.com 21713685Sjavier.bueno@metempsy.com # This size does not set the final sizes of the tables (it is just used 21813685Sjavier.bueno@metempsy.com # for some calculations) 21913685Sjavier.bueno@metempsy.com # Instead, the number of TAGE entries comes from shortTagsTageEntries and 22013685Sjavier.bueno@metempsy.com # longTagsTageEntries 22113685Sjavier.bueno@metempsy.com logTagTableSize = Param.Unsigned("Log size of each tag table") 22213685Sjavier.bueno@metempsy.com 22313685Sjavier.bueno@metempsy.com shortTagsTageFactor = Param.Unsigned( 22413685Sjavier.bueno@metempsy.com "Factor for calculating the total number of short tags TAGE entries") 22513685Sjavier.bueno@metempsy.com 22613685Sjavier.bueno@metempsy.com longTagsTageFactor = Param.Unsigned( 22713685Sjavier.bueno@metempsy.com "Factor for calculating the total number of long tags TAGE entries") 22813685Sjavier.bueno@metempsy.com 22913685Sjavier.bueno@metempsy.com shortTagsSize = Param.Unsigned(8, "Size of the short tags") 23013685Sjavier.bueno@metempsy.com 23113685Sjavier.bueno@metempsy.com longTagsSize = Param.Unsigned("Size of the long tags") 23213685Sjavier.bueno@metempsy.com 23313685Sjavier.bueno@metempsy.com firstLongTagTable = Param.Unsigned("First table with long tags") 23413685Sjavier.bueno@metempsy.com 23513685Sjavier.bueno@metempsy.com truncatePathHist = Param.Bool(True, 23613685Sjavier.bueno@metempsy.com "Truncate the path history to its configured size") 23713685Sjavier.bueno@metempsy.com 23813685Sjavier.bueno@metempsy.com 23913685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE_64KB(TAGE_SC_L_TAGE): 24013685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_TAGE_64KB' 24113685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_TAGE_64KB' 24213685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_64KB.hh" 24313685Sjavier.bueno@metempsy.com nHistoryTables = 36 24413685Sjavier.bueno@metempsy.com 24513685Sjavier.bueno@metempsy.com minHist = 6 24613685Sjavier.bueno@metempsy.com maxHist = 3000 24713685Sjavier.bueno@metempsy.com 24813685Sjavier.bueno@metempsy.com tagTableUBits = 1 24913685Sjavier.bueno@metempsy.com 25013685Sjavier.bueno@metempsy.com logTagTableSizes = [13] 25113685Sjavier.bueno@metempsy.com 25213685Sjavier.bueno@metempsy.com # This is used to handle the 2-way associativity 25313685Sjavier.bueno@metempsy.com # (all odd entries are set to one, and if the corresponding even entry 25413685Sjavier.bueno@metempsy.com # is set to one, then there is a 2-way associativity for this pair) 25513685Sjavier.bueno@metempsy.com # Entry 0 is for the bimodal and it is ignored 25613685Sjavier.bueno@metempsy.com # Note: For this implementation, some odd entries are also set to 0 to save 25713685Sjavier.bueno@metempsy.com # some bits 25813685Sjavier.bueno@metempsy.com noSkip = [0,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1, 25913685Sjavier.bueno@metempsy.com 1,1,1,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1] 26013685Sjavier.bueno@metempsy.com 26113685Sjavier.bueno@metempsy.com logTagTableSize = 10 26213685Sjavier.bueno@metempsy.com shortTagsTageFactor = 10 26313685Sjavier.bueno@metempsy.com longTagsTageFactor = 20 26413685Sjavier.bueno@metempsy.com 26513685Sjavier.bueno@metempsy.com longTagsSize = 12 26613685Sjavier.bueno@metempsy.com 26713685Sjavier.bueno@metempsy.com firstLongTagTable = 13 26813685Sjavier.bueno@metempsy.com 26913685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE_8KB(TAGE_SC_L_TAGE): 27013685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_TAGE_8KB' 27113685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_TAGE_8KB' 27213685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_8KB.hh" 27313685Sjavier.bueno@metempsy.com 27413685Sjavier.bueno@metempsy.com nHistoryTables = 30 27513685Sjavier.bueno@metempsy.com 27613685Sjavier.bueno@metempsy.com minHist = 4 27713685Sjavier.bueno@metempsy.com maxHist = 1000 27813685Sjavier.bueno@metempsy.com 27913685Sjavier.bueno@metempsy.com logTagTableSize = 7 28013685Sjavier.bueno@metempsy.com shortTagsTageFactor = 9 28113685Sjavier.bueno@metempsy.com longTagsTageFactor = 17 28213685Sjavier.bueno@metempsy.com longTagsSize = 12 28313685Sjavier.bueno@metempsy.com 28413685Sjavier.bueno@metempsy.com logTagTableSizes = [12] 28513685Sjavier.bueno@metempsy.com 28613685Sjavier.bueno@metempsy.com firstLongTagTable = 11 28713685Sjavier.bueno@metempsy.com 28813685Sjavier.bueno@metempsy.com truncatePathHist = False 28913685Sjavier.bueno@metempsy.com 29013685Sjavier.bueno@metempsy.com noSkip = [0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1] 29113685Sjavier.bueno@metempsy.com 29213685Sjavier.bueno@metempsy.com tagTableUBits = 2 29313627Sjavier.bueno@metempsy.com 29413627Sjavier.bueno@metempsy.com# LTAGE branch predictor as described in 29513627Sjavier.bueno@metempsy.com# https://www.irisa.fr/caps/people/seznec/L-TAGE.pdf 29613627Sjavier.bueno@metempsy.com# It is basically a TAGE predictor plus a loop predictor 29713627Sjavier.bueno@metempsy.com# The differnt TAGE sizes are updated according to the paper values (256 Kbits) 29813627Sjavier.bueno@metempsy.comclass LTAGE(TAGE): 29913627Sjavier.bueno@metempsy.com type = 'LTAGE' 30013627Sjavier.bueno@metempsy.com cxx_class = 'LTAGE' 30113627Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/ltage.hh" 30213627Sjavier.bueno@metempsy.com 30313627Sjavier.bueno@metempsy.com tage = LTAGE_TAGE() 30413685Sjavier.bueno@metempsy.com 30513627Sjavier.bueno@metempsy.com loop_predictor = Param.LoopPredictor(LoopPredictor(), "Loop predictor") 30613685Sjavier.bueno@metempsy.com 30713685Sjavier.bueno@metempsy.comclass TAGE_SC_L_LoopPredictor(LoopPredictor): 30813685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_LoopPredictor' 30913685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_LoopPredictor' 31013685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l.hh" 31113685Sjavier.bueno@metempsy.com loopTableAgeBits = 4 31213685Sjavier.bueno@metempsy.com loopTableConfidenceBits = 4 31313685Sjavier.bueno@metempsy.com loopTableTagBits = 10 31413685Sjavier.bueno@metempsy.com loopTableIterBits = 10 31513685Sjavier.bueno@metempsy.com useSpeculation = False 31613685Sjavier.bueno@metempsy.com useHashing = True 31713685Sjavier.bueno@metempsy.com useDirectionBit = True 31813685Sjavier.bueno@metempsy.com restrictAllocation = True 31913685Sjavier.bueno@metempsy.com initialLoopIter = 0 32013685Sjavier.bueno@metempsy.com initialLoopAge = 7 32113685Sjavier.bueno@metempsy.com optionalAgeReset = False 32213685Sjavier.bueno@metempsy.com 32313685Sjavier.bueno@metempsy.comclass StatisticalCorrector(SimObject): 32413685Sjavier.bueno@metempsy.com type = 'StatisticalCorrector' 32513685Sjavier.bueno@metempsy.com cxx_class = 'StatisticalCorrector' 32613685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/statistical_corrector.hh" 32713685Sjavier.bueno@metempsy.com abstract = True 32813685Sjavier.bueno@metempsy.com 32913685Sjavier.bueno@metempsy.com # Statistical corrector parameters 33013685Sjavier.bueno@metempsy.com 33113685Sjavier.bueno@metempsy.com numEntriesFirstLocalHistories = Param.Unsigned( 33213685Sjavier.bueno@metempsy.com "Number of entries for first local histories") 33313685Sjavier.bueno@metempsy.com 33413685Sjavier.bueno@metempsy.com bwnb = Param.Unsigned("Num global backward branch GEHL lengths") 33513685Sjavier.bueno@metempsy.com bwm = VectorParam.Int("Global backward branch GEHL lengths") 33613685Sjavier.bueno@metempsy.com logBwnb = Param.Unsigned("Log num of global backward branch GEHL entries") 33713685Sjavier.bueno@metempsy.com 33813685Sjavier.bueno@metempsy.com lnb = Param.Unsigned("Num first local history GEHL lenghts") 33913685Sjavier.bueno@metempsy.com lm = VectorParam.Int("First local history GEHL lengths") 34013685Sjavier.bueno@metempsy.com logLnb = Param.Unsigned("Log number of first local history GEHL entries") 34113685Sjavier.bueno@metempsy.com 34213685Sjavier.bueno@metempsy.com inb = Param.Unsigned(1, "Num IMLI GEHL lenghts") 34313685Sjavier.bueno@metempsy.com im = VectorParam.Int([8], "IMLI history GEHL lengths") 34413685Sjavier.bueno@metempsy.com logInb = Param.Unsigned("Log number of IMLI GEHL entries") 34513685Sjavier.bueno@metempsy.com 34613685Sjavier.bueno@metempsy.com logBias = Param.Unsigned("Log size of Bias tables") 34713685Sjavier.bueno@metempsy.com 34813685Sjavier.bueno@metempsy.com logSizeUp = Param.Unsigned(6, 34913685Sjavier.bueno@metempsy.com "Log size of update threshold counters tables") 35013685Sjavier.bueno@metempsy.com 35113685Sjavier.bueno@metempsy.com chooserConfWidth = Param.Unsigned(7, 35213685Sjavier.bueno@metempsy.com "Number of bits for the chooser counters") 35313685Sjavier.bueno@metempsy.com 35413685Sjavier.bueno@metempsy.com updateThresholdWidth = Param.Unsigned(12, 35513685Sjavier.bueno@metempsy.com "Number of bits for the update threshold counter") 35613685Sjavier.bueno@metempsy.com 35713685Sjavier.bueno@metempsy.com pUpdateThresholdWidth = Param.Unsigned(8, 35813685Sjavier.bueno@metempsy.com "Number of bits for the pUpdate threshold counters") 35913685Sjavier.bueno@metempsy.com 36013685Sjavier.bueno@metempsy.com extraWeightsWidth = Param.Unsigned(6, 36113685Sjavier.bueno@metempsy.com "Number of bits for the extra weights") 36213685Sjavier.bueno@metempsy.com 36313685Sjavier.bueno@metempsy.com scCountersWidth = Param.Unsigned(6, "Statistical corrector counters width") 36413685Sjavier.bueno@metempsy.com 36513685Sjavier.bueno@metempsy.com# TAGE-SC-L branch predictor as desribed in 36613685Sjavier.bueno@metempsy.com# https://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf 36713685Sjavier.bueno@metempsy.com# It is a modified LTAGE predictor plus a statistical corrector predictor 36813685Sjavier.bueno@metempsy.com# The TAGE modifications include bank interleaving and partial associativity 36913685Sjavier.bueno@metempsy.com# Two different sizes are proposed in the paper: 37013685Sjavier.bueno@metempsy.com# 8KB => See TAGE_SC_L_8KB below 37113685Sjavier.bueno@metempsy.com# 64KB => See TAGE_SC_L_64KB below 37213685Sjavier.bueno@metempsy.com# The TAGE_SC_L_8KB and TAGE_SC_L_64KB classes differ not only on the values 37313685Sjavier.bueno@metempsy.com# of some parameters, but also in some implementation details 37413685Sjavier.bueno@metempsy.com# Given this, the TAGE_SC_L class is left abstract 37513685Sjavier.bueno@metempsy.com# Note that as it is now, this branch predictor does not handle any type 37613685Sjavier.bueno@metempsy.com# of speculation: All the structures/histories are updated at commit time 37713685Sjavier.bueno@metempsy.comclass TAGE_SC_L(LTAGE): 37813685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L' 37913685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L' 38013685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l.hh" 38113685Sjavier.bueno@metempsy.com abstract = True 38213685Sjavier.bueno@metempsy.com 38313685Sjavier.bueno@metempsy.com statistical_corrector = Param.StatisticalCorrector( 38413685Sjavier.bueno@metempsy.com "Statistical Corrector") 38513685Sjavier.bueno@metempsy.com 38613685Sjavier.bueno@metempsy.comclass TAGE_SC_L_64KB_LoopPredictor(TAGE_SC_L_LoopPredictor): 38713685Sjavier.bueno@metempsy.com logSizeLoopPred = 5 38813685Sjavier.bueno@metempsy.com 38913685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB_LoopPredictor(TAGE_SC_L_LoopPredictor): 39013685Sjavier.bueno@metempsy.com logSizeLoopPred = 3 39113685Sjavier.bueno@metempsy.com 39213685Sjavier.bueno@metempsy.comclass TAGE_SC_L_64KB_StatisticalCorrector(StatisticalCorrector): 39313685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_64KB_StatisticalCorrector' 39413685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_64KB_StatisticalCorrector' 39513685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_64KB.hh" 39613685Sjavier.bueno@metempsy.com 39713685Sjavier.bueno@metempsy.com pnb = Param.Unsigned(3, "Num variation global branch GEHL lengths") 39813685Sjavier.bueno@metempsy.com pm = VectorParam.Int([25, 16, 9], "Variation global branch GEHL lengths") 39913685Sjavier.bueno@metempsy.com logPnb = Param.Unsigned(9, 40013685Sjavier.bueno@metempsy.com "Log number of variation global branch GEHL entries") 40113685Sjavier.bueno@metempsy.com 40213685Sjavier.bueno@metempsy.com snb = Param.Unsigned(3, "Num second local history GEHL lenghts") 40313685Sjavier.bueno@metempsy.com sm = VectorParam.Int([16, 11, 6], "Second local history GEHL lengths") 40413685Sjavier.bueno@metempsy.com logSnb = Param.Unsigned(9, 40513685Sjavier.bueno@metempsy.com "Log number of second local history GEHL entries") 40613685Sjavier.bueno@metempsy.com 40713685Sjavier.bueno@metempsy.com tnb = Param.Unsigned(2, "Num third local history GEHL lenghts") 40813685Sjavier.bueno@metempsy.com tm = VectorParam.Int([9, 4], "Third local history GEHL lengths") 40913685Sjavier.bueno@metempsy.com logTnb = Param.Unsigned(10, 41013685Sjavier.bueno@metempsy.com "Log number of third local history GEHL entries") 41113685Sjavier.bueno@metempsy.com 41213685Sjavier.bueno@metempsy.com imnb = Param.Unsigned(2, "Num second IMLI GEHL lenghts") 41313685Sjavier.bueno@metempsy.com imm = VectorParam.Int([10, 4], "Second IMLI history GEHL lengths") 41413685Sjavier.bueno@metempsy.com logImnb = Param.Unsigned(9, "Log number of second IMLI GEHL entries") 41513685Sjavier.bueno@metempsy.com 41613685Sjavier.bueno@metempsy.com numEntriesSecondLocalHistories = Param.Unsigned(16, 41713685Sjavier.bueno@metempsy.com "Number of entries for second local histories") 41813685Sjavier.bueno@metempsy.com numEntriesThirdLocalHistories = Param.Unsigned(16, 41913685Sjavier.bueno@metempsy.com "Number of entries for second local histories") 42013685Sjavier.bueno@metempsy.com 42113685Sjavier.bueno@metempsy.com numEntriesFirstLocalHistories = 256 42213685Sjavier.bueno@metempsy.com 42313685Sjavier.bueno@metempsy.com logBias = 8 42413685Sjavier.bueno@metempsy.com 42513685Sjavier.bueno@metempsy.com bwnb = 3 42613685Sjavier.bueno@metempsy.com bwm = [40, 24, 10] 42713685Sjavier.bueno@metempsy.com logBwnb = 10 42813685Sjavier.bueno@metempsy.com 42913685Sjavier.bueno@metempsy.com lnb = 3 43013685Sjavier.bueno@metempsy.com lm = [11, 6, 3] 43113685Sjavier.bueno@metempsy.com logLnb = 10 43213685Sjavier.bueno@metempsy.com 43313685Sjavier.bueno@metempsy.com logInb = 8 43413685Sjavier.bueno@metempsy.com 43513685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB_StatisticalCorrector(StatisticalCorrector): 43613685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_8KB_StatisticalCorrector' 43713685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_8KB_StatisticalCorrector' 43813685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_8KB.hh" 43913685Sjavier.bueno@metempsy.com gnb = Param.Unsigned(2, "Num global branch GEHL lengths") 44013685Sjavier.bueno@metempsy.com gm = VectorParam.Int([6, 3], "Global branch GEHL lengths") 44113685Sjavier.bueno@metempsy.com logGnb = Param.Unsigned(7, "Log number of global branch GEHL entries") 44213685Sjavier.bueno@metempsy.com 44313685Sjavier.bueno@metempsy.com numEntriesFirstLocalHistories = 64 44413685Sjavier.bueno@metempsy.com 44513685Sjavier.bueno@metempsy.com logBias = 7 44613685Sjavier.bueno@metempsy.com 44713685Sjavier.bueno@metempsy.com bwnb = 2 44813685Sjavier.bueno@metempsy.com logBwnb = 7 44913685Sjavier.bueno@metempsy.com bwm = [16, 8] 45013685Sjavier.bueno@metempsy.com 45113685Sjavier.bueno@metempsy.com lnb = 2 45213685Sjavier.bueno@metempsy.com logLnb = 7 45313685Sjavier.bueno@metempsy.com lm = [6, 3] 45413685Sjavier.bueno@metempsy.com 45513685Sjavier.bueno@metempsy.com logInb = 7 45613685Sjavier.bueno@metempsy.com 45713685Sjavier.bueno@metempsy.com# 64KB TAGE-SC-L branch predictor as described in 45813685Sjavier.bueno@metempsy.com# http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf 45913685Sjavier.bueno@metempsy.comclass TAGE_SC_L_64KB(TAGE_SC_L): 46013685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_64KB' 46113685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_64KB' 46213685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_64KB.hh" 46313685Sjavier.bueno@metempsy.com 46413685Sjavier.bueno@metempsy.com tage = TAGE_SC_L_TAGE_64KB() 46513685Sjavier.bueno@metempsy.com loop_predictor = TAGE_SC_L_64KB_LoopPredictor() 46613685Sjavier.bueno@metempsy.com statistical_corrector = TAGE_SC_L_64KB_StatisticalCorrector() 46713685Sjavier.bueno@metempsy.com 46813685Sjavier.bueno@metempsy.com# 8KB TAGE-SC-L branch predictor as described in 46913685Sjavier.bueno@metempsy.com# http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf 47013685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB(TAGE_SC_L): 47113685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_8KB' 47213685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_8KB' 47313685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_8KB.hh" 47413685Sjavier.bueno@metempsy.com 47513685Sjavier.bueno@metempsy.com tage = TAGE_SC_L_TAGE_8KB() 47613685Sjavier.bueno@metempsy.com loop_predictor = TAGE_SC_L_8KB_LoopPredictor() 47713685Sjavier.bueno@metempsy.com statistical_corrector = TAGE_SC_L_8KB_StatisticalCorrector() 47814034Sjavier.bueno@metempsy.com 47914034Sjavier.bueno@metempsy.comclass MultiperspectivePerceptron(BranchPredictor): 48014034Sjavier.bueno@metempsy.com type = 'MultiperspectivePerceptron' 48114034Sjavier.bueno@metempsy.com cxx_class = 'MultiperspectivePerceptron' 48214034Sjavier.bueno@metempsy.com cxx_header = 'cpu/pred/multiperspective_perceptron.hh' 48314034Sjavier.bueno@metempsy.com abstract = True 48414034Sjavier.bueno@metempsy.com 48514034Sjavier.bueno@metempsy.com num_filter_entries = Param.Int("Number of filter entries") 48614034Sjavier.bueno@metempsy.com num_local_histories = Param.Int("Number of local history entries") 48714034Sjavier.bueno@metempsy.com local_history_length = Param.Int(11, 48814034Sjavier.bueno@metempsy.com "Length in bits of each history entry") 48914034Sjavier.bueno@metempsy.com 49014034Sjavier.bueno@metempsy.com block_size = Param.Int(21, 49114034Sjavier.bueno@metempsy.com "number of ghist bits in a 'block'; this is the width of an initial " 49214034Sjavier.bueno@metempsy.com "hash of ghist") 49314034Sjavier.bueno@metempsy.com pcshift = Param.Int(-10, "Shift for hashing PC") 49414034Sjavier.bueno@metempsy.com threshold = Param.Int(1, "Threshold for deciding low/high confidence") 49514034Sjavier.bueno@metempsy.com bias0 = Param.Int(-5, 49614034Sjavier.bueno@metempsy.com "Bias perceptron output this much on all-bits-zero local history") 49714034Sjavier.bueno@metempsy.com bias1 = Param.Int(5, 49814034Sjavier.bueno@metempsy.com "Bias perceptron output this much on all-bits-one local history") 49914034Sjavier.bueno@metempsy.com biasmostly0 = Param.Int(-1, 50014034Sjavier.bueno@metempsy.com "Bias perceptron output this much on almost-all-bits-zero local " 50114034Sjavier.bueno@metempsy.com "history") 50214034Sjavier.bueno@metempsy.com biasmostly1 = Param.Int(1, 50314034Sjavier.bueno@metempsy.com "Bias perceptron output this much on almost-all-bits-one local " 50414034Sjavier.bueno@metempsy.com "history") 50514034Sjavier.bueno@metempsy.com nbest = Param.Int(20, 50614034Sjavier.bueno@metempsy.com "Use this many of the top performing tables on a low-confidence " 50714034Sjavier.bueno@metempsy.com "branch") 50814034Sjavier.bueno@metempsy.com tunebits = Param.Int(24, "Number of bits in misprediction counters") 50914034Sjavier.bueno@metempsy.com hshift = Param.Int(-6, 51014034Sjavier.bueno@metempsy.com "How much to shift initial feauture hash before XORing with PC bits") 51114034Sjavier.bueno@metempsy.com imli_mask1 = Param.UInt64( 51214034Sjavier.bueno@metempsy.com "Which tables should have their indices hashed with the first IMLI " 51314034Sjavier.bueno@metempsy.com "counter") 51414034Sjavier.bueno@metempsy.com imli_mask4 = Param.UInt64( 51514034Sjavier.bueno@metempsy.com "Which tables should have their indices hashed with the fourth IMLI " 51614034Sjavier.bueno@metempsy.com "counter") 51714034Sjavier.bueno@metempsy.com recencypos_mask = Param.UInt64( 51814034Sjavier.bueno@metempsy.com "Which tables should have their indices hashed with the recency " 51914034Sjavier.bueno@metempsy.com "position") 52014034Sjavier.bueno@metempsy.com fudge = Param.Float(0.245, "Fudge factor to multiply by perceptron output") 52114034Sjavier.bueno@metempsy.com n_sign_bits = Param.Int(2, "Number of sign bits per magnitude") 52214034Sjavier.bueno@metempsy.com pcbit = Param.Int(2, "Bit from the PC to use for hashing global history") 52314034Sjavier.bueno@metempsy.com decay = Param.Int(0, "Whether and how often to decay a random weight") 52414034Sjavier.bueno@metempsy.com record_mask = Param.Int(191, 52514034Sjavier.bueno@metempsy.com "Which histories are updated with filtered branch outcomes") 52614034Sjavier.bueno@metempsy.com hash_taken = Param.Bool(False, 52714034Sjavier.bueno@metempsy.com "Hash the taken/not taken value with a PC bit") 52814034Sjavier.bueno@metempsy.com tuneonly = Param.Bool(True, 52914034Sjavier.bueno@metempsy.com "If true, only count mispredictions of low-confidence branches") 53014034Sjavier.bueno@metempsy.com extra_rounds = Param.Int(1, 53114034Sjavier.bueno@metempsy.com "Number of extra rounds of training a single weight on a " 53214034Sjavier.bueno@metempsy.com "low-confidence prediction") 53314034Sjavier.bueno@metempsy.com speed = Param.Int(9, "Adaptive theta learning speed") 53414034Sjavier.bueno@metempsy.com initial_theta = Param.Int(10, "Initial theta") 53514034Sjavier.bueno@metempsy.com budgetbits = Param.Int("Hardware budget in bits") 53614034Sjavier.bueno@metempsy.com speculative_update = Param.Bool(False, 53714034Sjavier.bueno@metempsy.com "Use speculative update for histories") 53814034Sjavier.bueno@metempsy.com 53914034Sjavier.bueno@metempsy.comclass MultiperspectivePerceptron8KB(MultiperspectivePerceptron): 54014034Sjavier.bueno@metempsy.com type = 'MultiperspectivePerceptron8KB' 54114034Sjavier.bueno@metempsy.com cxx_class = 'MultiperspectivePerceptron8KB' 54214034Sjavier.bueno@metempsy.com cxx_header = 'cpu/pred/multiperspective_perceptron_8KB.hh' 54314034Sjavier.bueno@metempsy.com budgetbits = 8192 * 8 + 2048 54414034Sjavier.bueno@metempsy.com num_local_histories = 48 54514034Sjavier.bueno@metempsy.com num_filter_entries = 0 54614034Sjavier.bueno@metempsy.com imli_mask1 = 0x6 54714034Sjavier.bueno@metempsy.com imli_mask4 = 0x4400 54814034Sjavier.bueno@metempsy.com recencypos_mask = 0x100000090 54914034Sjavier.bueno@metempsy.com 55014034Sjavier.bueno@metempsy.comclass MultiperspectivePerceptron64KB(MultiperspectivePerceptron): 55114034Sjavier.bueno@metempsy.com type = 'MultiperspectivePerceptron64KB' 55214034Sjavier.bueno@metempsy.com cxx_class = 'MultiperspectivePerceptron64KB' 55314034Sjavier.bueno@metempsy.com cxx_header = 'cpu/pred/multiperspective_perceptron_64KB.hh' 55414034Sjavier.bueno@metempsy.com budgetbits = 65536 * 8 + 2048 55514034Sjavier.bueno@metempsy.com num_local_histories = 510 55614034Sjavier.bueno@metempsy.com num_filter_entries = 18025 55714034Sjavier.bueno@metempsy.com imli_mask1 = 0xc1000 55814034Sjavier.bueno@metempsy.com imli_mask4 = 0x80008000 55914034Sjavier.bueno@metempsy.com recencypos_mask = 0x100000090 560