gem5  v20.1.0.0
tage_sc_l.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Metempsy Technology Consulting
3  * All rights reserved.
4  *
5  * Copyright (c) 2006 INRIA (Institut National de Recherche en
6  * Informatique et en Automatique / French National Research Institute
7  * for Computer Science and Applied Mathematics)
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are
13  * met: redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer;
15  * redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution;
18  * neither the name of the copyright holders nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * Author: AndrĂ© Seznec, Pau Cabre, Javier Bueno
35  *
36  */
37 
38 /*
39  * TAGE-SC-L branch predictor base class (devised by Andre Seznec)
40  * It consits of a TAGE + a statistical corrector (SC) + a loop predictor (L)
41  */
42 
43 #ifndef __CPU_PRED_TAGE_SC_L
44 #define __CPU_PRED_TAGE_SC_L
45 
46 #include "cpu/pred/ltage.hh"
48 #include "params/TAGE_SC_L.hh"
49 #include "params/TAGE_SC_L_LoopPredictor.hh"
50 #include "params/TAGE_SC_L_TAGE.hh"
51 
52 class TAGE_SC_L_TAGE : public TAGEBase {
53  const unsigned firstLongTagTable;
54  const unsigned longTagsSize;
55  const unsigned shortTagsSize;
56 
57  const unsigned logTagTableSize;
58 
59  const unsigned shortTagsTageFactor;
60  const unsigned longTagsTageFactor;
61 
62  const bool truncatePathHist;
63 
64  public:
65  struct BranchInfo : public TAGEBase::BranchInfo {
66  bool lowConf;
67  bool highConf;
68  bool altConf;
69  bool medConf;
71  lowConf(false), highConf(false), altConf(false), medConf(false)
72  {}
73  virtual ~BranchInfo()
74  {}
75  };
76 
77  virtual TAGEBase::BranchInfo *makeBranchInfo() override;
78 
79  TAGE_SC_L_TAGE(const TAGE_SC_L_TAGEParams *p)
80  : TAGEBase(p),
88  {}
89 
90  void calculateParameters() override;
91 
92  void buildTageTables() override;
93 
95  ThreadID tid, Addr branch_pc, TAGEBase::BranchInfo* bi) override;
96 
97  unsigned getUseAltIdx(TAGEBase::BranchInfo* bi, Addr branch_pc) override;
98 
99  void updateHistories(
100  ThreadID tid, Addr branch_pc, bool taken, TAGEBase::BranchInfo* b,
101  bool speculative, const StaticInstPtr &inst,
102  Addr target) override;
103 
104  int bindex(Addr pc_in) const override;
105  int gindex(ThreadID tid, Addr pc, int bank) const override;
106  virtual int gindex_ext(int index, int bank) const = 0;
107  int F(int phist, int size, int bank) const override;
108 
109  virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override = 0;
110 
111  void squash(ThreadID tid, bool taken, TAGEBase::BranchInfo *bi,
112  Addr target) override;
113 
115  ThreadHistory & tHist, int brtype, bool taken,
116  Addr branch_pc, Addr target);
117 
118  void adjustAlloc(bool & alloc, bool taken, bool pred_taken) override;
119 
120  virtual void handleAllocAndUReset(bool alloc, bool taken,
121  TAGEBase::BranchInfo* bi, int nrand) override = 0;
122 
123  void handleUReset() override;
124 
125  virtual void handleTAGEUpdate(
126  Addr branch_pc, bool taken, TAGEBase::BranchInfo* bi) override = 0;
127 
129 
130  bool getBimodePred(Addr branch_pc,
131  TAGEBase::BranchInfo* tage_bi) const override;
132 
133  void extraAltCalc(TAGEBase::BranchInfo* bi) override;
134 
135 };
136 
138 {
139  public:
140  TAGE_SC_L_LoopPredictor(TAGE_SC_L_LoopPredictorParams *p)
141  : LoopPredictor(p)
142  {}
143 
144  virtual bool calcConf(int index) const override;
145  virtual bool optionalAgeInc() const override;
146 };
147 
148 class TAGE_SC_L: public LTAGE
149 {
151  public:
152  TAGE_SC_L(const TAGE_SC_LParams *params);
153 
154  bool predict(
155  ThreadID tid, Addr branch_pc, bool cond_branch, void* &b) override;
156 
157  void regStats() override;
158 
159  void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
160  bool squashed, const StaticInstPtr & inst,
161  Addr corrTarget) override;
162 
163  protected:
164 
166  {
168 
170  LoopPredictor &lp)
171  : LTageBranchInfo(tage, lp), scBranchInfo(sc.makeBranchInfo())
172  {}
173 
175  {
176  delete scBranchInfo;
177  }
178  };
179 
180  // more provider types
181  enum {
183  };
184 
185 };
186 
187 #endif // __CPU_PRED_TAGE_SC_L
188 
TAGE_SC_L_TAGE::buildTageTables
void buildTageTables() override
Instantiates the TAGE table entries.
Definition: tage_sc_l.cc:111
TAGE_SC_L_TAGE::BranchInfo::highConf
bool highConf
Definition: tage_sc_l.hh:67
ltage.hh
MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:44
TAGE_SC_L_TAGE::logTagTableSize
const unsigned logTagTableSize
Definition: tage_sc_l.hh:57
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
TAGE_SC_L_TAGE::truncatePathHist
const bool truncatePathHist
Definition: tage_sc_l.hh:62
TAGE_SC_L_TAGE::TAGE_SC_L_TAGE
TAGE_SC_L_TAGE(const TAGE_SC_L_TAGEParams *p)
Definition: tage_sc_l.hh:79
TAGE_SC_L_LoopPredictor
Definition: tage_sc_l.hh:137
TAGE_SC_L::regStats
void regStats() override
Callback to set stat parameters.
Definition: tage_sc_l.cc:469
TAGE_SC_L_TAGE::shortTagsTageFactor
const unsigned shortTagsTageFactor
Definition: tage_sc_l.hh:59
statistical_corrector.hh
TAGE_SC_L_TAGE::calcDep
int calcDep(TAGEBase::BranchInfo *bi)
Definition: tage_sc_l.cc:305
LTAGE
Definition: ltage.hh:60
TAGE_SC_L_TAGE
Definition: tage_sc_l.hh:52
TAGE_SC_L_TAGE::squash
void squash(ThreadID tid, bool taken, TAGEBase::BranchInfo *bi, Addr target) override
Restores speculatively updated path and direction histories.
Definition: tage_sc_l.cc:289
TAGEBase::BranchInfo
Definition: tage_base.hh:120
TAGE_SC_L::statisticalCorrector
StatisticalCorrector * statisticalCorrector
Definition: tage_sc_l.hh:150
LoopPredictor
Definition: loop_predictor.hh:43
LTAGE::LAST_LTAGE_PROVIDER_TYPE
@ LAST_LTAGE_PROVIDER_TYPE
Definition: ltage.hh:81
TAGE_SC_L::TAGE_SC_L
TAGE_SC_L(const TAGE_SC_LParams *params)
Definition: tage_sc_l.cc:67
LTAGE::LTageBranchInfo
Definition: ltage.hh:85
TAGE_SC_L_LoopPredictor::TAGE_SC_L_LoopPredictor
TAGE_SC_L_LoopPredictor(TAGE_SC_L_LoopPredictorParams *p)
Definition: tage_sc_l.hh:140
TAGE_SC_L_TAGE::handleAllocAndUReset
virtual void handleAllocAndUReset(bool alloc, bool taken, TAGEBase::BranchInfo *bi, int nrand) override=0
Handles Allocation and U bits reset on an update.
TAGE_SC_L_TAGE::BranchInfo::medConf
bool medConf
Definition: tage_sc_l.hh:69
TAGE_SC_L_TAGE::bindex
int bindex(Addr pc_in) const override
Computes the index used to access the bimodal table.
Definition: tage_sc_l.cc:223
TAGE_SC_L_TAGE::calculateParameters
void calculateParameters() override
Calculates the history lengths and some other paramters in derived classes.
Definition: tage_sc_l.cc:78
TAGE_SC_L_TAGE::BranchInfo::lowConf
bool lowConf
Definition: tage_sc_l.hh:66
TAGE_SC_L_TAGE::gindex
int gindex(ThreadID tid, Addr pc, int bank) const override
Computes the index used to access a partially tagged table.
Definition: tage_sc_l.cc:180
PowerISA::bi
Bitfield< 20, 16 > bi
Definition: types.hh:63
TAGE_SC_L::TageSCLBranchInfo::scBranchInfo
StatisticalCorrector::BranchInfo * scBranchInfo
Definition: tage_sc_l.hh:167
TAGE_SC_L_TAGE::getBimodePred
bool getBimodePred(Addr branch_pc, TAGEBase::BranchInfo *tage_bi) const override
Get a branch prediction from the bimodal predictor.
Definition: tage_sc_l.cc:340
TAGE::tage
TAGEBase * tage
Definition: tage.hh:61
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
TAGE_SC_L_TAGE::calculateIndicesAndTags
void calculateIndicesAndTags(ThreadID tid, Addr branch_pc, TAGEBase::BranchInfo *bi) override
On a prediction, calculates the TAGE indices and tags for all the different history lengths.
Definition: tage_sc_l.cc:128
TAGE_SC_L_TAGE::F
int F(int phist, int size, int bank) const override
Utility function to shuffle the path history depending on which tagged table we are accessing.
Definition: tage_sc_l.cc:199
TAGE_SC_L::predict
bool predict(ThreadID tid, Addr branch_pc, bool cond_branch, void *&b) override
Get a branch prediction from LTAGE.
Definition: tage_sc_l.cc:365
TAGE_SC_L
Definition: tage_sc_l.hh:148
TAGE_SC_L_TAGE::handleUReset
void handleUReset() override
Handles the U bits reset.
Definition: tage_sc_l.cc:316
TAGE_SC_L::SC
@ SC
Definition: tage_sc_l.hh:182
TAGE_SC_L_LoopPredictor::optionalAgeInc
virtual bool optionalAgeInc() const override
Definition: tage_sc_l.cc:56
TAGE_SC_L_TAGE::gtag
virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override=0
Computes the partial tag of a tagged table.
TAGEBase
Definition: tage_base.hh:58
TAGE_SC_L_TAGE::getUseAltIdx
unsigned getUseAltIdx(TAGEBase::BranchInfo *bi, Addr branch_pc) override
Calculation of the index for useAltPredForNewlyAllocated On this base TAGE implementation it is alway...
Definition: tage_sc_l.cc:171
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
TAGE_SC_L_TAGE::updateHistories
void updateHistories(ThreadID tid, Addr branch_pc, bool taken, TAGEBase::BranchInfo *b, bool speculative, const StaticInstPtr &inst, Addr target) override
(Speculatively) updates global histories (path and direction).
Definition: tage_sc_l.cc:265
SimObject::params
const Params * params() const
Definition: sim_object.hh:119
TAGE_SC_L_TAGE::BranchInfo::~BranchInfo
virtual ~BranchInfo()
Definition: tage_sc_l.hh:73
TAGE_SC_L_TAGE::BranchInfo::altConf
bool altConf
Definition: tage_sc_l.hh:68
TAGE_SC_L::TageSCLBranchInfo::~TageSCLBranchInfo
virtual ~TageSCLBranchInfo()
Definition: tage_sc_l.hh:174
TAGE_SC_L_TAGE::gindex_ext
virtual int gindex_ext(int index, int bank) const =0
TAGE_SC_L_LoopPredictor::calcConf
virtual bool calcConf(int index) const override
Definition: tage_sc_l.cc:49
TAGE_SC_L_TAGE::handleTAGEUpdate
virtual void handleTAGEUpdate(Addr branch_pc, bool taken, TAGEBase::BranchInfo *bi) override=0
Handles the update of the TAGE entries.
TAGE_SC_L_TAGE::BranchInfo::BranchInfo
BranchInfo(TAGEBase &tage)
Definition: tage_sc_l.hh:70
ArmISA::b
Bitfield< 7 > b
Definition: miscregs_types.hh:376
StatisticalCorrector::BranchInfo
Definition: statistical_corrector.hh:192
TAGE_SC_L_TAGE::longTagsSize
const unsigned longTagsSize
Definition: tage_sc_l.hh:54
TAGE_SC_L_TAGE::firstLongTagTable
const unsigned firstLongTagTable
Definition: tage_sc_l.hh:53
TAGE_SC_L_TAGE::adjustAlloc
void adjustAlloc(bool &alloc, bool taken, bool pred_taken) override
Extra calculation to tell whether TAGE allocaitons may happen or not on an update For this base TAGE ...
Definition: tage_sc_l.cc:296
TAGE_SC_L_TAGE::shortTagsSize
const unsigned shortTagsSize
Definition: tage_sc_l.hh:55
StatisticalCorrector
Definition: statistical_corrector.hh:52
TAGE_SC_L_TAGE::extraAltCalc
void extraAltCalc(TAGEBase::BranchInfo *bi) override
Extra steps for calculating altTaken For this base TAGE class it does nothing.
Definition: tage_sc_l.cc:356
TAGE_SC_L::TageSCLBranchInfo
Definition: tage_sc_l.hh:165
RefCountingPtr< StaticInst >
TAGE_SC_L_TAGE::updatePathAndGlobalHistory
void updatePathAndGlobalHistory(ThreadHistory &tHist, int brtype, bool taken, Addr branch_pc, Addr target)
Definition: tage_sc_l.cc:230
TAGE_SC_L_TAGE::BranchInfo
Definition: tage_sc_l.hh:65
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
TAGE_SC_L_TAGE::makeBranchInfo
virtual TAGEBase::BranchInfo * makeBranchInfo() override
Definition: tage_sc_l.cc:73
TAGE_SC_L_TAGE::longTagsTageFactor
const unsigned longTagsTageFactor
Definition: tage_sc_l.hh:60
TAGE_SC_L::update
void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, bool squashed, const StaticInstPtr &inst, Addr corrTarget) override
Updates the BP with taken/not taken information.
Definition: tage_sc_l.cc:413
TAGE_SC_L::TageSCLBranchInfo::TageSCLBranchInfo
TageSCLBranchInfo(TAGEBase &tage, StatisticalCorrector &sc, LoopPredictor &lp)
Definition: tage_sc_l.hh:169

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17