BranchPredictor.py revision 14034
12929Sktlim@umich.edu# Copyright (c) 2012 Mark D. Hill and David A. Wood
22929Sktlim@umich.edu# Copyright (c) 2015 The University of Wisconsin
32932Sktlim@umich.edu# All rights reserved.
42929Sktlim@umich.edu#
52929Sktlim@umich.edu# Redistribution and use in source and binary forms, with or without
62929Sktlim@umich.edu# modification, are permitted provided that the following conditions are
72929Sktlim@umich.edu# met: redistributions of source code must retain the above copyright
82929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer;
92929Sktlim@umich.edu# redistributions in binary form must reproduce the above copyright
102929Sktlim@umich.edu# notice, this list of conditions and the following disclaimer in the
112929Sktlim@umich.edu# documentation and/or other materials provided with the distribution;
122929Sktlim@umich.edu# neither the name of the copyright holders nor the names of its
132929Sktlim@umich.edu# contributors may be used to endorse or promote products derived from
142929Sktlim@umich.edu# this software without specific prior written permission.
152929Sktlim@umich.edu#
162929Sktlim@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172929Sktlim@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182929Sktlim@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192929Sktlim@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202929Sktlim@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212929Sktlim@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222929Sktlim@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232929Sktlim@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242929Sktlim@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252929Sktlim@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262929Sktlim@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272929Sktlim@umich.edu#
282932Sktlim@umich.edu# Authors: Nilay Vaish and Dibakar Gope
292932Sktlim@umich.edu
302932Sktlim@umich.edufrom m5.SimObject import SimObject
312929Sktlim@umich.edufrom m5.params import *
326007Ssteve.reinhardt@amd.comfrom m5.proxy import *
337735SAli.Saidi@ARM.com
342929Sktlim@umich.educlass IndirectPredictor(SimObject):
352929Sktlim@umich.edu    type = 'IndirectPredictor'
362929Sktlim@umich.edu    cxx_class = 'IndirectPredictor'
372929Sktlim@umich.edu    cxx_header = "cpu/pred/indirect.hh"
382929Sktlim@umich.edu    abstract = True
392929Sktlim@umich.edu
402929Sktlim@umich.edu    numThreads = Param.Unsigned(Parent.numThreads, "Number of threads")
412929Sktlim@umich.edu
422929Sktlim@umich.educlass SimpleIndirectPredictor(IndirectPredictor):
432929Sktlim@umich.edu    type = 'SimpleIndirectPredictor'
442929Sktlim@umich.edu    cxx_class = 'SimpleIndirectPredictor'
452929Sktlim@umich.edu    cxx_header = "cpu/pred/simple_indirect.hh"
462929Sktlim@umich.edu
476007Ssteve.reinhardt@amd.com    indirectHashGHR = Param.Bool(True, "Hash branch predictor GHR")
486007Ssteve.reinhardt@amd.com    indirectHashTargets = Param.Bool(True, "Hash path history targets")
496007Ssteve.reinhardt@amd.com    indirectSets = Param.Unsigned(256, "Cache sets for indirect predictor")
506007Ssteve.reinhardt@amd.com    indirectWays = Param.Unsigned(2, "Ways for indirect predictor")
516007Ssteve.reinhardt@amd.com    indirectTagSize = Param.Unsigned(16, "Indirect target cache tag bits")
526007Ssteve.reinhardt@amd.com    indirectPathLength = Param.Unsigned(3,
536007Ssteve.reinhardt@amd.com        "Previous indirect targets to use for path history")
546007Ssteve.reinhardt@amd.com    indirectGHRBits = Param.Unsigned(13, "Indirect GHR number of bits")
556007Ssteve.reinhardt@amd.com    instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by")
566007Ssteve.reinhardt@amd.com
576007Ssteve.reinhardt@amd.comclass BranchPredictor(SimObject):
586007Ssteve.reinhardt@amd.com    type = 'BranchPredictor'
596007Ssteve.reinhardt@amd.com    cxx_class = 'BPredUnit'
606007Ssteve.reinhardt@amd.com    cxx_header = "cpu/pred/bpred_unit.hh"
616007Ssteve.reinhardt@amd.com    abstract = True
626007Ssteve.reinhardt@amd.com
636007Ssteve.reinhardt@amd.com    numThreads = Param.Unsigned(Parent.numThreads, "Number of threads")
646007Ssteve.reinhardt@amd.com    BTBEntries = Param.Unsigned(4096, "Number of BTB entries")
656007Ssteve.reinhardt@amd.com    BTBTagSize = Param.Unsigned(16, "Size of the BTB tags, in bits")
666007Ssteve.reinhardt@amd.com    RASSize = Param.Unsigned(16, "RAS size")
676007Ssteve.reinhardt@amd.com    instShiftAmt = Param.Unsigned(2, "Number of bits to shift instructions by")
686007Ssteve.reinhardt@amd.com
696007Ssteve.reinhardt@amd.com    indirectBranchPred = Param.IndirectPredictor(SimpleIndirectPredictor(),
706007Ssteve.reinhardt@amd.com      "Indirect branch predictor, set to NULL to disable indirect predictions")
716007Ssteve.reinhardt@amd.com
726007Ssteve.reinhardt@amd.comclass LocalBP(BranchPredictor):
736007Ssteve.reinhardt@amd.com    type = 'LocalBP'
746007Ssteve.reinhardt@amd.com    cxx_class = 'LocalBP'
756007Ssteve.reinhardt@amd.com    cxx_header = "cpu/pred/2bit_local.hh"
762929Sktlim@umich.edu
772929Sktlim@umich.edu    localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
782929Sktlim@umich.edu    localCtrBits = Param.Unsigned(2, "Bits per counter")
796007Ssteve.reinhardt@amd.com
806007Ssteve.reinhardt@amd.com
816007Ssteve.reinhardt@amd.comclass TournamentBP(BranchPredictor):
826007Ssteve.reinhardt@amd.com    type = 'TournamentBP'
836007Ssteve.reinhardt@amd.com    cxx_class = 'TournamentBP'
846007Ssteve.reinhardt@amd.com    cxx_header = "cpu/pred/tournament.hh"
852929Sktlim@umich.edu
862929Sktlim@umich.edu    localPredictorSize = Param.Unsigned(2048, "Size of local predictor")
872929Sktlim@umich.edu    localCtrBits = Param.Unsigned(2, "Bits per counter")
882929Sktlim@umich.edu    localHistoryTableSize = Param.Unsigned(2048, "size of local history table")
892929Sktlim@umich.edu    globalPredictorSize = Param.Unsigned(8192, "Size of global predictor")
906011Ssteve.reinhardt@amd.com    globalCtrBits = Param.Unsigned(2, "Bits per counter")
916007Ssteve.reinhardt@amd.com    choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor")
926007Ssteve.reinhardt@amd.com    choiceCtrBits = Param.Unsigned(2, "Bits of choice counters")
936007Ssteve.reinhardt@amd.com
946007Ssteve.reinhardt@amd.com
956007Ssteve.reinhardt@amd.comclass BiModeBP(BranchPredictor):
966007Ssteve.reinhardt@amd.com    type = 'BiModeBP'
976007Ssteve.reinhardt@amd.com    cxx_class = 'BiModeBP'
986007Ssteve.reinhardt@amd.com    cxx_header = "cpu/pred/bi_mode.hh"
996007Ssteve.reinhardt@amd.com
1006007Ssteve.reinhardt@amd.com    globalPredictorSize = Param.Unsigned(8192, "Size of global predictor")
1016007Ssteve.reinhardt@amd.com    globalCtrBits = Param.Unsigned(2, "Bits per counter")
1026007Ssteve.reinhardt@amd.com    choicePredictorSize = Param.Unsigned(8192, "Size of choice predictor")
1036007Ssteve.reinhardt@amd.com    choiceCtrBits = Param.Unsigned(2, "Bits of choice counters")
1046007Ssteve.reinhardt@amd.com
1057735SAli.Saidi@ARM.comclass TAGEBase(SimObject):
1066011Ssteve.reinhardt@amd.com    type = 'TAGEBase'
1076007Ssteve.reinhardt@amd.com    cxx_class = 'TAGEBase'
1086007Ssteve.reinhardt@amd.com    cxx_header = "cpu/pred/tage_base.hh"
1096007Ssteve.reinhardt@amd.com
1106007Ssteve.reinhardt@amd.com    numThreads = Param.Unsigned(Parent.numThreads, "Number of threads")
1117735SAli.Saidi@ARM.com    instShiftAmt = Param.Unsigned(Parent.instShiftAmt,
1127735SAli.Saidi@ARM.com        "Number of bits to shift instructions by")
1137735SAli.Saidi@ARM.com
1147735SAli.Saidi@ARM.com    nHistoryTables = Param.Unsigned(7, "Number of history tables")
1157735SAli.Saidi@ARM.com    minHist = Param.Unsigned(5, "Minimum history size of TAGE")
1167735SAli.Saidi@ARM.com    maxHist = Param.Unsigned(130, "Maximum history size of TAGE")
1177735SAli.Saidi@ARM.com
1187735SAli.Saidi@ARM.com    tagTableTagWidths = VectorParam.Unsigned(
1197735SAli.Saidi@ARM.com        [0, 9, 9, 10, 10, 11, 11, 12], "Tag size in TAGE tag tables")
1207735SAli.Saidi@ARM.com    logTagTableSizes = VectorParam.Int(
1217735SAli.Saidi@ARM.com        [13, 9, 9, 9, 9, 9, 9, 9], "Log2 of TAGE table sizes")
1227735SAli.Saidi@ARM.com    logRatioBiModalHystEntries = Param.Unsigned(2,
1237735SAli.Saidi@ARM.com        "Log num of prediction entries for a shared hysteresis bit " \
1247735SAli.Saidi@ARM.com        "for the Bimodal")
1256007Ssteve.reinhardt@amd.com
1267685Ssteve.reinhardt@amd.com    tagTableCounterBits = Param.Unsigned(3, "Number of tag table counter bits")
1276007Ssteve.reinhardt@amd.com    tagTableUBits = Param.Unsigned(2, "Number of tag table u bits")
1286011Ssteve.reinhardt@amd.com
1296007Ssteve.reinhardt@amd.com    histBufferSize = Param.Unsigned(2097152,
1306007Ssteve.reinhardt@amd.com            "A large number to track all branch histories(2MEntries default)")
1316007Ssteve.reinhardt@amd.com
1326007Ssteve.reinhardt@amd.com    pathHistBits = Param.Unsigned(16, "Path history size")
1336007Ssteve.reinhardt@amd.com    logUResetPeriod = Param.Unsigned(18,
1346007Ssteve.reinhardt@amd.com        "Log period in number of branches to reset TAGE useful counters")
1356011Ssteve.reinhardt@amd.com    numUseAltOnNa = Param.Unsigned(1, "Number of USE_ALT_ON_NA counters")
1366007Ssteve.reinhardt@amd.com    useAltOnNaBits = Param.Unsigned(4, "Size of the USE_ALT_ON_NA counter(s)")
1376007Ssteve.reinhardt@amd.com
1386007Ssteve.reinhardt@amd.com    maxNumAlloc = Param.Unsigned(1,
1396007Ssteve.reinhardt@amd.com        "Max number of TAGE entries allocted on mispredict")
1406007Ssteve.reinhardt@amd.com
1416008Ssteve.reinhardt@amd.com    # List of enabled TAGE tables. If empty, all are enabled
1426007Ssteve.reinhardt@amd.com    noSkip = VectorParam.Bool([], "Vector of enabled TAGE tables")
1436008Ssteve.reinhardt@amd.com
1446008Ssteve.reinhardt@amd.com    speculativeHistUpdate = Param.Bool(True,
1456008Ssteve.reinhardt@amd.com        "Use speculative update for histories")
1466008Ssteve.reinhardt@amd.com
1476008Ssteve.reinhardt@amd.com# TAGE branch predictor as described in https://www.jilp.org/vol8/v8paper1.pdf
1486008Ssteve.reinhardt@amd.com# The default sizes below are for the 8C-TAGE configuration (63.5 Kbits)
1496008Ssteve.reinhardt@amd.comclass TAGE(BranchPredictor):
1506007Ssteve.reinhardt@amd.com    type = 'TAGE'
1516007Ssteve.reinhardt@amd.com    cxx_class = 'TAGE'
1526007Ssteve.reinhardt@amd.com    cxx_header = "cpu/pred/tage.hh"
1536007Ssteve.reinhardt@amd.com    tage = Param.TAGEBase(TAGEBase(), "Tage object")
1546007Ssteve.reinhardt@amd.com
1552929Sktlim@umich.educlass LTAGE_TAGE(TAGEBase):
1562929Sktlim@umich.edu    nHistoryTables = 12
1572929Sktlim@umich.edu    minHist = 4
1582929Sktlim@umich.edu    maxHist = 640
1596007Ssteve.reinhardt@amd.com    tagTableTagWidths = [0, 7, 7, 8, 8, 9, 10, 11, 12, 12, 13, 14, 15]
1606007Ssteve.reinhardt@amd.com    logTagTableSizes = [14, 10, 10, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9]
1612929Sktlim@umich.edu    logUResetPeriod = 19
1622929Sktlim@umich.edu
1632929Sktlim@umich.educlass LoopPredictor(SimObject):
1642929Sktlim@umich.edu    type = 'LoopPredictor'
1656007Ssteve.reinhardt@amd.com    cxx_class = 'LoopPredictor'
1666007Ssteve.reinhardt@amd.com    cxx_header = 'cpu/pred/loop_predictor.hh'
1672929Sktlim@umich.edu
1682929Sktlim@umich.edu    logSizeLoopPred = Param.Unsigned(8, "Log size of the loop predictor")
1696007Ssteve.reinhardt@amd.com    withLoopBits = Param.Unsigned(7, "Size of the WITHLOOP counter")
1702929Sktlim@umich.edu    loopTableAgeBits = Param.Unsigned(8, "Number of age bits per loop entry")
1712929Sktlim@umich.edu    loopTableConfidenceBits = Param.Unsigned(2,
1722929Sktlim@umich.edu            "Number of confidence bits per loop entry")
1732929Sktlim@umich.edu    loopTableTagBits = Param.Unsigned(14, "Number of tag bits per loop entry")
1742929Sktlim@umich.edu    loopTableIterBits = Param.Unsigned(14, "Nuber of iteration bits per loop")
1752929Sktlim@umich.edu    logLoopTableAssoc = Param.Unsigned(2, "Log loop predictor associativity")
1762929Sktlim@umich.edu
1774937Sstever@gmail.com    # Parameters for enabling modifications to the loop predictor
1784937Sstever@gmail.com    # They have been copied from TAGE-GSC-IMLI
1794937Sstever@gmail.com    # (http://www.irisa.fr/alf/downloads/seznec/TAGE-GSC-IMLI.tar)
1804937Sstever@gmail.com    #
1818120Sgblack@eecs.umich.edu    # All of them should be disabled to match the original LTAGE implementation
1824937Sstever@gmail.com    # (http://hpca23.cse.tamu.edu/taco/camino/cbp2/cbp-src/realistic-seznec.h)
1834937Sstever@gmail.com
1844937Sstever@gmail.com    # Add speculation
1854937Sstever@gmail.com    useSpeculation = Param.Bool(False, "Use speculation")
1865773Snate@binkert.org
1874937Sstever@gmail.com    # Add hashing for calculating the loop table index
1884937Sstever@gmail.com    useHashing = Param.Bool(False, "Use hashing")
1894937Sstever@gmail.com
1902929Sktlim@umich.edu    # Add a direction bit to the loop table entries
1912929Sktlim@umich.edu    useDirectionBit = Param.Bool(False, "Use direction info")
1922929Sktlim@umich.edu
1935773Snate@binkert.org    # If true, use random to decide whether to allocate or not, and only try
1942929Sktlim@umich.edu    # with one entry
1952929Sktlim@umich.edu    restrictAllocation = Param.Bool(False,
1962929Sktlim@umich.edu        "Restrict the allocation conditions")
1972929Sktlim@umich.edu
1982929Sktlim@umich.edu    initialLoopIter = Param.Unsigned(1, "Initial iteration number")
1992929Sktlim@umich.edu    initialLoopAge = Param.Unsigned(255, "Initial age value")
2004937Sstever@gmail.com    optionalAgeReset = Param.Bool(True,
2014937Sstever@gmail.com        "Reset age bits optionally in some cases")
2024937Sstever@gmail.com
2034937Sstever@gmail.comclass TAGE_SC_L_TAGE(TAGEBase):
2044937Sstever@gmail.com    type = 'TAGE_SC_L_TAGE'
2054937Sstever@gmail.com    cxx_class = 'TAGE_SC_L_TAGE'
2064937Sstever@gmail.com    cxx_header = "cpu/pred/tage_sc_l.hh"
2074937Sstever@gmail.com    abstract = True
2084937Sstever@gmail.com    tagTableTagWidths = [0]
2094937Sstever@gmail.com    numUseAltOnNa = 16
2104937Sstever@gmail.com    pathHistBits = 27
2114937Sstever@gmail.com    maxNumAlloc = 2
2124937Sstever@gmail.com    logUResetPeriod = 10
2134937Sstever@gmail.com    useAltOnNaBits = 5
2144937Sstever@gmail.com    # TODO No speculation implemented as of now
2152929Sktlim@umich.edu    speculativeHistUpdate = False
2162929Sktlim@umich.edu
2172929Sktlim@umich.edu    # This size does not set the final sizes of the tables (it is just used
2182929Sktlim@umich.edu    # for some calculations)
2192929Sktlim@umich.edu    # Instead, the number of TAGE entries comes from shortTagsTageEntries and
2202929Sktlim@umich.edu    # longTagsTageEntries
2212929Sktlim@umich.edu    logTagTableSize = Param.Unsigned("Log size of each tag table")
2226011Ssteve.reinhardt@amd.com
2232929Sktlim@umich.edu    shortTagsTageFactor = Param.Unsigned(
2242929Sktlim@umich.edu        "Factor for calculating the total number of short tags TAGE entries")
2252929Sktlim@umich.edu
2262929Sktlim@umich.edu    longTagsTageFactor = Param.Unsigned(
2272929Sktlim@umich.edu        "Factor for calculating the total number of long tags TAGE entries")
2282929Sktlim@umich.edu
2292929Sktlim@umich.edu    shortTagsSize = Param.Unsigned(8, "Size of the short tags")
2302929Sktlim@umich.edu
2312997Sstever@eecs.umich.edu    longTagsSize = Param.Unsigned("Size of the long tags")
2322997Sstever@eecs.umich.edu
2332929Sktlim@umich.edu    firstLongTagTable = Param.Unsigned("First table with long tags")
2342997Sstever@eecs.umich.edu
2352997Sstever@eecs.umich.edu    truncatePathHist = Param.Bool(True,
2362929Sktlim@umich.edu        "Truncate the path history to its configured size")
2372997Sstever@eecs.umich.edu
2382997Sstever@eecs.umich.edu
2392997Sstever@eecs.umich.educlass TAGE_SC_L_TAGE_64KB(TAGE_SC_L_TAGE):
2402929Sktlim@umich.edu    type = 'TAGE_SC_L_TAGE_64KB'
2412997Sstever@eecs.umich.edu    cxx_class = 'TAGE_SC_L_TAGE_64KB'
2422997Sstever@eecs.umich.edu    cxx_header = "cpu/pred/tage_sc_l_64KB.hh"
2432997Sstever@eecs.umich.edu    nHistoryTables = 36
2442997Sstever@eecs.umich.edu
2455773Snate@binkert.org    minHist = 6
2465773Snate@binkert.org    maxHist = 3000
2472997Sstever@eecs.umich.edu
2482997Sstever@eecs.umich.edu    tagTableUBits = 1
2496007Ssteve.reinhardt@amd.com
2506007Ssteve.reinhardt@amd.com    logTagTableSizes = [13]
2512997Sstever@eecs.umich.edu
2522929Sktlim@umich.edu    # This is used to handle the 2-way associativity
2532997Sstever@eecs.umich.edu    # (all odd entries are set to one, and if the corresponding even entry
2548120Sgblack@eecs.umich.edu    # is set to one, then there is a 2-way associativity for this pair)
2552997Sstever@eecs.umich.edu    # Entry 0 is for the bimodal and it is ignored
2562997Sstever@eecs.umich.edu    # Note: For this implementation, some odd entries are also set to 0 to save
2572997Sstever@eecs.umich.edu    # some bits
2582997Sstever@eecs.umich.edu    noSkip = [0,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,
2592997Sstever@eecs.umich.edu                1,1,1,1,0,1,0,1,0,1,0,0,0,1,0,0,0,1]
2602929Sktlim@umich.edu
2612997Sstever@eecs.umich.edu    logTagTableSize = 10
2622929Sktlim@umich.edu    shortTagsTageFactor = 10
2632929Sktlim@umich.edu    longTagsTageFactor = 20
2643005Sstever@eecs.umich.edu
2653005Sstever@eecs.umich.edu    longTagsSize = 12
2663005Sstever@eecs.umich.edu
2673005Sstever@eecs.umich.edu    firstLongTagTable = 13
2686025Snate@binkert.org
2696025Snate@binkert.orgclass TAGE_SC_L_TAGE_8KB(TAGE_SC_L_TAGE):
2706025Snate@binkert.org    type = 'TAGE_SC_L_TAGE_8KB'
2716025Snate@binkert.org    cxx_class = 'TAGE_SC_L_TAGE_8KB'
2726025Snate@binkert.org    cxx_header = "cpu/pred/tage_sc_l_8KB.hh"
2736025Snate@binkert.org
2744130Ssaidi@eecs.umich.edu    nHistoryTables = 30
2754130Ssaidi@eecs.umich.edu
2764130Ssaidi@eecs.umich.edu    minHist = 4
2777735SAli.Saidi@ARM.com    maxHist = 1000
2787735SAli.Saidi@ARM.com
2798150SAli.Saidi@ARM.com    logTagTableSize = 7
2808150SAli.Saidi@ARM.com    shortTagsTageFactor = 9
2817926Sgblack@eecs.umich.edu    longTagsTageFactor = 17
2827926Sgblack@eecs.umich.edu    longTagsSize = 12
2837926Sgblack@eecs.umich.edu
2843691Shsul@eecs.umich.edu    logTagTableSizes = [12]
2853005Sstever@eecs.umich.edu
2865721Shsul@eecs.umich.edu    firstLongTagTable = 11
2876194Sksewell@umich.edu
2886928SBrad.Beckmann@amd.com    truncatePathHist = False
2893005Sstever@eecs.umich.edu
2906168Snate@binkert.org    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]
2916928SBrad.Beckmann@amd.com
2926928SBrad.Beckmann@amd.com    tagTableUBits = 2
2936928SBrad.Beckmann@amd.com
2946928SBrad.Beckmann@amd.com# LTAGE branch predictor as described in
2956928SBrad.Beckmann@amd.com# https://www.irisa.fr/caps/people/seznec/L-TAGE.pdf
2966928SBrad.Beckmann@amd.com# It is basically a TAGE predictor plus a loop predictor
2976928SBrad.Beckmann@amd.com# The differnt TAGE sizes are updated according to the paper values (256 Kbits)
2986928SBrad.Beckmann@amd.comclass LTAGE(TAGE):
2996928SBrad.Beckmann@amd.com    type = 'LTAGE'
3006928SBrad.Beckmann@amd.com    cxx_class = 'LTAGE'
3016928SBrad.Beckmann@amd.com    cxx_header = "cpu/pred/ltage.hh"
3026928SBrad.Beckmann@amd.com
3036928SBrad.Beckmann@amd.com    tage = LTAGE_TAGE()
3046928SBrad.Beckmann@amd.com
3056166Ssteve.reinhardt@amd.com    loop_predictor = Param.LoopPredictor(LoopPredictor(), "Loop predictor")
3062929Sktlim@umich.edu
3072929Sktlim@umich.educlass TAGE_SC_L_LoopPredictor(LoopPredictor):
3083005Sstever@eecs.umich.edu    type = 'TAGE_SC_L_LoopPredictor'
3092997Sstever@eecs.umich.edu    cxx_class  = 'TAGE_SC_L_LoopPredictor'
3102997Sstever@eecs.umich.edu    cxx_header = "cpu/pred/tage_sc_l.hh"
3116293Ssteve.reinhardt@amd.com    loopTableAgeBits = 4
3126293Ssteve.reinhardt@amd.com    loopTableConfidenceBits = 4
3132929Sktlim@umich.edu    loopTableTagBits = 10
314    loopTableIterBits = 10
315    useSpeculation = False
316    useHashing = True
317    useDirectionBit = True
318    restrictAllocation = True
319    initialLoopIter = 0
320    initialLoopAge = 7
321    optionalAgeReset = False
322
323class StatisticalCorrector(SimObject):
324    type = 'StatisticalCorrector'
325    cxx_class  = 'StatisticalCorrector'
326    cxx_header = "cpu/pred/statistical_corrector.hh"
327    abstract = True
328
329    # Statistical corrector parameters
330
331    numEntriesFirstLocalHistories = Param.Unsigned(
332        "Number of entries for first local histories")
333
334    bwnb = Param.Unsigned("Num global backward branch GEHL lengths")
335    bwm = VectorParam.Int("Global backward branch GEHL lengths")
336    logBwnb = Param.Unsigned("Log num of global backward branch GEHL entries")
337
338    lnb = Param.Unsigned("Num first local history GEHL lenghts")
339    lm = VectorParam.Int("First local history GEHL lengths")
340    logLnb = Param.Unsigned("Log number of first local history GEHL entries")
341
342    inb = Param.Unsigned(1, "Num IMLI GEHL lenghts")
343    im = VectorParam.Int([8], "IMLI history GEHL lengths")
344    logInb = Param.Unsigned("Log number of IMLI GEHL entries")
345
346    logBias = Param.Unsigned("Log size of Bias tables")
347
348    logSizeUp = Param.Unsigned(6,
349        "Log size of update threshold counters tables")
350
351    chooserConfWidth = Param.Unsigned(7,
352        "Number of bits for the chooser counters")
353
354    updateThresholdWidth = Param.Unsigned(12,
355        "Number of bits for the update threshold counter")
356
357    pUpdateThresholdWidth = Param.Unsigned(8,
358        "Number of bits for the pUpdate threshold counters")
359
360    extraWeightsWidth = Param.Unsigned(6,
361        "Number of bits for the extra weights")
362
363    scCountersWidth = Param.Unsigned(6, "Statistical corrector counters width")
364
365# TAGE-SC-L branch predictor as desribed in
366# https://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf
367# It is a modified LTAGE predictor plus a statistical corrector predictor
368# The TAGE modifications include bank interleaving and partial associativity
369# Two different sizes are proposed in the paper:
370# 8KB => See TAGE_SC_L_8KB below
371# 64KB => See TAGE_SC_L_64KB below
372# The TAGE_SC_L_8KB and TAGE_SC_L_64KB classes differ not only on the values
373# of some parameters, but also in some implementation details
374# Given this, the TAGE_SC_L class is left abstract
375# Note that as it is now, this branch predictor does not handle any type
376# of speculation: All the structures/histories are updated at commit time
377class TAGE_SC_L(LTAGE):
378    type = 'TAGE_SC_L'
379    cxx_class = 'TAGE_SC_L'
380    cxx_header = "cpu/pred/tage_sc_l.hh"
381    abstract = True
382
383    statistical_corrector = Param.StatisticalCorrector(
384        "Statistical Corrector")
385
386class TAGE_SC_L_64KB_LoopPredictor(TAGE_SC_L_LoopPredictor):
387    logSizeLoopPred = 5
388
389class TAGE_SC_L_8KB_LoopPredictor(TAGE_SC_L_LoopPredictor):
390    logSizeLoopPred = 3
391
392class TAGE_SC_L_64KB_StatisticalCorrector(StatisticalCorrector):
393    type = 'TAGE_SC_L_64KB_StatisticalCorrector'
394    cxx_class  = 'TAGE_SC_L_64KB_StatisticalCorrector'
395    cxx_header = "cpu/pred/tage_sc_l_64KB.hh"
396
397    pnb = Param.Unsigned(3, "Num variation global branch GEHL lengths")
398    pm = VectorParam.Int([25, 16, 9], "Variation global branch GEHL lengths")
399    logPnb = Param.Unsigned(9,
400        "Log number of variation global branch GEHL entries")
401
402    snb = Param.Unsigned(3, "Num second local history GEHL lenghts")
403    sm = VectorParam.Int([16, 11, 6], "Second local history GEHL lengths")
404    logSnb = Param.Unsigned(9,
405        "Log number of second local history GEHL entries")
406
407    tnb = Param.Unsigned(2, "Num third local history GEHL lenghts")
408    tm = VectorParam.Int([9, 4], "Third local history GEHL lengths")
409    logTnb = Param.Unsigned(10,
410        "Log number of third local history GEHL entries")
411
412    imnb = Param.Unsigned(2, "Num second IMLI GEHL lenghts")
413    imm = VectorParam.Int([10, 4], "Second IMLI history GEHL lengths")
414    logImnb = Param.Unsigned(9, "Log number of second IMLI GEHL entries")
415
416    numEntriesSecondLocalHistories = Param.Unsigned(16,
417        "Number of entries for second local histories")
418    numEntriesThirdLocalHistories = Param.Unsigned(16,
419        "Number of entries for second local histories")
420
421    numEntriesFirstLocalHistories = 256
422
423    logBias = 8
424
425    bwnb = 3
426    bwm = [40, 24, 10]
427    logBwnb = 10
428
429    lnb = 3
430    lm = [11, 6, 3]
431    logLnb = 10
432
433    logInb = 8
434
435class TAGE_SC_L_8KB_StatisticalCorrector(StatisticalCorrector):
436    type = 'TAGE_SC_L_8KB_StatisticalCorrector'
437    cxx_class  = 'TAGE_SC_L_8KB_StatisticalCorrector'
438    cxx_header = "cpu/pred/tage_sc_l_8KB.hh"
439    gnb = Param.Unsigned(2, "Num global branch GEHL lengths")
440    gm = VectorParam.Int([6, 3], "Global branch GEHL lengths")
441    logGnb = Param.Unsigned(7, "Log number of global branch GEHL entries")
442
443    numEntriesFirstLocalHistories = 64
444
445    logBias = 7
446
447    bwnb = 2
448    logBwnb = 7
449    bwm = [16, 8]
450
451    lnb = 2
452    logLnb = 7
453    lm = [6, 3]
454
455    logInb = 7
456
457# 64KB TAGE-SC-L branch predictor as described in
458# http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf
459class TAGE_SC_L_64KB(TAGE_SC_L):
460    type = 'TAGE_SC_L_64KB'
461    cxx_class = 'TAGE_SC_L_64KB'
462    cxx_header = "cpu/pred/tage_sc_l_64KB.hh"
463
464    tage = TAGE_SC_L_TAGE_64KB()
465    loop_predictor = TAGE_SC_L_64KB_LoopPredictor()
466    statistical_corrector = TAGE_SC_L_64KB_StatisticalCorrector()
467
468# 8KB TAGE-SC-L branch predictor as described in
469# http://www.jilp.org/cbp2016/paper/AndreSeznecLimited.pdf
470class TAGE_SC_L_8KB(TAGE_SC_L):
471    type = 'TAGE_SC_L_8KB'
472    cxx_class = 'TAGE_SC_L_8KB'
473    cxx_header = "cpu/pred/tage_sc_l_8KB.hh"
474
475    tage = TAGE_SC_L_TAGE_8KB()
476    loop_predictor = TAGE_SC_L_8KB_LoopPredictor()
477    statistical_corrector = TAGE_SC_L_8KB_StatisticalCorrector()
478
479class MultiperspectivePerceptron(BranchPredictor):
480    type = 'MultiperspectivePerceptron'
481    cxx_class = 'MultiperspectivePerceptron'
482    cxx_header = 'cpu/pred/multiperspective_perceptron.hh'
483    abstract = True
484
485    num_filter_entries = Param.Int("Number of filter entries")
486    num_local_histories = Param.Int("Number of local history entries")
487    local_history_length = Param.Int(11,
488        "Length in bits of each history entry")
489
490    block_size = Param.Int(21,
491        "number of ghist bits in a 'block'; this is the width of an initial "
492        "hash of ghist")
493    pcshift = Param.Int(-10, "Shift for hashing PC")
494    threshold = Param.Int(1, "Threshold for deciding low/high confidence")
495    bias0 = Param.Int(-5,
496        "Bias perceptron output this much on all-bits-zero local history")
497    bias1 = Param.Int(5,
498        "Bias perceptron output this much on all-bits-one local history")
499    biasmostly0 = Param.Int(-1,
500        "Bias perceptron output this much on almost-all-bits-zero local "
501        "history")
502    biasmostly1 = Param.Int(1,
503        "Bias perceptron output this much on almost-all-bits-one local "
504        "history")
505    nbest = Param.Int(20,
506        "Use this many of the top performing tables on a low-confidence "
507        "branch")
508    tunebits = Param.Int(24, "Number of bits in misprediction counters")
509    hshift = Param.Int(-6,
510        "How much to shift initial feauture hash before XORing with PC bits")
511    imli_mask1 = Param.UInt64(
512        "Which tables should have their indices hashed with the first IMLI "
513        "counter")
514    imli_mask4 = Param.UInt64(
515        "Which tables should have their indices hashed with the fourth IMLI "
516        "counter")
517    recencypos_mask = Param.UInt64(
518        "Which tables should have their indices hashed with the recency "
519        "position")
520    fudge = Param.Float(0.245, "Fudge factor to multiply by perceptron output")
521    n_sign_bits = Param.Int(2, "Number of sign bits per magnitude")
522    pcbit = Param.Int(2, "Bit from the PC to use for hashing global history")
523    decay = Param.Int(0, "Whether and how often to decay a random weight")
524    record_mask = Param.Int(191,
525        "Which histories are updated with filtered branch outcomes")
526    hash_taken = Param.Bool(False,
527        "Hash the taken/not taken value with a PC bit")
528    tuneonly = Param.Bool(True,
529        "If true, only count mispredictions of low-confidence branches")
530    extra_rounds = Param.Int(1,
531        "Number of extra rounds of training a single weight on a "
532        "low-confidence prediction")
533    speed = Param.Int(9, "Adaptive theta learning speed")
534    initial_theta = Param.Int(10, "Initial theta")
535    budgetbits = Param.Int("Hardware budget in bits")
536    speculative_update = Param.Bool(False,
537        "Use speculative update for histories")
538
539class MultiperspectivePerceptron8KB(MultiperspectivePerceptron):
540    type = 'MultiperspectivePerceptron8KB'
541    cxx_class = 'MultiperspectivePerceptron8KB'
542    cxx_header = 'cpu/pred/multiperspective_perceptron_8KB.hh'
543    budgetbits = 8192 * 8 + 2048
544    num_local_histories = 48
545    num_filter_entries = 0
546    imli_mask1 = 0x6
547    imli_mask4 = 0x4400
548    recencypos_mask = 0x100000090
549
550class MultiperspectivePerceptron64KB(MultiperspectivePerceptron):
551    type = 'MultiperspectivePerceptron64KB'
552    cxx_class = 'MultiperspectivePerceptron64KB'
553    cxx_header = 'cpu/pred/multiperspective_perceptron_64KB.hh'
554    budgetbits = 65536 * 8 + 2048
555    num_local_histories = 510
556    num_filter_entries = 18025
557    imli_mask1 = 0xc1000
558    imli_mask4 = 0x80008000
559    recencypos_mask = 0x100000090
560