gem5  v20.1.0.0
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 
43  const MPP_StatisticalCorrector_64KBParams *p)
45  numEntriesSecondLocalHistories(p->numEntriesSecondLocalHistories),
46  numEntriesThirdLocalHistories(p->numEntriesThirdLocalHistories),
47  snb(p->snb),
48  logSnb(p->logSnb),
49  sm(p->sm),
50  tnb(p->tnb),
51  logTnb(p->logTnb),
52  tm(p->tm)
53 {
54  initGEHLTable(snb, sm, sgehl, logSnb, ws, -1);
55  initGEHLTable(tnb, tm, tgehl, logTnb, wt, -1);
56 }
57 
60 {
62 
63  sh->setNumOrdinalHistories(3);
64  sh->initLocalHistory(1, numEntriesFirstLocalHistories, 4);
65  sh->initLocalHistory(2, numEntriesSecondLocalHistories, 5);
66  sh->initLocalHistory(3, numEntriesThirdLocalHistories, 3);
67 
68  return sh;
69 }
70 
71 
72 void
74  StatisticalCorrector::BranchInfo* bi, int &lsum) const
75 {
76  int8_t ctr = bias[getIndBias(branch_pc, bi, false /* unused */)];
77  lsum += 2.09 * ctr;
78  ctr = biasSK[getIndBiasSK(branch_pc, bi)];
79  lsum += 2.08 * ctr;
80 }
81 
82 int
84  StatisticalCorrector::BranchInfo* bi, int & lsum, int64_t phist)
85 {
87  unsigned int pc = branch_pc;
88  lsum += gPredict((pc << 1) + bi->predBeforeSC, sh->globalHist << 11,
89  gm, ggehl, gnb, logGnb, wg);
90 
91  // Local History #1
92  lsum += 2.02 * gPredict(branch_pc, sh->getLocalHistory(1, branch_pc),
93  lm, lgehl, lnb, logLnb, wl);
94  if (sh->getLocalHistory(1, branch_pc) == 2047) lsum += 4;
95  if (sh->getLocalHistory(1, branch_pc) == 0) lsum -= 4;
96 
97  // Local History #3
98  lsum += gPredict(branch_pc, sh->getLocalHistory(3, branch_pc) << 11,
99  tm, tgehl, tnb, logTnb, wt);
100 
101  // Local History #2
102  lsum += gPredict(branch_pc, sh->getLocalHistory(2, branch_pc),
103  sm, sgehl, snb, logSnb, ws);
104 
105  lsum += gPredict(branch_pc, sh->getHistoryStackEntry(),
106  pm, pgehl, pnb, logPnb, wp);
107 
108  int thres = pUpdateThreshold[getIndUpd(branch_pc)];
109 
110  return thres;
111 }
112 
113 void
115  StatisticalCorrector::BranchInfo* bi, int64_t phist)
116 {
118 
119  gUpdate((pc << 1) + bi->predBeforeSC, taken, sh->globalHist << 11,
120  gm, ggehl, gnb, logGnb, wg, bi);
121 
122  gUpdate(pc, taken, sh->getLocalHistory(1, pc),
123  lm, lgehl, lnb, logLnb, wl, bi);
124 
125  gUpdate(pc, taken, sh->getLocalHistory(2, pc),
126  sm, sgehl, snb, logSnb, ws, bi);
127 
128  gUpdate(pc, taken, sh->getLocalHistory(3, pc) << 11,
129  tm, tgehl, tnb, logTnb, wt, bi);
130 
131  gUpdate(pc, taken, sh->getHistoryStackEntry(),
132  pm, pgehl, pnb, logPnb, wp, bi);
133 }
134 
135 void
137  const StaticInstPtr &inst, bool taken,
139 {
140  int brtype = inst->isDirectCtrl() ? 0 : 2;
141  if (! inst->isUncondCtrl()) {
142  ++brtype;
143  }
144 
146 
147  if (brtype & 1) {
148  sh->globalHist = (sh->globalHist << 1) + taken;
149  sh->updateLocalHistory(2, branch_pc, taken,
150  (branch_pc ^ (branch_pc >> 4)) & 15);
151  sh->updateLocalHistory(3, branch_pc, taken);
152  }
153  sh->updateHistoryStack(corrTarget, taken, inst->isCall(),
154  inst->isReturn());
155 
156  StatisticalCorrector::scHistoryUpdate(branch_pc, inst, taken, bi,
157  corrTarget);
158 }
159 
160 size_t
162 {
163  size_t bits = 16; //global histories
164 
166 
167  bits += scCountersWidth * 2 * (1 << logBias); //2 bias arrays
168 
169  bits += (gnb - 2) * (1 << logGnb) * (scCountersWidth - 1) +
170  (1 << (logGnb - 1)) * (2 * scCountersWidth - 1);
171 
172  bits += (pnb - 2) * (1 << logPnb) * (scCountersWidth - 1) +
173  (1 << (logPnb - 1)) * (2 * scCountersWidth - 1);
174 
175  bits += (lnb - 2) * (1 << logLnb) * (scCountersWidth - 1) +
176  (1 << (logLnb - 1)) * (2 * scCountersWidth - 1);
177 
179 
180  bits += (snb - 2) * (1 << logSnb) * (scCountersWidth - 1) +
181  (1 << (logSnb - 1)) * (2 * scCountersWidth - 1);
182 
184 
185  bits += (tnb - 2) * (1 << logTnb) * (scCountersWidth - 1) +
186  (1 << (logTnb - 1)) * (2 * scCountersWidth - 1);
187 
188  /* tm[0] is artificially increased by 11 to accomodate IMLI */
189  bits += numEntriesThirdLocalHistories * (tm[0] - 11);
190 
191  bits += 16 * 16; // History stack
192  bits += 4; // History stack pointer
193 
194  bits += 3 * chooserConfWidth; // 3 chooser counters
195 
196  return bits;
197 }
198 
200 MPP_StatisticalCorrector_64KBParams::create()
201 {
202  return new MPP_StatisticalCorrector_64KB(this);
203 }
204 
205 
207  const MultiperspectivePerceptronTAGE64KBParams *p)
209 {
210 }
211 
212 void
214 {
215  addSpec(new BLURRYPATH(5, 15, -1, 2.25, 0, 6, *this));
216  addSpec(new BLURRYPATH(8, 10, -1, 2.25, 0, 6, *this));
217  addSpec(new RECENCYPOS(31, 3.5, 0, 6, *this));
218  addSpec(new GHISTMODPATH(3, 7, 1, 2.24, 0, 6, *this));
219  addSpec(new MODPATH(3, 20, 3, 2.24, 0, 6, *this));
220  addSpec(new IMLI(1, 2.23, 0, 6, *this));
221  addSpec(new IMLI(4, 1.98, 0, 6, *this));
222  addSpec(new RECENCY(9, 3, -1, 2.51, 0, 6, *this));
223  addSpec(new ACYCLIC(12, -1, -1, 2.0, 0, 6, *this));
224 }
225 
227 MultiperspectivePerceptronTAGE64KBParams::create()
228 {
229  return new MultiperspectivePerceptronTAGE64KB(this);
230 }
MPP_StatisticalCorrector::gUpdate
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
Definition: multiperspective_perceptron_tage.cc:333
MPP_StatisticalCorrector::getIndBiasSK
unsigned getIndBiasSK(Addr branch_pc, StatisticalCorrector::BranchInfo *bi) const override
Definition: multiperspective_perceptron_tage.cc:306
StaticInst::isDirectCtrl
bool isDirectCtrl() const
Definition: static_inst.hh:178
ArmISA::sh
Bitfield< 8, 7 > sh
Definition: miscregs_types.hh:654
MultiperspectivePerceptron::GHISTMODPATH
Definition: multiperspective_perceptron.hh:856
MultiperspectivePerceptron::ACYCLIC
Definition: multiperspective_perceptron.hh:534
MPP_StatisticalCorrector::getIndBias
unsigned getIndBias(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, bool bias) const override
Definition: multiperspective_perceptron_tage.cc:298
MultiperspectivePerceptron::addSpec
void addSpec(HistorySpec *spec)
Add a table spec to the prefetcher.
Definition: multiperspective_perceptron.hh:476
MPP_StatisticalCorrector::MPP_SCThreadHistory
Definition: multiperspective_perceptron_tage.hh:111
MPP_StatisticalCorrector_64KB::logSnb
const unsigned logSnb
Definition: multiperspective_perceptron_tage_64KB.hh:52
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
MultiperspectivePerceptron::RECENCY
Definition: multiperspective_perceptron.hh:626
StatisticalCorrector::chooserConfWidth
const unsigned chooserConfWidth
Definition: statistical_corrector.hh:173
StatisticalCorrector::bias
std::vector< int8_t > bias
Definition: statistical_corrector.hh:162
MultiperspectivePerceptron::IMLI
Definition: multiperspective_perceptron.hh:668
StatisticalCorrector::lgehl
std::vector< int8_t > * lgehl
Definition: statistical_corrector.hh:152
StatisticalCorrector::scCountersWidth
const unsigned scCountersWidth
Definition: statistical_corrector.hh:180
StatisticalCorrector::pUpdateThreshold
std::vector< int > pUpdateThreshold
Definition: statistical_corrector.hh:169
MPP_StatisticalCorrector
Definition: multiperspective_perceptron_tage.hh:94
MPP_StatisticalCorrector::logGnb
const unsigned logGnb
Definition: multiperspective_perceptron_tage.hh:106
MPP_StatisticalCorrector_64KB::makeThreadHistory
StatisticalCorrector::SCThreadHistory * makeThreadHistory() override
Definition: multiperspective_perceptron_tage_64KB.cc:59
StatisticalCorrector::numEntriesFirstLocalHistories
const unsigned numEntriesFirstLocalHistories
Definition: statistical_corrector.hh:139
MPP_StatisticalCorrector_64KB::tgehl
std::vector< int8_t > * tgehl
Definition: multiperspective_perceptron_tage_64KB.hh:61
MPP_StatisticalCorrector_64KB::sm
std::vector< int > sm
Definition: multiperspective_perceptron_tage_64KB.hh:53
MPP_StatisticalCorrector_64KB::gUpdates
void gUpdates(ThreadID tid, Addr pc, bool taken, StatisticalCorrector::BranchInfo *bi, int64_t phist) override
Definition: multiperspective_perceptron_tage_64KB.cc:114
MultiperspectivePerceptronTAGE64KB::createSpecs
void createSpecs() override
Creates the tables of the predictor.
Definition: multiperspective_perceptron_tage_64KB.cc:213
MultiperspectivePerceptronTAGE
Definition: multiperspective_perceptron_tage.hh:182
StatisticalCorrector::SCThreadHistory
Definition: statistical_corrector.hh:69
MPP_StatisticalCorrector_64KB::wt
std::vector< int8_t > wt
Definition: multiperspective_perceptron_tage_64KB.hh:62
StatisticalCorrector::logLnb
const unsigned logLnb
Definition: statistical_corrector.hh:150
MPP_StatisticalCorrector_64KB::getBiasLSUM
void getBiasLSUM(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum) const override
Definition: multiperspective_perceptron_tage_64KB.cc:73
MultiperspectivePerceptron::MODPATH
Definition: multiperspective_perceptron.hh:757
PowerISA::bi
Bitfield< 20, 16 > bi
Definition: types.hh:63
MPP_StatisticalCorrector::wg
std::vector< int8_t > wg
Definition: multiperspective_perceptron_tage.hh:109
MPP_StatisticalCorrector_64KB::numEntriesThirdLocalHistories
const unsigned numEntriesThirdLocalHistories
Definition: multiperspective_perceptron_tage_64KB.hh:48
MPP_StatisticalCorrector_64KB::sgehl
std::vector< int8_t > * sgehl
Definition: multiperspective_perceptron_tage_64KB.hh:54
MultiperspectivePerceptron::RECENCYPOS
Definition: multiperspective_perceptron.hh:934
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
StatisticalCorrector::lm
std::vector< int > lm
Definition: statistical_corrector.hh:151
MultiperspectivePerceptronTAGE64KB::MultiperspectivePerceptronTAGE64KB
MultiperspectivePerceptronTAGE64KB(const MultiperspectivePerceptronTAGE64KBParams *p)
Definition: multiperspective_perceptron_tage_64KB.cc:206
MPP_StatisticalCorrector::pgehl
std::vector< int8_t > * pgehl
Definition: multiperspective_perceptron_tage.hh:101
StatisticalCorrector::logSizeUp
const unsigned logSizeUp
Definition: statistical_corrector.hh:136
MPP_StatisticalCorrector_64KB::logTnb
const unsigned logTnb
Definition: multiperspective_perceptron_tage_64KB.hh:59
multiperspective_perceptron_tage_64KB.hh
StatisticalCorrector::scHistory
SCThreadHistory * scHistory
Definition: statistical_corrector.hh:132
MPP_StatisticalCorrector_64KB::snb
const unsigned snb
Definition: multiperspective_perceptron_tage_64KB.hh:51
MPP_StatisticalCorrector::wp
std::vector< int8_t > wp
Definition: multiperspective_perceptron_tage.hh:102
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
MultiperspectivePerceptron::BLURRYPATH
Definition: multiperspective_perceptron.hh:888
MultiperspectivePerceptronTAGE64KB
Definition: multiperspective_perceptron_tage_64KB.hh:80
StatisticalCorrector::scHistoryUpdate
virtual void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, BranchInfo *tage_bi, Addr corrTarget)
Definition: statistical_corrector.cc:289
StatisticalCorrector::initGEHLTable
void initGEHLTable(unsigned numLenghts, std::vector< int > lengths, std::vector< int8_t > *&table, unsigned logNumEntries, std::vector< int8_t > &w, int8_t wInitValue)
Definition: statistical_corrector.cc:128
MPP_StatisticalCorrector::pnb
const unsigned pnb
Definition: multiperspective_perceptron_tage.hh:98
MPP_StatisticalCorrector::ggehl
std::vector< int8_t > * ggehl
Definition: multiperspective_perceptron_tage.hh:108
StatisticalCorrector::wl
std::vector< int8_t > wl
Definition: statistical_corrector.hh:153
MPP_StatisticalCorrector::logPnb
const unsigned logPnb
Definition: multiperspective_perceptron_tage.hh:99
StatisticalCorrector::biasSK
std::vector< int8_t > biasSK
Definition: statistical_corrector.hh:163
MPP_StatisticalCorrector::gnb
const unsigned gnb
Definition: multiperspective_perceptron_tage.hh:105
MPP_StatisticalCorrector_64KB::gPredictions
int gPredictions(ThreadID tid, Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum, int64_t phist) override
Definition: multiperspective_perceptron_tage_64KB.cc:83
MPP_StatisticalCorrector_64KB::numEntriesSecondLocalHistories
const unsigned numEntriesSecondLocalHistories
Definition: multiperspective_perceptron_tage_64KB.hh:47
MPP_StatisticalCorrector_64KB::getSizeInBits
size_t getSizeInBits() const override
Definition: multiperspective_perceptron_tage_64KB.cc:161
StatisticalCorrector::BranchInfo
Definition: statistical_corrector.hh:192
MPP_StatisticalCorrector_64KB::scHistoryUpdate
void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, StatisticalCorrector::BranchInfo *bi, Addr corrTarget) override
Definition: multiperspective_perceptron_tage_64KB.cc:136
MPP_StatisticalCorrector_64KB::ws
std::vector< int8_t > ws
Definition: multiperspective_perceptron_tage_64KB.hh:55
StatisticalCorrector::gPredict
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)
Definition: statistical_corrector.cc:187
StaticInst::isCall
bool isCall() const
Definition: static_inst.hh:176
MPP_StatisticalCorrector_64KB::MPP_StatisticalCorrector_64KB
MPP_StatisticalCorrector_64KB(const MPP_StatisticalCorrector_64KBParams *p)
Definition: multiperspective_perceptron_tage_64KB.cc:42
StatisticalCorrector::logBias
const unsigned logBias
Definition: statistical_corrector.hh:134
MPP_StatisticalCorrector::getIndUpd
unsigned getIndUpd(Addr branch_pc) const override
Definition: multiperspective_perceptron_tage.cc:327
StatisticalCorrector::pUpdateThresholdWidth
const unsigned pUpdateThresholdWidth
Definition: statistical_corrector.hh:176
MPP_StatisticalCorrector::gm
std::vector< int > gm
Definition: multiperspective_perceptron_tage.hh:107
StatisticalCorrector::lnb
const unsigned lnb
Definition: statistical_corrector.hh:149
RefCountingPtr< StaticInst >
MPP_StatisticalCorrector_64KB
Definition: multiperspective_perceptron_tage_64KB.hh:46
MPP_StatisticalCorrector_64KB::tnb
const unsigned tnb
Definition: multiperspective_perceptron_tage_64KB.hh:58
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
MPP_StatisticalCorrector::pm
std::vector< int > pm
Definition: multiperspective_perceptron_tage.hh:100
MPP_StatisticalCorrector_64KB::tm
std::vector< int > tm
Definition: multiperspective_perceptron_tage_64KB.hh:60
StaticInst::isReturn
bool isReturn() const
Definition: static_inst.hh:177
MipsISA::sm
Bitfield< 1 > sm
Definition: pra_constants.hh:270
StaticInst::isUncondCtrl
bool isUncondCtrl() const
Definition: static_inst.hh:181
bits
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:75

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