gem5 v24.0.0.0
Loading...
Searching...
No Matches
multiperspective_perceptron_tage_64KB.cc
Go to the documentation of this file.
1/*
2 * Copyright 2019 Texas A&M University
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * 3. Neither the name of the copyright holder nor the names of its
15 * contributors may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Author: Daniel A. Jiménez
31 * Adapted to gem5 by: Javier Bueno Hedo
32 *
33 */
34
35/*
36 * Multiperspective Perceptron Predictor with TAGE (by Daniel A. Jiménez)
37 * 64 KB version
38 */
39
41
42namespace gem5
43{
44
45namespace branch_prediction
46{
47
49 const MPP_StatisticalCorrector_64KBParams &p)
51 numEntriesSecondLocalHistories(p.numEntriesSecondLocalHistories),
52 numEntriesThirdLocalHistories(p.numEntriesThirdLocalHistories),
53 snb(p.snb),
54 logSnb(p.logSnb),
55 sm(p.sm),
56 tnb(p.tnb),
57 logTnb(p.logTnb),
58 tm(p.tm)
59{
62}
63
66{
68
69 sh->setNumOrdinalHistories(3);
70 sh->initLocalHistory(1, numEntriesFirstLocalHistories, 4);
71 sh->initLocalHistory(2, numEntriesSecondLocalHistories, 5);
72 sh->initLocalHistory(3, numEntriesThirdLocalHistories, 3);
73
74 return sh;
75}
76
77
78void
80 StatisticalCorrector::BranchInfo* bi, int &lsum) const
81{
82 int8_t ctr = bias[getIndBias(branch_pc, bi, false /* unused */)];
83 lsum += 2.09 * ctr;
84 ctr = biasSK[getIndBiasSK(branch_pc, bi)];
85 lsum += 2.08 * ctr;
86}
87
88int
90 StatisticalCorrector::BranchInfo* bi, int & lsum, int64_t phist)
91{
93 unsigned int pc = branch_pc;
94 lsum += gPredict((pc << 1) + bi->predBeforeSC, sh->globalHist << 11,
95 gm, ggehl, gnb, logGnb, wg);
96
97 // Local History #1
98 lsum += 2.02 * gPredict(branch_pc, sh->getLocalHistory(1, branch_pc),
99 lm, lgehl, lnb, logLnb, wl);
100 if (sh->getLocalHistory(1, branch_pc) == 2047) lsum += 4;
101 if (sh->getLocalHistory(1, branch_pc) == 0) lsum -= 4;
102
103 // Local History #3
104 lsum += gPredict(branch_pc, sh->getLocalHistory(3, branch_pc) << 11,
105 tm, tgehl, tnb, logTnb, wt);
106
107 // Local History #2
108 lsum += gPredict(branch_pc, sh->getLocalHistory(2, branch_pc),
109 sm, sgehl, snb, logSnb, ws);
110
111 lsum += gPredict(branch_pc, sh->getHistoryStackEntry(),
112 pm, pgehl, pnb, logPnb, wp);
113
114 int thres = pUpdateThreshold[getIndUpd(branch_pc)];
115
116 return thres;
117}
118
119void
121 StatisticalCorrector::BranchInfo* bi, int64_t phist)
122{
124
125 gUpdate((pc << 1) + bi->predBeforeSC, taken, sh->globalHist << 11,
126 gm, ggehl, gnb, logGnb, wg, bi);
127
128 gUpdate(pc, taken, sh->getLocalHistory(1, pc),
129 lm, lgehl, lnb, logLnb, wl, bi);
130
131 gUpdate(pc, taken, sh->getLocalHistory(2, pc),
132 sm, sgehl, snb, logSnb, ws, bi);
133
134 gUpdate(pc, taken, sh->getLocalHistory(3, pc) << 11,
135 tm, tgehl, tnb, logTnb, wt, bi);
136
137 gUpdate(pc, taken, sh->getHistoryStackEntry(),
138 pm, pgehl, pnb, logPnb, wp, bi);
139}
140
141void
143 const StaticInstPtr &inst, bool taken,
145{
146 int brtype = inst->isDirectCtrl() ? 0 : 2;
147 if (! inst->isUncondCtrl()) {
148 ++brtype;
149 }
150
152
153 if (brtype & 1) {
154 sh->globalHist = (sh->globalHist << 1) + taken;
155 sh->updateLocalHistory(2, branch_pc, taken,
156 (branch_pc ^ (branch_pc >> 4)) & 15);
157 sh->updateLocalHistory(3, branch_pc, taken);
158 }
159 sh->updateHistoryStack(corrTarget, taken, inst->isCall(),
160 inst->isReturn());
161
162 StatisticalCorrector::scHistoryUpdate(branch_pc, inst, taken, bi,
163 corrTarget);
164}
165
166size_t
168{
169 size_t bits = 16; //global histories
170
172
173 bits += scCountersWidth * 2 * (1 << logBias); //2 bias arrays
174
175 bits += (gnb - 2) * (1 << logGnb) * (scCountersWidth - 1) +
176 (1 << (logGnb - 1)) * (2 * scCountersWidth - 1);
177
178 bits += (pnb - 2) * (1 << logPnb) * (scCountersWidth - 1) +
179 (1 << (logPnb - 1)) * (2 * scCountersWidth - 1);
180
181 bits += (lnb - 2) * (1 << logLnb) * (scCountersWidth - 1) +
182 (1 << (logLnb - 1)) * (2 * scCountersWidth - 1);
183
185
186 bits += (snb - 2) * (1 << logSnb) * (scCountersWidth - 1) +
187 (1 << (logSnb - 1)) * (2 * scCountersWidth - 1);
188
190
191 bits += (tnb - 2) * (1 << logTnb) * (scCountersWidth - 1) +
192 (1 << (logTnb - 1)) * (2 * scCountersWidth - 1);
193
194 /* tm[0] is artificially increased by 11 to accomodate IMLI */
196
197 bits += 16 * 16; // History stack
198 bits += 4; // History stack pointer
199
200 bits += 3 * chooserConfWidth; // 3 chooser counters
201
202 return bits;
203}
204
206 const MultiperspectivePerceptronTAGE64KBParams &p)
208{
209}
210
211void
213{
214 addSpec(new BLURRYPATH(5, 15, -1, 2.25, 0, 6, *this));
215 addSpec(new BLURRYPATH(8, 10, -1, 2.25, 0, 6, *this));
216 addSpec(new RECENCYPOS(31, 3.5, 0, 6, *this));
217 addSpec(new GHISTMODPATH(3, 7, 1, 2.24, 0, 6, *this));
218 addSpec(new MODPATH(3, 20, 3, 2.24, 0, 6, *this));
219 addSpec(new IMLI(1, 2.23, 0, 6, *this));
220 addSpec(new IMLI(4, 1.98, 0, 6, *this));
221 addSpec(new RECENCY(9, 3, -1, 2.51, 0, 6, *this));
222 addSpec(new ACYCLIC(12, -1, -1, 2.0, 0, 6, *this));
223}
224
225} // namespace branch_prediction
226} // namespace gem5
bool isDirectCtrl() const
bool isUncondCtrl() const
bool isReturn() const
bool isCall() const
void getBiasLSUM(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum) const override
StatisticalCorrector::SCThreadHistory * makeThreadHistory() override
void gUpdates(ThreadID tid, Addr pc, bool taken, StatisticalCorrector::BranchInfo *bi, int64_t phist) override
MPP_StatisticalCorrector_64KB(const MPP_StatisticalCorrector_64KBParams &p)
void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, StatisticalCorrector::BranchInfo *bi, Addr corrTarget) override
int gPredictions(ThreadID tid, Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum, int64_t phist) override
void gUpdate(Addr branch_pc, bool taken, int64_t hist, std::vector< int > &length, std::vector< int8_t > *tab, int nbr, int logs, std::vector< int8_t > &w, StatisticalCorrector::BranchInfo *bi) override
unsigned getIndBiasSK(Addr branch_pc, StatisticalCorrector::BranchInfo *bi) const override
unsigned getIndBias(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, bool bias) const override
MultiperspectivePerceptronTAGE64KB(const MultiperspectivePerceptronTAGE64KBParams &p)
void addSpec(HistorySpec *spec)
Add a table spec to the prefetcher.
void initGEHLTable(unsigned numLenghts, std::vector< int > lengths, std::vector< int8_t > *&table, unsigned logNumEntries, std::vector< int8_t > &w, int8_t wInitValue)
virtual void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, BranchInfo *tage_bi, Addr corrTarget)
int gPredict(Addr branch_pc, int64_t hist, std::vector< int > &length, std::vector< int8_t > *tab, int nbr, int logs, std::vector< int8_t > &w)
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:79
Bitfield< 8, 7 > sh
Bitfield< 0, 0 > sm
Bitfield< 4 > pc
Bitfield< 0 > p
Bitfield< 20, 16 > bi
Definition types.hh:80
Bitfield< 32 > tm
Definition misc.hh:112
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0