gem5  v22.0.0.1
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_HH__
44 #define __CPU_PRED_TAGE_SC_L_HH__
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 namespace gem5
53 {
54 
55 namespace branch_prediction
56 {
57 
58 class TAGE_SC_L_TAGE : public TAGEBase
59 {
60  const unsigned firstLongTagTable;
61  const unsigned longTagsSize;
62  const unsigned shortTagsSize;
63 
64  const unsigned logTagTableSize;
65 
66  const unsigned shortTagsTageFactor;
67  const unsigned longTagsTageFactor;
68 
69  const bool truncatePathHist;
70 
71  public:
73  {
74  bool lowConf;
75  bool highConf;
76  bool altConf;
77  bool medConf;
79  lowConf(false), highConf(false), altConf(false), medConf(false)
80  {}
81  virtual ~BranchInfo()
82  {}
83  };
84 
85  virtual TAGEBase::BranchInfo *makeBranchInfo() override;
86 
87  TAGE_SC_L_TAGE(const TAGE_SC_L_TAGEParams &p)
88  : TAGEBase(p),
96  {}
97 
98  void calculateParameters() override;
99 
100  void buildTageTables() override;
101 
103  ThreadID tid, Addr branch_pc, TAGEBase::BranchInfo* bi) override;
104 
105  unsigned getUseAltIdx(TAGEBase::BranchInfo* bi, Addr branch_pc) override;
106 
107  void updateHistories(
108  ThreadID tid, Addr branch_pc, bool taken, TAGEBase::BranchInfo* b,
109  bool speculative, const StaticInstPtr &inst,
110  Addr target) override;
111 
112  int bindex(Addr pc_in) const override;
113  int gindex(ThreadID tid, Addr pc, int bank) const override;
114  virtual int gindex_ext(int index, int bank) const = 0;
115  int F(int phist, int size, int bank) const override;
116 
117  virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override = 0;
118 
119  void squash(ThreadID tid, bool taken, TAGEBase::BranchInfo *bi,
120  Addr target) override;
121 
123  ThreadHistory & tHist, int brtype, bool taken,
124  Addr branch_pc, Addr target);
125 
126  void adjustAlloc(bool & alloc, bool taken, bool pred_taken) override;
127 
128  virtual void handleAllocAndUReset(bool alloc, bool taken,
129  TAGEBase::BranchInfo* bi, int nrand) override = 0;
130 
131  void handleUReset() override;
132 
133  virtual void handleTAGEUpdate(
134  Addr branch_pc, bool taken, TAGEBase::BranchInfo* bi) override = 0;
135 
137 
138  bool getBimodePred(Addr branch_pc,
139  TAGEBase::BranchInfo* tage_bi) const override;
140 
141  void extraAltCalc(TAGEBase::BranchInfo* bi) override;
142 
143 };
144 
146 {
147  public:
148  TAGE_SC_L_LoopPredictor(const TAGE_SC_L_LoopPredictorParams &p)
149  : LoopPredictor(p)
150  {}
151 
152  virtual bool calcConf(int index) const override;
153  virtual bool optionalAgeInc() const override;
154 };
155 
156 class TAGE_SC_L: public LTAGE
157 {
159  public:
160  TAGE_SC_L(const TAGE_SC_LParams &params);
161 
162  bool predict(
163  ThreadID tid, Addr branch_pc, bool cond_branch, void* &b) override;
164 
165  void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history,
166  bool squashed, const StaticInstPtr & inst,
167  Addr corrTarget) override;
168 
169  protected:
170 
172  {
174 
176  LoopPredictor &lp)
177  : LTageBranchInfo(tage, lp), scBranchInfo(sc.makeBranchInfo())
178  {}
179 
181  {
182  delete scBranchInfo;
183  }
184  };
185 
186  // more provider types
187  enum
188  {
190  };
191 
192 };
193 
194 } // namespace branch_prediction
195 } // namespace gem5
196 
197 #endif // __CPU_PRED_TAGE_SC_L_HH__
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo
Definition: tage_sc_l.hh:72
gem5::branch_prediction::TAGE_SC_L_TAGE::calcDep
int calcDep(TAGEBase::BranchInfo *bi)
Definition: tage_sc_l.cc:305
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L::TageSCLBranchInfo::scBranchInfo
StatisticalCorrector::BranchInfo * scBranchInfo
Definition: tage_sc_l.hh:173
ltage.hh
gem5::branch_prediction::TAGE_SC_L::SC
@ SC
Definition: tage_sc_l.hh:189
gem5::branch_prediction::TAGE_SC_L_TAGE::firstLongTagTable
const unsigned firstLongTagTable
Definition: tage_sc_l.hh:60
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
gem5::branch_prediction::TAGE_SC_L_LoopPredictor::calcConf
virtual bool calcConf(int index) const override
Definition: tage_sc_l.cc:55
gem5::branch_prediction::TAGE_SC_L_TAGE::updatePathAndGlobalHistory
void updatePathAndGlobalHistory(ThreadHistory &tHist, int brtype, bool taken, Addr branch_pc, Addr target)
Definition: tage_sc_l.cc:230
statistical_corrector.hh
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo::lowConf
bool lowConf
Definition: tage_sc_l.hh:74
gem5::branch_prediction::TAGE_SC_L::TageSCLBranchInfo
Definition: tage_sc_l.hh:171
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L_TAGE::longTagsTageFactor
const unsigned longTagsTageFactor
Definition: tage_sc_l.hh:67
gem5::branch_prediction::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
gem5::branch_prediction::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.
gem5::branch_prediction::StatisticalCorrector
Definition: statistical_corrector.hh:58
gem5::branch_prediction::TAGE_SC_L_TAGE::TAGE_SC_L_TAGE
TAGE_SC_L_TAGE(const TAGE_SC_L_TAGEParams &p)
Definition: tage_sc_l.hh:87
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo::medConf
bool medConf
Definition: tage_sc_l.hh:77
gem5::branch_prediction::TAGE_SC_L
Definition: tage_sc_l.hh:156
gem5::branch_prediction::TAGE_SC_L_TAGE::buildTageTables
void buildTageTables() override
Instantiates the TAGE table entries.
Definition: tage_sc_l.cc:111
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo::altConf
bool altConf
Definition: tage_sc_l.hh:76
gem5::PowerISA::bi
Bitfield< 20, 16 > bi
Definition: types.hh:80
gem5::branch_prediction::TAGE_SC_L_LoopPredictor::TAGE_SC_L_LoopPredictor
TAGE_SC_L_LoopPredictor(const TAGE_SC_L_LoopPredictorParams &p)
Definition: tage_sc_l.hh:148
gem5::branch_prediction::TAGEBase::BranchInfo
Definition: tage_base.hh:128
gem5::branch_prediction::TAGE_SC_L_LoopPredictor
Definition: tage_sc_l.hh:145
gem5::RefCountingPtr< StaticInst >
gem5::branch_prediction::TAGE_SC_L_TAGE::shortTagsSize
const unsigned shortTagsSize
Definition: tage_sc_l.hh:62
gem5::branch_prediction::TAGEBase
Definition: tage_base.hh:65
gem5::branch_prediction::LTAGE::LAST_LTAGE_PROVIDER_TYPE
@ LAST_LTAGE_PROVIDER_TYPE
Definition: ltage.hh:87
gem5::ArmISA::b
Bitfield< 7 > b
Definition: misc_types.hh:382
gem5::branch_prediction::TAGE_SC_L_LoopPredictor::optionalAgeInc
virtual bool optionalAgeInc() const override
Definition: tage_sc_l.cc:62
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::branch_prediction::TAGE_SC_L_TAGE::shortTagsTageFactor
const unsigned shortTagsTageFactor
Definition: tage_sc_l.hh:66
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L_TAGE::makeBranchInfo
virtual TAGEBase::BranchInfo * makeBranchInfo() override
Definition: tage_sc_l.cc:73
gem5::branch_prediction::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.
gem5::branch_prediction::TAGE_SC_L::TageSCLBranchInfo::TageSCLBranchInfo
TageSCLBranchInfo(TAGEBase &tage, StatisticalCorrector &sc, LoopPredictor &lp)
Definition: tage_sc_l.hh:175
gem5::branch_prediction::TAGE_SC_L_TAGE
Definition: tage_sc_l.hh:58
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L::statisticalCorrector
StatisticalCorrector * statisticalCorrector
Definition: tage_sc_l.hh:158
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo::BranchInfo
BranchInfo(TAGEBase &tage)
Definition: tage_sc_l.hh:78
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::branch_prediction::StatisticalCorrector::BranchInfo
Definition: statistical_corrector.hh:200
gem5::branch_prediction::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
gem5::branch_prediction::LTAGE::LTageBranchInfo
Definition: ltage.hh:91
gem5::branch_prediction::LTAGE
Definition: ltage.hh:66
gem5::branch_prediction::TAGE_SC_L_TAGE::gindex_ext
virtual int gindex_ext(int index, int bank) const =0
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo::~BranchInfo
virtual ~BranchInfo()
Definition: tage_sc_l.hh:81
gem5::branch_prediction::TAGE_SC_L_TAGE::logTagTableSize
const unsigned logTagTableSize
Definition: tage_sc_l.hh:64
gem5::branch_prediction::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
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L_TAGE::truncatePathHist
const bool truncatePathHist
Definition: tage_sc_l.hh:69
gem5::branch_prediction::TAGE_SC_L_TAGE::handleUReset
void handleUReset() override
Handles the U bits reset.
Definition: tage_sc_l.cc:316
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::branch_prediction::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
gem5::branch_prediction::TAGE::tage
TAGEBase * tage
Definition: tage.hh:67
gem5::branch_prediction::LoopPredictor
Definition: loop_predictor.hh:49
gem5::branch_prediction::TAGE_SC_L_TAGE::longTagsSize
const unsigned longTagsSize
Definition: tage_sc_l.hh:61
gem5::branch_prediction::TAGE_SC_L::TAGE_SC_L
TAGE_SC_L(const TAGE_SC_LParams &params)
Definition: tage_sc_l.cc:67
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::branch_prediction::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.
gem5::branch_prediction::TAGE_SC_L_TAGE::BranchInfo::highConf
bool highConf
Definition: tage_sc_l.hh:75
gem5::branch_prediction::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
gem5::branch_prediction::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
gem5::branch_prediction::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
gem5::branch_prediction::TAGE_SC_L::TageSCLBranchInfo::~TageSCLBranchInfo
virtual ~TageSCLBranchInfo()
Definition: tage_sc_l.hh:180
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235

Generated on Sat Jun 18 2022 08:12:21 for gem5 by doxygen 1.8.17