gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
tage_sc_l.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022-2023 The University of Edinburgh
3 * Copyright (c) 2024 Technical University of Munich
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2018 Metempsy Technology Consulting
16 * All rights reserved.
17 *
18 * Copyright (c) 2006 INRIA (Institut National de Recherche en
19 * Informatique et en Automatique / French National Research Institute
20 * for Computer Science and Applied Mathematics)
21 *
22 * All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions are
26 * met: redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer;
28 * redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution;
31 * neither the name of the copyright holders nor the names of its
32 * contributors may be used to endorse or promote products derived from
33 * this software without specific prior written permission.
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 *
47 * Author: André Seznec, Pau Cabre, Javier Bueno
48 *
49 */
50
51/*
52 * TAGE-SC-L branch predictor base class (devised by Andre Seznec)
53 * It consits of a TAGE + a statistical corrector (SC) + a loop predictor (L)
54 */
55
56#ifndef __CPU_PRED_TAGE_SC_L_HH__
57#define __CPU_PRED_TAGE_SC_L_HH__
58
59#include "base/random.hh"
60#include "cpu/pred/ltage.hh"
62#include "params/TAGE_SC_L.hh"
63#include "params/TAGE_SC_L_LoopPredictor.hh"
64#include "params/TAGE_SC_L_TAGE.hh"
65
66namespace gem5
67{
68
69namespace branch_prediction
70{
71
73{
74 const unsigned firstLongTagTable;
75 const unsigned longTagsSize;
76 const unsigned shortTagsSize;
77
78 const unsigned logTagTableSize;
79
80 const unsigned shortTagsTageFactor;
81 const unsigned longTagsTageFactor;
82
83 const bool truncatePathHist;
84
85 protected:
87
88 public:
90 {
91 bool lowConf;
93 bool altConf;
94 bool medConf;
96 : TAGEBase::BranchInfo(tage, pc, cond),
97 lowConf(false), highConf(false), altConf(false), medConf(false)
98 {}
99 virtual ~BranchInfo()
100 {}
101 };
102
103 virtual TAGEBase::BranchInfo *makeBranchInfo(Addr pc, bool cond) override;
104
115
116 void calculateParameters() override;
117
118 void buildTageTables() override;
119
121 ThreadID tid, Addr branch_pc, TAGEBase::BranchInfo* bi) override;
122
123 unsigned getUseAltIdx(TAGEBase::BranchInfo* bi, Addr branch_pc) override;
124
125 int bindex(Addr pc_in) const override;
126 int gindex(ThreadID tid, Addr pc, int bank) const override;
127 virtual int gindex_ext(int index, int bank) const = 0;
128 int F(int phist, int size, int bank) const override;
129
130 virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override = 0;
131
132 int branchTypeExtra(const StaticInstPtr& inst) override;
133 void updatePathAndGlobalHistory(ThreadID tid, int brtype, bool taken,
134 Addr branch_pc, Addr target,
135 TAGEBase::BranchInfo* bi) override;
136
137 void adjustAlloc(bool & alloc, bool taken, bool pred_taken) override;
138
139 virtual void handleAllocAndUReset(bool alloc, bool taken,
140 TAGEBase::BranchInfo* bi, int nrand) override = 0;
141
142 void handleUReset() override;
143
144 virtual void handleTAGEUpdate(
145 Addr branch_pc, bool taken, TAGEBase::BranchInfo* bi) override = 0;
146
148
149 bool getBimodePred(Addr branch_pc,
150 TAGEBase::BranchInfo* tage_bi) const override;
151
152 void extraAltCalc(TAGEBase::BranchInfo* bi) override;
153
154};
155
157{
158 public:
159 TAGE_SC_L_LoopPredictor(const TAGE_SC_L_LoopPredictorParams &p)
161 {}
162
163 virtual bool calcConf(int index) const override;
164 virtual bool optionalAgeInc() const override;
165};
166
167class TAGE_SC_L: public LTAGE
168{
170 public:
171 TAGE_SC_L(const TAGE_SC_LParams &params);
172
173 bool predict(
174 ThreadID tid, Addr branch_pc, bool cond_branch, void* &b) override;
175 void squash(ThreadID tid, void * &bp_history) override;
176 void update(ThreadID tid, Addr pc, bool taken, void * &bp_history,
177 bool squashed, const StaticInstPtr & inst,
178 Addr target) override;
179 void updateHistories(ThreadID tid, Addr pc, bool uncond,
180 bool taken, Addr target, const StaticInstPtr &inst,
181 void * &bp_history) override;
183 bool uncond, void * &bp_history) override
184 { panic("Not implemented for this BP!\n"); }
185
186 protected:
187
189 {
191
193 LoopPredictor &lp, Addr pc, bool cond_branch)
194 : LTageBranchInfo(tage, lp, pc, cond_branch),
195 scBranchInfo(sc.makeBranchInfo())
196 {}
197
199 {
200 delete scBranchInfo;
201 }
202 };
203
204 // more provider types
205 enum
206 {
208 };
209
210};
211
212} // namespace branch_prediction
213} // namespace gem5
214
215#endif // __CPU_PRED_TAGE_SC_L_HH__
static RandomPtr genRandom(Random *r=nullptr)
Definition random.hh:68
std::shared_ptr< Random > RandomPtr
Definition random.hh:65
LTAGE(const LTAGEParams &params)
Definition ltage.cc:64
LoopPredictor(const LoopPredictorParams &p)
TAGEBase(const TAGEBaseParams &p)
Definition tage_base.cc:52
TAGE_SC_L_LoopPredictor(const TAGE_SC_L_LoopPredictorParams &p)
Definition tage_sc_l.hh:159
virtual bool optionalAgeInc() const override
Definition tage_sc_l.cc:74
virtual bool calcConf(int index) const override
Definition tage_sc_l.cc:67
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:349
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:140
int bindex(Addr pc_in) const override
Computes the index used to access the bimodal table.
Definition tage_sc_l.cc:236
int calcDep(TAGEBase::BranchInfo *bi)
Definition tage_sc_l.cc:298
bool getBimodePred(Addr branch_pc, TAGEBase::BranchInfo *tage_bi) const override
Get a branch prediction from the bimodal predictor.
Definition tage_sc_l.cc:333
TAGE_SC_L_TAGE(const TAGE_SC_L_TAGEParams &p)
Definition tage_sc_l.hh:105
void updatePathAndGlobalHistory(ThreadID tid, int brtype, bool taken, Addr branch_pc, Addr target, TAGEBase::BranchInfo *bi) override
Does the actual update of path and global history.
Definition tage_sc_l.cc:254
virtual void handleTAGEUpdate(Addr branch_pc, bool taken, TAGEBase::BranchInfo *bi) override=0
Handles the update of the TAGE entries.
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:194
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:212
void calculateParameters() override
Calculates the history lengths and some other paramters in derived classes.
Definition tage_sc_l.cc:90
int branchTypeExtra(const StaticInstPtr &inst) override
This function acts as a hook for other TAGE implementations to adjust the branch type.
Definition tage_sc_l.cc:244
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:289
void buildTageTables() override
Instantiates the TAGE table entries.
Definition tage_sc_l.cc:123
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:185
virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const override=0
Computes the partial tag of a tagged table.
virtual TAGEBase::BranchInfo * makeBranchInfo(Addr pc, bool cond) override
Definition tage_sc_l.cc:85
void handleUReset() override
Handles the U bits reset.
Definition tage_sc_l.cc:309
bool predict(ThreadID tid, Addr branch_pc, bool cond_branch, void *&b) override
Get a branch prediction from LTAGE.
Definition tage_sc_l.cc:358
void update(ThreadID tid, Addr pc, bool taken, void *&bp_history, bool squashed, const StaticInstPtr &inst, Addr target) override
Updates the BP with taken/not taken information.
Definition tage_sc_l.cc:414
TAGE_SC_L(const TAGE_SC_LParams &params)
Definition tage_sc_l.cc:79
void branchPlaceholder(ThreadID tid, Addr pc, bool uncond, void *&bp_history) override
Special function for the decoupled front-end.
Definition tage_sc_l.hh:182
StatisticalCorrector * statisticalCorrector
Definition tage_sc_l.hh:169
void squash(ThreadID tid, void *&bp_history) override
Definition tage_sc_l.cc:484
void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, const StaticInstPtr &inst, void *&bp_history) override
Ones done with the prediction this function updates the path and global history.
Definition tage_sc_l.cc:495
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
const Params & params() const
Bitfield< 7 > b
Bitfield< 4 > pc
Bitfield< 30, 0 > index
Bitfield< 0 > p
Bitfield< 20, 16 > bi
Definition types.hh:80
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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
RefCountingPtr< StaticInst > StaticInstPtr
LTageBranchInfo(TAGEBase &tage, LoopPredictor &lp, Addr pc, bool conditional)
Definition ltage.hh:107
TageSCLBranchInfo(TAGEBase &tage, StatisticalCorrector &sc, LoopPredictor &lp, Addr pc, bool cond_branch)
Definition tage_sc_l.hh:192
StatisticalCorrector::BranchInfo * scBranchInfo
Definition tage_sc_l.hh:190
BranchInfo(TAGEBase &tage, Addr pc, bool cond)
Definition tage_sc_l.hh:95

Generated on Mon May 26 2025 09:19:08 for gem5 by doxygen 1.13.2