BranchPredictor.py revision 13685
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 349480Snilay@cs.wisc.educlass BranchPredictor(SimObject): 359480Snilay@cs.wisc.edu type = 'BranchPredictor' 369480Snilay@cs.wisc.edu cxx_class = 'BPredUnit' 379480Snilay@cs.wisc.edu cxx_header = "cpu/pred/bpred_unit.hh" 3810785Sgope@wisc.edu abstract = True 399480Snilay@cs.wisc.edu 4013432Spau.cabre@metempsy.com numThreads = Param.Unsigned(Parent.numThreads, "Number of threads") 4110785Sgope@wisc.edu BTBEntries = Param.Unsigned(4096, "Number of BTB entries") 4210785Sgope@wisc.edu BTBTagSize = Param.Unsigned(16, "Size of the BTB tags, in bits") 4310785Sgope@wisc.edu RASSize = Param.Unsigned(16, "RAS size") 4410785Sgope@wisc.edu instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by") 4510785Sgope@wisc.edu 4611433Smitch.hayenga@arm.com useIndirect = Param.Bool(True, "Use indirect branch predictor") 4711433Smitch.hayenga@arm.com indirectHashGHR = Param.Bool(True, "Hash branch predictor GHR") 4811433Smitch.hayenga@arm.com indirectHashTargets = Param.Bool(True, "Hash path history targets") 4911433Smitch.hayenga@arm.com indirectSets = Param.Unsigned(256, "Cache sets for indirect predictor") 5011433Smitch.hayenga@arm.com indirectWays = Param.Unsigned(2, "Ways for indirect predictor") 5111433Smitch.hayenga@arm.com indirectTagSize = Param.Unsigned(16, "Indirect target cache tag bits") 5211433Smitch.hayenga@arm.com indirectPathLength = Param.Unsigned(3, 5311433Smitch.hayenga@arm.com "Previous indirect targets to use for path history") 5411433Smitch.hayenga@arm.com 5511433Smitch.hayenga@arm.com 5610785Sgope@wisc.edu 5710785Sgope@wisc.educlass LocalBP(BranchPredictor): 5810785Sgope@wisc.edu type = 'LocalBP' 5910785Sgope@wisc.edu cxx_class = 'LocalBP' 6010785Sgope@wisc.edu cxx_header = "cpu/pred/2bit_local.hh" 6110785Sgope@wisc.edu 629480Snilay@cs.wisc.edu localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 639480Snilay@cs.wisc.edu localCtrBits = Param.Unsigned(2, "Bits per counter") 6410785Sgope@wisc.edu 6510785Sgope@wisc.edu 6610785Sgope@wisc.educlass TournamentBP(BranchPredictor): 6710785Sgope@wisc.edu type = 'TournamentBP' 6810785Sgope@wisc.edu cxx_class = 'TournamentBP' 6910785Sgope@wisc.edu cxx_header = "cpu/pred/tournament.hh" 7010785Sgope@wisc.edu 7110785Sgope@wisc.edu localPredictorSize = Param.Unsigned(2048, "Size of local predictor") 7210785Sgope@wisc.edu localCtrBits = Param.Unsigned(2, "Bits per counter") 7310785Sgope@wisc.edu localHistoryTableSize = Param.Unsigned(2048, "size of local history table") 749480Snilay@cs.wisc.edu globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 759480Snilay@cs.wisc.edu globalCtrBits = Param.Unsigned(2, "Bits per counter") 769480Snilay@cs.wisc.edu choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 779480Snilay@cs.wisc.edu choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 789480Snilay@cs.wisc.edu 799480Snilay@cs.wisc.edu 8010785Sgope@wisc.educlass BiModeBP(BranchPredictor): 8110785Sgope@wisc.edu type = 'BiModeBP' 8210785Sgope@wisc.edu cxx_class = 'BiModeBP' 8310785Sgope@wisc.edu cxx_header = "cpu/pred/bi_mode.hh" 8410785Sgope@wisc.edu 8510785Sgope@wisc.edu globalPredictorSize = Param.Unsigned(8192, "Size of global predictor") 8610785Sgope@wisc.edu globalCtrBits = Param.Unsigned(2, "Bits per counter") 8710785Sgope@wisc.edu choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor") 8810785Sgope@wisc.edu choiceCtrBits = Param.Unsigned(2, "Bits of choice counters") 8910785Sgope@wisc.edu 9013626Sjairo.balart@metempsy.comclass TAGEBase(SimObject): 9113626Sjairo.balart@metempsy.com type = 'TAGEBase' 9213626Sjairo.balart@metempsy.com cxx_class = 'TAGEBase' 9313626Sjairo.balart@metempsy.com cxx_header = "cpu/pred/tage_base.hh" 9413626Sjairo.balart@metempsy.com 9513626Sjairo.balart@metempsy.com numThreads = Param.Unsigned(Parent.numThreads, "Number of threads") 9613626Sjairo.balart@metempsy.com instShiftAmt = Param.Unsigned(Parent.instShiftAmt, 9713626Sjairo.balart@metempsy.com "Number of bits to shift instructions by") 9813454Spau.cabre@metempsy.com 9913454Spau.cabre@metempsy.com nHistoryTables = Param.Unsigned(7, "Number of history tables") 10013494Spau.cabre@metempsy.com minHist = Param.Unsigned(5, "Minimum history size of TAGE") 10113494Spau.cabre@metempsy.com maxHist = Param.Unsigned(130, "Maximum history size of TAGE") 10213454Spau.cabre@metempsy.com 10313454Spau.cabre@metempsy.com tagTableTagWidths = VectorParam.Unsigned( 10413454Spau.cabre@metempsy.com [0, 9, 9, 10, 10, 11, 11, 12], "Tag size in TAGE tag tables") 10513454Spau.cabre@metempsy.com logTagTableSizes = VectorParam.Int( 10613454Spau.cabre@metempsy.com [13, 9, 9, 9, 9, 9, 9, 9], "Log2 of TAGE table sizes") 10713454Spau.cabre@metempsy.com logRatioBiModalHystEntries = Param.Unsigned(2, 10813454Spau.cabre@metempsy.com "Log num of prediction entries for a shared hysteresis bit " \ 10913454Spau.cabre@metempsy.com "for the Bimodal") 11013454Spau.cabre@metempsy.com 11113454Spau.cabre@metempsy.com tagTableCounterBits = Param.Unsigned(3, "Number of tag table counter bits") 11213454Spau.cabre@metempsy.com tagTableUBits = Param.Unsigned(2, "Number of tag table u bits") 11313454Spau.cabre@metempsy.com 11413454Spau.cabre@metempsy.com histBufferSize = Param.Unsigned(2097152, 11513454Spau.cabre@metempsy.com "A large number to track all branch histories(2MEntries default)") 11613454Spau.cabre@metempsy.com 11713454Spau.cabre@metempsy.com pathHistBits = Param.Unsigned(16, "Path history size") 11813454Spau.cabre@metempsy.com logUResetPeriod = Param.Unsigned(18, 11913454Spau.cabre@metempsy.com "Log period in number of branches to reset TAGE useful counters") 12013626Sjairo.balart@metempsy.com numUseAltOnNa = Param.Unsigned(1, "Number of USE_ALT_ON_NA counters") 12113685Sjavier.bueno@metempsy.com useAltOnNaBits = Param.Unsigned(4, "Size of the USE_ALT_ON_NA counter(s)") 12213454Spau.cabre@metempsy.com 12313626Sjairo.balart@metempsy.com maxNumAlloc = Param.Unsigned(1, 12413626Sjairo.balart@metempsy.com "Max number of TAGE entries allocted on mispredict") 12513626Sjairo.balart@metempsy.com 12613626Sjairo.balart@metempsy.com # List of enabled TAGE tables. If empty, all are enabled 12713626Sjairo.balart@metempsy.com noSkip = VectorParam.Bool([], "Vector of enabled TAGE tables") 12813626Sjairo.balart@metempsy.com 12913626Sjairo.balart@metempsy.com speculativeHistUpdate = Param.Bool(True, 13013626Sjairo.balart@metempsy.com "Use speculative update for histories") 13113626Sjairo.balart@metempsy.com 13213626Sjairo.balart@metempsy.com# TAGE branch predictor as described in https://www.jilp.org/vol8/v8paper1.pdf 13313626Sjairo.balart@metempsy.com# The default sizes below are for the 8C-TAGE configuration (63.5 Kbits) 13413626Sjairo.balart@metempsy.comclass TAGE(BranchPredictor): 13513626Sjairo.balart@metempsy.com type = 'TAGE' 13613626Sjairo.balart@metempsy.com cxx_class = 'TAGE' 13713626Sjairo.balart@metempsy.com cxx_header = "cpu/pred/tage.hh" 13813626Sjairo.balart@metempsy.com tage = Param.TAGEBase(TAGEBase(), "Tage object") 13913626Sjairo.balart@metempsy.com 14013626Sjairo.balart@metempsy.comclass LTAGE_TAGE(TAGEBase): 14113626Sjairo.balart@metempsy.com nHistoryTables = 12 14213626Sjairo.balart@metempsy.com minHist = 4 14313626Sjairo.balart@metempsy.com maxHist = 640 14413626Sjairo.balart@metempsy.com tagTableTagWidths = [0, 7, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15] 14513626Sjairo.balart@metempsy.com logTagTableSizes = [14, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9] 14613626Sjairo.balart@metempsy.com logUResetPeriod = 19 14713454Spau.cabre@metempsy.com 14813627Sjavier.bueno@metempsy.comclass LoopPredictor(SimObject): 14913627Sjavier.bueno@metempsy.com type = 'LoopPredictor' 15013627Sjavier.bueno@metempsy.com cxx_class = 'LoopPredictor' 15113627Sjavier.bueno@metempsy.com cxx_header = 'cpu/pred/loop_predictor.hh' 15213454Spau.cabre@metempsy.com 15311784Sarthur.perais@inria.fr logSizeLoopPred = Param.Unsigned(8, "Log size of the loop predictor") 15413444Spau.cabre@metempsy.com withLoopBits = Param.Unsigned(7, "Size of the WITHLOOP counter") 15513442Spau.cabre@metempsy.com loopTableAgeBits = Param.Unsigned(8, "Number of age bits per loop entry") 15613442Spau.cabre@metempsy.com loopTableConfidenceBits = Param.Unsigned(2, 15713442Spau.cabre@metempsy.com "Number of confidence bits per loop entry") 15813442Spau.cabre@metempsy.com loopTableTagBits = Param.Unsigned(14, "Number of tag bits per loop entry") 15913442Spau.cabre@metempsy.com loopTableIterBits = Param.Unsigned(14, "Nuber of iteration bits per loop") 16013444Spau.cabre@metempsy.com logLoopTableAssoc = Param.Unsigned(2, "Log loop predictor associativity") 16113442Spau.cabre@metempsy.com 16213493Spau.cabre@metempsy.com # Parameters for enabling modifications to the loop predictor 16313627Sjavier.bueno@metempsy.com # They have been copied from TAGE-GSC-IMLI 16413627Sjavier.bueno@metempsy.com # (http://www.irisa.fr/alf/downloads/seznec/TAGE-GSC-IMLI.tar) 16513493Spau.cabre@metempsy.com # 16613493Spau.cabre@metempsy.com # All of them should be disabled to match the original LTAGE implementation 16713493Spau.cabre@metempsy.com # (http://hpca23.cse.tamu.edu/taco/camino/cbp2/cbp-src/realistic-seznec.h) 16813493Spau.cabre@metempsy.com 16913493Spau.cabre@metempsy.com # Add speculation 17013493Spau.cabre@metempsy.com useSpeculation = Param.Bool(False, "Use speculation") 17113493Spau.cabre@metempsy.com 17213493Spau.cabre@metempsy.com # Add hashing for calculating the loop table index 17313493Spau.cabre@metempsy.com useHashing = Param.Bool(False, "Use hashing") 17413493Spau.cabre@metempsy.com 17513493Spau.cabre@metempsy.com # Add a direction bit to the loop table entries 17613493Spau.cabre@metempsy.com useDirectionBit = Param.Bool(False, "Use direction info") 17713493Spau.cabre@metempsy.com 17813627Sjavier.bueno@metempsy.com # If true, use random to decide whether to allocate or not, and only try 17913627Sjavier.bueno@metempsy.com # with one entry 18013627Sjavier.bueno@metempsy.com restrictAllocation = Param.Bool(False, 18113627Sjavier.bueno@metempsy.com "Restrict the allocation conditions") 18213627Sjavier.bueno@metempsy.com 18313627Sjavier.bueno@metempsy.com initialLoopIter = Param.Unsigned(1, "Initial iteration number") 18413627Sjavier.bueno@metempsy.com initialLoopAge = Param.Unsigned(255, "Initial age value") 18513627Sjavier.bueno@metempsy.com optionalAgeReset = Param.Bool(True, 18613627Sjavier.bueno@metempsy.com "Reset age bits optionally in some cases") 18713627Sjavier.bueno@metempsy.com 18813685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE(TAGEBase): 18913685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_TAGE' 19013685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_TAGE' 19113685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l.hh" 19213685Sjavier.bueno@metempsy.com abstract = True 19313685Sjavier.bueno@metempsy.com tagTableTagWidths = [0] 19413685Sjavier.bueno@metempsy.com numUseAltOnNa = 16 19513685Sjavier.bueno@metempsy.com pathHistBits = 27 19613685Sjavier.bueno@metempsy.com maxNumAlloc = 2 19713685Sjavier.bueno@metempsy.com logUResetPeriod = 10 19813685Sjavier.bueno@metempsy.com useAltOnNaBits = 5 19913685Sjavier.bueno@metempsy.com # TODO No speculation implemented as of now 20013685Sjavier.bueno@metempsy.com speculativeHistUpdate = False 20113685Sjavier.bueno@metempsy.com 20213685Sjavier.bueno@metempsy.com # This size does not set the final sizes of the tables (it is just used 20313685Sjavier.bueno@metempsy.com # for some calculations) 20413685Sjavier.bueno@metempsy.com # Instead, the number of TAGE entries comes from shortTagsTageEntries and 20513685Sjavier.bueno@metempsy.com # longTagsTageEntries 20613685Sjavier.bueno@metempsy.com logTagTableSize = Param.Unsigned("Log size of each tag table") 20713685Sjavier.bueno@metempsy.com 20813685Sjavier.bueno@metempsy.com shortTagsTageFactor = Param.Unsigned( 20913685Sjavier.bueno@metempsy.com "Factor for calculating the total number of short tags TAGE entries") 21013685Sjavier.bueno@metempsy.com 21113685Sjavier.bueno@metempsy.com longTagsTageFactor = Param.Unsigned( 21213685Sjavier.bueno@metempsy.com "Factor for calculating the total number of long tags TAGE entries") 21313685Sjavier.bueno@metempsy.com 21413685Sjavier.bueno@metempsy.com shortTagsSize = Param.Unsigned(8, "Size of the short tags") 21513685Sjavier.bueno@metempsy.com 21613685Sjavier.bueno@metempsy.com longTagsSize = Param.Unsigned("Size of the long tags") 21713685Sjavier.bueno@metempsy.com 21813685Sjavier.bueno@metempsy.com firstLongTagTable = Param.Unsigned("First table with long tags") 21913685Sjavier.bueno@metempsy.com 22013685Sjavier.bueno@metempsy.com truncatePathHist = Param.Bool(True, 22113685Sjavier.bueno@metempsy.com "Truncate the path history to its configured size") 22213685Sjavier.bueno@metempsy.com 22313685Sjavier.bueno@metempsy.com 22413685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE_64KB(TAGE_SC_L_TAGE): 22513685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_TAGE_64KB' 22613685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_TAGE_64KB' 22713685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_64KB.hh" 22813685Sjavier.bueno@metempsy.com nHistoryTables = 36 22913685Sjavier.bueno@metempsy.com 23013685Sjavier.bueno@metempsy.com minHist = 6 23113685Sjavier.bueno@metempsy.com maxHist = 3000 23213685Sjavier.bueno@metempsy.com 23313685Sjavier.bueno@metempsy.com tagTableUBits = 1 23413685Sjavier.bueno@metempsy.com 23513685Sjavier.bueno@metempsy.com logTagTableSizes = [13] 23613685Sjavier.bueno@metempsy.com 23713685Sjavier.bueno@metempsy.com # This is used to handle the 2-way associativity 23813685Sjavier.bueno@metempsy.com # (all odd entries are set to one, and if the corresponding even entry 23913685Sjavier.bueno@metempsy.com # is set to one, then there is a 2-way associativity for this pair) 24013685Sjavier.bueno@metempsy.com # Entry 0 is for the bimodal and it is ignored 24113685Sjavier.bueno@metempsy.com # Note: For this implementation, some odd entries are also set to 0 to save 24213685Sjavier.bueno@metempsy.com # some bits 24313685Sjavier.bueno@metempsy.com noSkip = [0,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1, 24413685Sjavier.bueno@metempsy.com 1,1,1,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1] 24513685Sjavier.bueno@metempsy.com 24613685Sjavier.bueno@metempsy.com logTagTableSize = 10 24713685Sjavier.bueno@metempsy.com shortTagsTageFactor = 10 24813685Sjavier.bueno@metempsy.com longTagsTageFactor = 20 24913685Sjavier.bueno@metempsy.com 25013685Sjavier.bueno@metempsy.com longTagsSize = 12 25113685Sjavier.bueno@metempsy.com 25213685Sjavier.bueno@metempsy.com firstLongTagTable = 13 25313685Sjavier.bueno@metempsy.com 25413685Sjavier.bueno@metempsy.comclass TAGE_SC_L_TAGE_8KB(TAGE_SC_L_TAGE): 25513685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_TAGE_8KB' 25613685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_TAGE_8KB' 25713685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_8KB.hh" 25813685Sjavier.bueno@metempsy.com 25913685Sjavier.bueno@metempsy.com nHistoryTables = 30 26013685Sjavier.bueno@metempsy.com 26113685Sjavier.bueno@metempsy.com minHist = 4 26213685Sjavier.bueno@metempsy.com maxHist = 1000 26313685Sjavier.bueno@metempsy.com 26413685Sjavier.bueno@metempsy.com logTagTableSize = 7 26513685Sjavier.bueno@metempsy.com shortTagsTageFactor = 9 26613685Sjavier.bueno@metempsy.com longTagsTageFactor = 17 26713685Sjavier.bueno@metempsy.com longTagsSize = 12 26813685Sjavier.bueno@metempsy.com 26913685Sjavier.bueno@metempsy.com logTagTableSizes = [12] 27013685Sjavier.bueno@metempsy.com 27113685Sjavier.bueno@metempsy.com firstLongTagTable = 11 27213685Sjavier.bueno@metempsy.com 27313685Sjavier.bueno@metempsy.com truncatePathHist = False 27413685Sjavier.bueno@metempsy.com 27513685Sjavier.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] 27613685Sjavier.bueno@metempsy.com 27713685Sjavier.bueno@metempsy.com tagTableUBits = 2 27813627Sjavier.bueno@metempsy.com 27913627Sjavier.bueno@metempsy.com# LTAGE branch predictor as described in 28013627Sjavier.bueno@metempsy.com# https://www.irisa.fr/caps/people/seznec/L-TAGE.pdf 28113627Sjavier.bueno@metempsy.com# It is basically a TAGE predictor plus a loop predictor 28213627Sjavier.bueno@metempsy.com# The differnt TAGE sizes are updated according to the paper values (256 Kbits) 28313627Sjavier.bueno@metempsy.comclass LTAGE(TAGE): 28413627Sjavier.bueno@metempsy.com type = 'LTAGE' 28513627Sjavier.bueno@metempsy.com cxx_class = 'LTAGE' 28613627Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/ltage.hh" 28713627Sjavier.bueno@metempsy.com 28813627Sjavier.bueno@metempsy.com tage = LTAGE_TAGE() 28913685Sjavier.bueno@metempsy.com 29013627Sjavier.bueno@metempsy.com loop_predictor = Param.LoopPredictor(LoopPredictor(), "Loop predictor") 29113685Sjavier.bueno@metempsy.com 29213685Sjavier.bueno@metempsy.comclass TAGE_SC_L_LoopPredictor(LoopPredictor): 29313685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_LoopPredictor' 29413685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_LoopPredictor' 29513685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l.hh" 29613685Sjavier.bueno@metempsy.com loopTableAgeBits = 4 29713685Sjavier.bueno@metempsy.com loopTableConfidenceBits = 4 29813685Sjavier.bueno@metempsy.com loopTableTagBits = 10 29913685Sjavier.bueno@metempsy.com loopTableIterBits = 10 30013685Sjavier.bueno@metempsy.com useSpeculation = False 30113685Sjavier.bueno@metempsy.com useHashing = True 30213685Sjavier.bueno@metempsy.com useDirectionBit = True 30313685Sjavier.bueno@metempsy.com restrictAllocation = True 30413685Sjavier.bueno@metempsy.com initialLoopIter = 0 30513685Sjavier.bueno@metempsy.com initialLoopAge = 7 30613685Sjavier.bueno@metempsy.com optionalAgeReset = False 30713685Sjavier.bueno@metempsy.com 30813685Sjavier.bueno@metempsy.comclass StatisticalCorrector(SimObject): 30913685Sjavier.bueno@metempsy.com type = 'StatisticalCorrector' 31013685Sjavier.bueno@metempsy.com cxx_class = 'StatisticalCorrector' 31113685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/statistical_corrector.hh" 31213685Sjavier.bueno@metempsy.com abstract = True 31313685Sjavier.bueno@metempsy.com 31413685Sjavier.bueno@metempsy.com # Statistical corrector parameters 31513685Sjavier.bueno@metempsy.com 31613685Sjavier.bueno@metempsy.com numEntriesFirstLocalHistories = Param.Unsigned( 31713685Sjavier.bueno@metempsy.com "Number of entries for first local histories") 31813685Sjavier.bueno@metempsy.com 31913685Sjavier.bueno@metempsy.com bwnb = Param.Unsigned("Num global backward branch GEHL lengths") 32013685Sjavier.bueno@metempsy.com bwm = VectorParam.Int("Global backward branch GEHL lengths") 32113685Sjavier.bueno@metempsy.com logBwnb = Param.Unsigned("Log num of global backward branch GEHL entries") 32213685Sjavier.bueno@metempsy.com 32313685Sjavier.bueno@metempsy.com lnb = Param.Unsigned("Num first local history GEHL lenghts") 32413685Sjavier.bueno@metempsy.com lm = VectorParam.Int("First local history GEHL lengths") 32513685Sjavier.bueno@metempsy.com logLnb = Param.Unsigned("Log number of first local history GEHL entries") 32613685Sjavier.bueno@metempsy.com 32713685Sjavier.bueno@metempsy.com inb = Param.Unsigned(1, "Num IMLI GEHL lenghts") 32813685Sjavier.bueno@metempsy.com im = VectorParam.Int([8], "IMLI history GEHL lengths") 32913685Sjavier.bueno@metempsy.com logInb = Param.Unsigned("Log number of IMLI GEHL entries") 33013685Sjavier.bueno@metempsy.com 33113685Sjavier.bueno@metempsy.com logBias = Param.Unsigned("Log size of Bias tables") 33213685Sjavier.bueno@metempsy.com 33313685Sjavier.bueno@metempsy.com logSizeUp = Param.Unsigned(6, 33413685Sjavier.bueno@metempsy.com "Log size of update threshold counters tables") 33513685Sjavier.bueno@metempsy.com 33613685Sjavier.bueno@metempsy.com chooserConfWidth = Param.Unsigned(7, 33713685Sjavier.bueno@metempsy.com "Number of bits for the chooser counters") 33813685Sjavier.bueno@metempsy.com 33913685Sjavier.bueno@metempsy.com updateThresholdWidth = Param.Unsigned(12, 34013685Sjavier.bueno@metempsy.com "Number of bits for the update threshold counter") 34113685Sjavier.bueno@metempsy.com 34213685Sjavier.bueno@metempsy.com pUpdateThresholdWidth = Param.Unsigned(8, 34313685Sjavier.bueno@metempsy.com "Number of bits for the pUpdate threshold counters") 34413685Sjavier.bueno@metempsy.com 34513685Sjavier.bueno@metempsy.com extraWeightsWidth = Param.Unsigned(6, 34613685Sjavier.bueno@metempsy.com "Number of bits for the extra weights") 34713685Sjavier.bueno@metempsy.com 34813685Sjavier.bueno@metempsy.com scCountersWidth = Param.Unsigned(6, "Statistical corrector counters width") 34913685Sjavier.bueno@metempsy.com 35013685Sjavier.bueno@metempsy.com# TAGE-SC-L branch predictor as desribed in 35113685Sjavier.bueno@metempsy.com# https://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf 35213685Sjavier.bueno@metempsy.com# It is a modified LTAGE predictor plus a statistical corrector predictor 35313685Sjavier.bueno@metempsy.com# The TAGE modifications include bank interleaving and partial associativity 35413685Sjavier.bueno@metempsy.com# Two different sizes are proposed in the paper: 35513685Sjavier.bueno@metempsy.com# 8KB => See TAGE_SC_L_8KB below 35613685Sjavier.bueno@metempsy.com# 64KB => See TAGE_SC_L_64KB below 35713685Sjavier.bueno@metempsy.com# The TAGE_SC_L_8KB and TAGE_SC_L_64KB classes differ not only on the values 35813685Sjavier.bueno@metempsy.com# of some parameters, but also in some implementation details 35913685Sjavier.bueno@metempsy.com# Given this, the TAGE_SC_L class is left abstract 36013685Sjavier.bueno@metempsy.com# Note that as it is now, this branch predictor does not handle any type 36113685Sjavier.bueno@metempsy.com# of speculation: All the structures/histories are updated at commit time 36213685Sjavier.bueno@metempsy.comclass TAGE_SC_L(LTAGE): 36313685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L' 36413685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L' 36513685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l.hh" 36613685Sjavier.bueno@metempsy.com abstract = True 36713685Sjavier.bueno@metempsy.com 36813685Sjavier.bueno@metempsy.com statistical_corrector = Param.StatisticalCorrector( 36913685Sjavier.bueno@metempsy.com "Statistical Corrector") 37013685Sjavier.bueno@metempsy.com 37113685Sjavier.bueno@metempsy.comclass TAGE_SC_L_64KB_LoopPredictor(TAGE_SC_L_LoopPredictor): 37213685Sjavier.bueno@metempsy.com logSizeLoopPred = 5 37313685Sjavier.bueno@metempsy.com 37413685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB_LoopPredictor(TAGE_SC_L_LoopPredictor): 37513685Sjavier.bueno@metempsy.com logSizeLoopPred = 3 37613685Sjavier.bueno@metempsy.com 37713685Sjavier.bueno@metempsy.comclass TAGE_SC_L_64KB_StatisticalCorrector(StatisticalCorrector): 37813685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_64KB_StatisticalCorrector' 37913685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_64KB_StatisticalCorrector' 38013685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_64KB.hh" 38113685Sjavier.bueno@metempsy.com 38213685Sjavier.bueno@metempsy.com pnb = Param.Unsigned(3, "Num variation global branch GEHL lengths") 38313685Sjavier.bueno@metempsy.com pm = VectorParam.Int([25, 16, 9], "Variation global branch GEHL lengths") 38413685Sjavier.bueno@metempsy.com logPnb = Param.Unsigned(9, 38513685Sjavier.bueno@metempsy.com "Log number of variation global branch GEHL entries") 38613685Sjavier.bueno@metempsy.com 38713685Sjavier.bueno@metempsy.com snb = Param.Unsigned(3, "Num second local history GEHL lenghts") 38813685Sjavier.bueno@metempsy.com sm = VectorParam.Int([16, 11, 6], "Second local history GEHL lengths") 38913685Sjavier.bueno@metempsy.com logSnb = Param.Unsigned(9, 39013685Sjavier.bueno@metempsy.com "Log number of second local history GEHL entries") 39113685Sjavier.bueno@metempsy.com 39213685Sjavier.bueno@metempsy.com tnb = Param.Unsigned(2, "Num third local history GEHL lenghts") 39313685Sjavier.bueno@metempsy.com tm = VectorParam.Int([9, 4], "Third local history GEHL lengths") 39413685Sjavier.bueno@metempsy.com logTnb = Param.Unsigned(10, 39513685Sjavier.bueno@metempsy.com "Log number of third local history GEHL entries") 39613685Sjavier.bueno@metempsy.com 39713685Sjavier.bueno@metempsy.com imnb = Param.Unsigned(2, "Num second IMLI GEHL lenghts") 39813685Sjavier.bueno@metempsy.com imm = VectorParam.Int([10, 4], "Second IMLI history GEHL lengths") 39913685Sjavier.bueno@metempsy.com logImnb = Param.Unsigned(9, "Log number of second IMLI GEHL entries") 40013685Sjavier.bueno@metempsy.com 40113685Sjavier.bueno@metempsy.com numEntriesSecondLocalHistories = Param.Unsigned(16, 40213685Sjavier.bueno@metempsy.com "Number of entries for second local histories") 40313685Sjavier.bueno@metempsy.com numEntriesThirdLocalHistories = Param.Unsigned(16, 40413685Sjavier.bueno@metempsy.com "Number of entries for second local histories") 40513685Sjavier.bueno@metempsy.com 40613685Sjavier.bueno@metempsy.com numEntriesFirstLocalHistories = 256 40713685Sjavier.bueno@metempsy.com 40813685Sjavier.bueno@metempsy.com logBias = 8 40913685Sjavier.bueno@metempsy.com 41013685Sjavier.bueno@metempsy.com bwnb = 3 41113685Sjavier.bueno@metempsy.com bwm = [40, 24, 10] 41213685Sjavier.bueno@metempsy.com logBwnb = 10 41313685Sjavier.bueno@metempsy.com 41413685Sjavier.bueno@metempsy.com lnb = 3 41513685Sjavier.bueno@metempsy.com lm = [11, 6, 3] 41613685Sjavier.bueno@metempsy.com logLnb = 10 41713685Sjavier.bueno@metempsy.com 41813685Sjavier.bueno@metempsy.com logInb = 8 41913685Sjavier.bueno@metempsy.com 42013685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB_StatisticalCorrector(StatisticalCorrector): 42113685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_8KB_StatisticalCorrector' 42213685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_8KB_StatisticalCorrector' 42313685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_8KB.hh" 42413685Sjavier.bueno@metempsy.com gnb = Param.Unsigned(2, "Num global branch GEHL lengths") 42513685Sjavier.bueno@metempsy.com gm = VectorParam.Int([6, 3], "Global branch GEHL lengths") 42613685Sjavier.bueno@metempsy.com logGnb = Param.Unsigned(7, "Log number of global branch GEHL entries") 42713685Sjavier.bueno@metempsy.com 42813685Sjavier.bueno@metempsy.com numEntriesFirstLocalHistories = 64 42913685Sjavier.bueno@metempsy.com 43013685Sjavier.bueno@metempsy.com logBias = 7 43113685Sjavier.bueno@metempsy.com 43213685Sjavier.bueno@metempsy.com bwnb = 2 43313685Sjavier.bueno@metempsy.com logBwnb = 7 43413685Sjavier.bueno@metempsy.com bwm = [16, 8] 43513685Sjavier.bueno@metempsy.com 43613685Sjavier.bueno@metempsy.com lnb = 2 43713685Sjavier.bueno@metempsy.com logLnb = 7 43813685Sjavier.bueno@metempsy.com lm = [6, 3] 43913685Sjavier.bueno@metempsy.com 44013685Sjavier.bueno@metempsy.com logInb = 7 44113685Sjavier.bueno@metempsy.com 44213685Sjavier.bueno@metempsy.com# 64KB TAGE-SC-L branch predictor as described in 44313685Sjavier.bueno@metempsy.com# http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf 44413685Sjavier.bueno@metempsy.comclass TAGE_SC_L_64KB(TAGE_SC_L): 44513685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_64KB' 44613685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_64KB' 44713685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_64KB.hh" 44813685Sjavier.bueno@metempsy.com 44913685Sjavier.bueno@metempsy.com tage = TAGE_SC_L_TAGE_64KB() 45013685Sjavier.bueno@metempsy.com loop_predictor = TAGE_SC_L_64KB_LoopPredictor() 45113685Sjavier.bueno@metempsy.com statistical_corrector = TAGE_SC_L_64KB_StatisticalCorrector() 45213685Sjavier.bueno@metempsy.com 45313685Sjavier.bueno@metempsy.com# 8KB TAGE-SC-L branch predictor as described in 45413685Sjavier.bueno@metempsy.com# http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf 45513685Sjavier.bueno@metempsy.comclass TAGE_SC_L_8KB(TAGE_SC_L): 45613685Sjavier.bueno@metempsy.com type = 'TAGE_SC_L_8KB' 45713685Sjavier.bueno@metempsy.com cxx_class = 'TAGE_SC_L_8KB' 45813685Sjavier.bueno@metempsy.com cxx_header = "cpu/pred/tage_sc_l_8KB.hh" 45913685Sjavier.bueno@metempsy.com 46013685Sjavier.bueno@metempsy.com tage = TAGE_SC_L_TAGE_8KB() 46113685Sjavier.bueno@metempsy.com loop_predictor = TAGE_SC_L_8KB_LoopPredictor() 46213685Sjavier.bueno@metempsy.com statistical_corrector = TAGE_SC_L_8KB_StatisticalCorrector() 463