gem5  v20.1.0.0
multiperspective_perceptron_tage_8KB.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  * 8 KB version
38  */
39 
41 
43 MPP_TAGE_8KBParams::create()
44 {
45  return new MPP_TAGE_8KB(this);
46 }
47 
49 MPP_LoopPredictor_8KBParams::create()
50 {
51  return new MPP_LoopPredictor_8KB(this);
52 }
53 
55  const MPP_StatisticalCorrector_8KBParams *p)
57 {
58 }
59 
62 {
64 
65  sh->setNumOrdinalHistories(1);
66  sh->initLocalHistory(1, numEntriesFirstLocalHistories, 4);
67 
68  return sh;
69 }
70 
71 void
73  StatisticalCorrector::BranchInfo* bi, int &lsum) const
74 {
75  int8_t ctr = bias[getIndBias(branch_pc, bi, false /* unused */)];
76  lsum += 2 * ctr + 1;
77  ctr = biasSK[getIndBiasSK(branch_pc, bi)];
78  lsum += 2 * ctr + 1;
79 }
80 
81 int
83  StatisticalCorrector::BranchInfo* bi, int & lsum, int64_t phist)
84 {
86  unsigned int pc = branch_pc;
87  lsum += gPredict((pc << 1) + bi->predBeforeSC, sh->globalHist << 11,
88  gm, ggehl, gnb, logGnb, wg);
89 
90  // Local History #1
91  lsum += 2 * gPredict(branch_pc, sh->getLocalHistory(1, branch_pc),
92  lm, lgehl, lnb, logLnb, wl);
93  if (sh->getLocalHistory(1, branch_pc) == 2047) lsum += 4;
94  if (sh->getLocalHistory(1, branch_pc) == 0) lsum -= 4;
95 
96  lsum += gPredict(branch_pc, sh->getHistoryStackEntry(),
97  pm, pgehl, pnb, logPnb, wp);
98 
99  int thres = pUpdateThreshold[getIndUpd(branch_pc)];
100 
101  return thres;
102 }
103 
104 void
106  StatisticalCorrector::BranchInfo* bi, int64_t phist)
107 {
109 
110  gUpdate((pc << 1) + bi->predBeforeSC, taken, sh->globalHist << 11,
111  gm, ggehl, gnb, logGnb, wg, bi);
112 
113  gUpdate(pc, taken, sh->getLocalHistory(1, pc),
114  lm, lgehl, lnb, logLnb, wl, bi);
115 
116  gUpdate(pc, taken, sh->getHistoryStackEntry(),
117  pm, pgehl, pnb, logPnb, wp, bi);
118 }
119 
120 void
122  const StaticInstPtr &inst, bool taken,
124 {
125  int brtype = inst->isDirectCtrl() ? 0 : 2;
126  if (! inst->isUncondCtrl()) {
127  ++brtype;
128  }
129 
131 
132  if (brtype & 1) {
133  sh->globalHist = (sh->globalHist << 1) + taken;
134  }
135  sh->updateHistoryStack(corrTarget, taken, inst->isCall(),
136  inst->isReturn());
137 
138  StatisticalCorrector::scHistoryUpdate(branch_pc, inst, taken, bi,
139  corrTarget);
140 }
141 
142 size_t
144 {
145  size_t bits = 16; //global histories
146 
148 
149  bits += scCountersWidth * 2 * (1 << logBias); //2 bias arrays
150 
151  bits += (gnb - 2) * (1 << logGnb) * (scCountersWidth - 1) +
152  (1 << (logGnb - 1)) * (2 * scCountersWidth - 1);
153 
154  bits += (pnb - 2) * (1 << logPnb) * (scCountersWidth - 1) +
155  (1 << (logPnb - 1)) * (2 * scCountersWidth - 1);
156 
157  bits += (lnb - 2) * (1 << logLnb) * (scCountersWidth - 1) +
158  (1 << (logLnb - 1)) * (2 * scCountersWidth - 1);
159 
161 
162  bits += 16 * 16; // History stack
163  bits += 4; // History stack pointer
164 
165  bits += 3 * chooserConfWidth; // 3 chooser counters
166 
167  return bits;
168 }
169 
171 MPP_StatisticalCorrector_8KBParams::create()
172 {
173  return new MPP_StatisticalCorrector_8KB(this);
174 }
175 
177  const MultiperspectivePerceptronTAGE8KBParams *p)
179 {
180 }
181 
182 void
184 {
185  addSpec(new BLURRYPATH(5, 15, -1, 2.25, 0, 6, *this));
186  addSpec(new RECENCYPOS(31, 3.5, 0, 6, *this));
187  addSpec(new GHISTMODPATH(3, 7, 1, 2.24, 0, 6, *this));
188  addSpec(new IMLI(1, 2.23, 0, 6, *this));
189  addSpec(new IMLI(4, 1.98, 0, 6, *this));
190 }
191 
193 MultiperspectivePerceptronTAGE8KBParams::create()
194 {
195  return new MultiperspectivePerceptronTAGE8KB(this);
196 }
MPP_StatisticalCorrector_8KB::gUpdates
void gUpdates(ThreadID tid, Addr pc, bool taken, StatisticalCorrector::BranchInfo *bi, int64_t phist) override
Definition: multiperspective_perceptron_tage_8KB.cc:105
MPP_StatisticalCorrector_8KB::gPredictions
int gPredictions(ThreadID tid, Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum, int64_t phist) override
Definition: multiperspective_perceptron_tage_8KB.cc:82
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
MultiperspectivePerceptronTAGE8KB::createSpecs
void createSpecs() override
Creates the tables of the predictor.
Definition: multiperspective_perceptron_tage_8KB.cc:183
MPP_StatisticalCorrector_8KB::MPP_StatisticalCorrector_8KB
MPP_StatisticalCorrector_8KB(const MPP_StatisticalCorrector_8KBParams *p)
Definition: multiperspective_perceptron_tage_8KB.cc:54
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
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
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
StatisticalCorrector::numEntriesFirstLocalHistories
const unsigned numEntriesFirstLocalHistories
Definition: statistical_corrector.hh:139
MultiperspectivePerceptronTAGE
Definition: multiperspective_perceptron_tage.hh:182
StatisticalCorrector::SCThreadHistory
Definition: statistical_corrector.hh:69
StatisticalCorrector::logLnb
const unsigned logLnb
Definition: statistical_corrector.hh:150
PowerISA::bi
Bitfield< 20, 16 > bi
Definition: types.hh:63
MultiperspectivePerceptronTAGE8KB::MultiperspectivePerceptronTAGE8KB
MultiperspectivePerceptronTAGE8KB(const MultiperspectivePerceptronTAGE8KBParams *p)
Definition: multiperspective_perceptron_tage_8KB.cc:176
MPP_StatisticalCorrector::wg
std::vector< int8_t > wg
Definition: multiperspective_perceptron_tage.hh:109
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
MultiperspectivePerceptronTAGE8KB
Definition: multiperspective_perceptron_tage_8KB.hh:76
MPP_StatisticalCorrector_8KB::scHistoryUpdate
void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, StatisticalCorrector::BranchInfo *bi, Addr corrTarget) override
Definition: multiperspective_perceptron_tage_8KB.cc:121
MPP_StatisticalCorrector::pgehl
std::vector< int8_t > * pgehl
Definition: multiperspective_perceptron_tage.hh:101
StatisticalCorrector::logSizeUp
const unsigned logSizeUp
Definition: statistical_corrector.hh:136
StatisticalCorrector::scHistory
SCThreadHistory * scHistory
Definition: statistical_corrector.hh:132
MPP_StatisticalCorrector_8KB::getSizeInBits
size_t getSizeInBits() const override
Definition: multiperspective_perceptron_tage_8KB.cc:143
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
MPP_StatisticalCorrector_8KB::makeThreadHistory
StatisticalCorrector::SCThreadHistory * makeThreadHistory() override
Definition: multiperspective_perceptron_tage_8KB.cc:61
StatisticalCorrector::scHistoryUpdate
virtual void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, BranchInfo *tage_bi, Addr corrTarget)
Definition: statistical_corrector.cc:289
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
multiperspective_perceptron_tage_8KB.hh
StatisticalCorrector::BranchInfo
Definition: statistical_corrector.hh:192
MPP_StatisticalCorrector_8KB
Definition: multiperspective_perceptron_tage_8KB.hh:60
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
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_LoopPredictor_8KB
Definition: multiperspective_perceptron_tage_8KB.hh:54
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 >
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
MPP_StatisticalCorrector::pm
std::vector< int > pm
Definition: multiperspective_perceptron_tage.hh:100
MPP_TAGE_8KB
Definition: multiperspective_perceptron_tage_8KB.hh:49
StaticInst::isReturn
bool isReturn() const
Definition: static_inst.hh:177
MPP_StatisticalCorrector_8KB::getBiasLSUM
void getBiasLSUM(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum) const override
Definition: multiperspective_perceptron_tage_8KB.cc:72
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