gem5  v22.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_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__
TAGE_SC_L_LoopPredictor(const TAGE_SC_L_LoopPredictorParams &p)
Definition: tage_sc_l.hh:148
virtual bool optionalAgeInc() const override
Definition: tage_sc_l.cc:62
virtual bool calcConf(int index) const override
Definition: tage_sc_l.cc:55
void updatePathAndGlobalHistory(ThreadHistory &tHist, int brtype, bool taken, Addr branch_pc, Addr target)
Definition: tage_sc_l.cc:230
virtual void handleAllocAndUReset(bool alloc, bool taken, TAGEBase::BranchInfo *bi, int nrand) override=0
Handles Allocation and U bits reset on an update.
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
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
int bindex(Addr pc_in) const override
Computes the index used to access the bimodal table.
Definition: tage_sc_l.cc:223
int calcDep(TAGEBase::BranchInfo *bi)
Definition: tage_sc_l.cc:305
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_SC_L_TAGE(const TAGE_SC_L_TAGEParams &p)
Definition: tage_sc_l.hh:87
virtual void handleTAGEUpdate(Addr branch_pc, bool taken, TAGEBase::BranchInfo *bi) override=0
Handles the update of the TAGE entries.
virtual TAGEBase::BranchInfo * makeBranchInfo() override
Definition: tage_sc_l.cc:73
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
virtual int gindex_ext(int index, int bank) const =0
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
void calculateParameters() override
Calculates the history lengths and some other paramters in derived classes.
Definition: tage_sc_l.cc:78
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
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
void buildTageTables() override
Instantiates the TAGE table entries.
Definition: tage_sc_l.cc:111
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
virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override=0
Computes the partial tag of a tagged table.
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
void handleUReset() override
Handles the U bits reset.
Definition: tage_sc_l.cc:316
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
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(const TAGE_SC_LParams &params)
Definition: tage_sc_l.cc:67
StatisticalCorrector * statisticalCorrector
Definition: tage_sc_l.hh:158
const Params & params() const
Definition: sim_object.hh:176
Bitfield< 7 > b
Definition: misc_types.hh:388
Bitfield< 4 > pc
Bitfield< 30, 0 > index
Bitfield< 20, 16 > bi
Definition: types.hh:80
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
TageSCLBranchInfo(TAGEBase &tage, StatisticalCorrector &sc, LoopPredictor &lp)
Definition: tage_sc_l.hh:175
StatisticalCorrector::BranchInfo * scBranchInfo
Definition: tage_sc_l.hh:173

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1