gem5  v21.1.0.2
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 
42 namespace gem5
43 {
44 
45 namespace branch_prediction
46 {
47 
49  const MPP_StatisticalCorrector_8KBParams &p)
51 {
52 }
53 
56 {
58 
59  sh->setNumOrdinalHistories(1);
60  sh->initLocalHistory(1, numEntriesFirstLocalHistories, 4);
61 
62  return sh;
63 }
64 
65 void
67  StatisticalCorrector::BranchInfo* bi, int &lsum) const
68 {
69  int8_t ctr = bias[getIndBias(branch_pc, bi, false /* unused */)];
70  lsum += 2 * ctr + 1;
71  ctr = biasSK[getIndBiasSK(branch_pc, bi)];
72  lsum += 2 * ctr + 1;
73 }
74 
75 int
77  StatisticalCorrector::BranchInfo* bi, int & lsum, int64_t phist)
78 {
80  unsigned int pc = branch_pc;
81  lsum += gPredict((pc << 1) + bi->predBeforeSC, sh->globalHist << 11,
82  gm, ggehl, gnb, logGnb, wg);
83 
84  // Local History #1
85  lsum += 2 * gPredict(branch_pc, sh->getLocalHistory(1, branch_pc),
86  lm, lgehl, lnb, logLnb, wl);
87  if (sh->getLocalHistory(1, branch_pc) == 2047) lsum += 4;
88  if (sh->getLocalHistory(1, branch_pc) == 0) lsum -= 4;
89 
90  lsum += gPredict(branch_pc, sh->getHistoryStackEntry(),
91  pm, pgehl, pnb, logPnb, wp);
92 
93  int thres = pUpdateThreshold[getIndUpd(branch_pc)];
94 
95  return thres;
96 }
97 
98 void
100  StatisticalCorrector::BranchInfo* bi, int64_t phist)
101 {
103 
104  gUpdate((pc << 1) + bi->predBeforeSC, taken, sh->globalHist << 11,
105  gm, ggehl, gnb, logGnb, wg, bi);
106 
107  gUpdate(pc, taken, sh->getLocalHistory(1, pc),
108  lm, lgehl, lnb, logLnb, wl, bi);
109 
110  gUpdate(pc, taken, sh->getHistoryStackEntry(),
111  pm, pgehl, pnb, logPnb, wp, bi);
112 }
113 
114 void
116  const StaticInstPtr &inst, bool taken,
118 {
119  int brtype = inst->isDirectCtrl() ? 0 : 2;
120  if (! inst->isUncondCtrl()) {
121  ++brtype;
122  }
123 
125 
126  if (brtype & 1) {
127  sh->globalHist = (sh->globalHist << 1) + taken;
128  }
129  sh->updateHistoryStack(corrTarget, taken, inst->isCall(),
130  inst->isReturn());
131 
132  StatisticalCorrector::scHistoryUpdate(branch_pc, inst, taken, bi,
133  corrTarget);
134 }
135 
136 size_t
138 {
139  size_t bits = 16; //global histories
140 
142 
143  bits += scCountersWidth * 2 * (1 << logBias); //2 bias arrays
144 
145  bits += (gnb - 2) * (1 << logGnb) * (scCountersWidth - 1) +
146  (1 << (logGnb - 1)) * (2 * scCountersWidth - 1);
147 
148  bits += (pnb - 2) * (1 << logPnb) * (scCountersWidth - 1) +
149  (1 << (logPnb - 1)) * (2 * scCountersWidth - 1);
150 
151  bits += (lnb - 2) * (1 << logLnb) * (scCountersWidth - 1) +
152  (1 << (logLnb - 1)) * (2 * scCountersWidth - 1);
153 
155 
156  bits += 16 * 16; // History stack
157  bits += 4; // History stack pointer
158 
159  bits += 3 * chooserConfWidth; // 3 chooser counters
160 
161  return bits;
162 }
163 
165  const MultiperspectivePerceptronTAGE8KBParams &p)
167 {
168 }
169 
170 void
172 {
173  addSpec(new BLURRYPATH(5, 15, -1, 2.25, 0, 6, *this));
174  addSpec(new RECENCYPOS(31, 3.5, 0, 6, *this));
175  addSpec(new GHISTMODPATH(3, 7, 1, 2.24, 0, 6, *this));
176  addSpec(new IMLI(1, 2.23, 0, 6, *this));
177  addSpec(new IMLI(4, 1.98, 0, 6, *this));
178 }
179 
180 } // namespace branch_prediction
181 } // namespace gem5
gem5::branch_prediction::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:99
gem5::branch_prediction::StatisticalCorrector::scHistory
SCThreadHistory * scHistory
Definition: statistical_corrector.hh:139
gem5::branch_prediction::StatisticalCorrector::scHistoryUpdate
virtual void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, BranchInfo *tage_bi, Addr corrTarget)
Definition: statistical_corrector.cc:295
gem5::branch_prediction::StatisticalCorrector::lm
std::vector< int > lm
Definition: statistical_corrector.hh:158
gem5::branch_prediction::MPP_StatisticalCorrector::getIndBias
unsigned getIndBias(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, bool bias) const override
Definition: multiperspective_perceptron_tage.cc:291
gem5::branch_prediction::MPP_StatisticalCorrector_8KB::getBiasLSUM
void getBiasLSUM(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum) const override
Definition: multiperspective_perceptron_tage_8KB.cc:66
gem5::branch_prediction::MultiperspectivePerceptron::GHISTMODPATH
Definition: multiperspective_perceptron.hh:877
gem5::branch_prediction::StatisticalCorrector::biasSK
std::vector< int8_t > biasSK
Definition: statistical_corrector.hh:170
gem5::branch_prediction::StatisticalCorrector::wl
std::vector< int8_t > wl
Definition: statistical_corrector.hh:160
gem5::branch_prediction::MPP_StatisticalCorrector::logGnb
const unsigned logGnb
Definition: multiperspective_perceptron_tage.hh:116
gem5::branch_prediction::MultiperspectivePerceptron::addSpec
void addSpec(HistorySpec *spec)
Add a table spec to the prefetcher.
Definition: multiperspective_perceptron.hh:487
gem5::branch_prediction::StatisticalCorrector::lnb
const unsigned lnb
Definition: statistical_corrector.hh:156
gem5::PowerISA::bi
Bitfield< 20, 16 > bi
Definition: types.hh:80
gem5::RefCountingPtr< StaticInst >
gem5::branch_prediction::MPP_StatisticalCorrector
Definition: multiperspective_perceptron_tage.hh:103
gem5::branch_prediction::MPP_StatisticalCorrector::gnb
const unsigned gnb
Definition: multiperspective_perceptron_tage.hh:115
gem5::StaticInst::isReturn
bool isReturn() const
Definition: static_inst.hh:184
gem5::branch_prediction::MPP_StatisticalCorrector::getIndBiasSK
unsigned getIndBiasSK(Addr branch_pc, StatisticalCorrector::BranchInfo *bi) const override
Definition: multiperspective_perceptron_tage.cc:299
gem5::branch_prediction::StatisticalCorrector::logSizeUp
const unsigned logSizeUp
Definition: statistical_corrector.hh:143
gem5::branch_prediction::StatisticalCorrector::logBias
const unsigned logBias
Definition: statistical_corrector.hh:141
gem5::branch_prediction::MPP_StatisticalCorrector::wg
std::vector< int8_t > wg
Definition: multiperspective_perceptron_tage.hh:119
gem5::branch_prediction::StatisticalCorrector::scCountersWidth
const unsigned scCountersWidth
Definition: statistical_corrector.hh:187
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::branch_prediction::StatisticalCorrector::pUpdateThreshold
std::vector< int > pUpdateThreshold
Definition: statistical_corrector.hh:176
gem5::branch_prediction::MPP_StatisticalCorrector_8KB::makeThreadHistory
StatisticalCorrector::SCThreadHistory * makeThreadHistory() override
Definition: multiperspective_perceptron_tage_8KB.cc:55
gem5::branch_prediction::StatisticalCorrector::numEntriesFirstLocalHistories
const unsigned numEntriesFirstLocalHistories
Definition: statistical_corrector.hh:146
gem5::branch_prediction::StatisticalCorrector::pUpdateThresholdWidth
const unsigned pUpdateThresholdWidth
Definition: statistical_corrector.hh:183
gem5::branch_prediction::MultiperspectivePerceptron::IMLI
Definition: multiperspective_perceptron.hh:684
gem5::branch_prediction::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:115
gem5::bits
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:76
gem5::branch_prediction::MultiperspectivePerceptronTAGE8KB::MultiperspectivePerceptronTAGE8KB
MultiperspectivePerceptronTAGE8KB(const MultiperspectivePerceptronTAGE8KBParams &p)
Definition: multiperspective_perceptron_tage_8KB.cc:164
gem5::StaticInst::isDirectCtrl
bool isDirectCtrl() const
Definition: static_inst.hh:185
gem5::branch_prediction::MPP_StatisticalCorrector_8KB::getSizeInBits
size_t getSizeInBits() const override
Definition: multiperspective_perceptron_tage_8KB.cc:137
gem5::branch_prediction::MPP_StatisticalCorrector::gm
std::vector< int > gm
Definition: multiperspective_perceptron_tage.hh:117
gem5::branch_prediction::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:76
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::branch_prediction::StatisticalCorrector::BranchInfo
Definition: statistical_corrector.hh:200
gem5::branch_prediction::MPP_StatisticalCorrector::pnb
const unsigned pnb
Definition: multiperspective_perceptron_tage.hh:108
gem5::ArmISA::sh
Bitfield< 8, 7 > sh
Definition: misc_types.hh:660
gem5::branch_prediction::MPP_StatisticalCorrector::pm
std::vector< int > pm
Definition: multiperspective_perceptron_tage.hh:110
gem5::branch_prediction::StatisticalCorrector::lgehl
std::vector< int8_t > * lgehl
Definition: statistical_corrector.hh:159
gem5::branch_prediction::MPP_StatisticalCorrector::getIndUpd
unsigned getIndUpd(Addr branch_pc) const override
Definition: multiperspective_perceptron_tage.cc:320
gem5::branch_prediction::MPP_StatisticalCorrector::ggehl
std::vector< int8_t > * ggehl
Definition: multiperspective_perceptron_tage.hh:118
gem5::branch_prediction::MPP_StatisticalCorrector::wp
std::vector< int8_t > wp
Definition: multiperspective_perceptron_tage.hh:112
gem5::branch_prediction::MultiperspectivePerceptron::RECENCYPOS
Definition: multiperspective_perceptron.hh:957
gem5::branch_prediction::MPP_StatisticalCorrector_8KB::MPP_StatisticalCorrector_8KB
MPP_StatisticalCorrector_8KB(const MPP_StatisticalCorrector_8KBParams &p)
Definition: multiperspective_perceptron_tage_8KB.cc:48
multiperspective_perceptron_tage_8KB.hh
gem5::branch_prediction::MPP_StatisticalCorrector::MPP_SCThreadHistory
Definition: multiperspective_perceptron_tage.hh:121
gem5::branch_prediction::StatisticalCorrector::bias
std::vector< int8_t > bias
Definition: statistical_corrector.hh:169
gem5::branch_prediction::MultiperspectivePerceptronTAGE
Definition: multiperspective_perceptron_tage.hh:193
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::StaticInst::isCall
bool isCall() const
Definition: static_inst.hh:183
gem5::branch_prediction::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:326
gem5::branch_prediction::StatisticalCorrector::SCThreadHistory
Definition: statistical_corrector.hh:75
gem5::branch_prediction::StatisticalCorrector::logLnb
const unsigned logLnb
Definition: statistical_corrector.hh:157
gem5::StaticInst::isUncondCtrl
bool isUncondCtrl() const
Definition: static_inst.hh:188
gem5::branch_prediction::MultiperspectivePerceptronTAGE8KB::createSpecs
void createSpecs() override
Creates the tables of the predictor.
Definition: multiperspective_perceptron_tage_8KB.cc:171
gem5::branch_prediction::MPP_StatisticalCorrector::logPnb
const unsigned logPnb
Definition: multiperspective_perceptron_tage.hh:109
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::branch_prediction::MultiperspectivePerceptron::BLURRYPATH
Definition: multiperspective_perceptron.hh:910
gem5::branch_prediction::MPP_StatisticalCorrector::pgehl
std::vector< int8_t > * pgehl
Definition: multiperspective_perceptron_tage.hh:111
gem5::branch_prediction::StatisticalCorrector::chooserConfWidth
const unsigned chooserConfWidth
Definition: statistical_corrector.hh:180
gem5::branch_prediction::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:193
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:242

Generated on Tue Sep 21 2021 12:25:05 for gem5 by doxygen 1.8.17