gem5  v22.1.0.0
multiperspective_perceptron_tage.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  */
38 
40 
41 #include "base/random.hh"
42 
43 namespace gem5
44 {
45 
46 namespace branch_prediction
47 {
48 
49 void
51 {
52  assert(tunedHistoryLengths.size() == (nHistoryTables+1));
53  for (int i = 0; i <= nHistoryTables; i += 1) {
55  }
56 }
57 
58 void
59 MPP_TAGE::handleTAGEUpdate(Addr branch_pc, bool taken,
61 {
62  if (bi->hitBank > 0) {
63  if (abs (2 * gtable[bi->hitBank][bi->hitBankIndex].ctr + 1) == 1) {
64  if (bi->longestMatchPred != taken) {
65  // acts as a protection
66  if (bi->altBank > 0) {
67  ctrUpdate(gtable[bi->altBank][bi->altBankIndex].ctr, taken,
69  }
70  if (bi->altBank == 0){
71  baseUpdate(branch_pc, taken, bi);
72  }
73  }
74  }
75 
76  ctrUpdate(gtable[bi->hitBank][bi->hitBankIndex].ctr, taken,
78 
79  //sign changes: no way it can have been useful
80  if (abs (2 * gtable[bi->hitBank][bi->hitBankIndex].ctr + 1) == 1) {
81  gtable[bi->hitBank][bi->hitBankIndex].u = 0;
82  }
83  } else {
84  baseUpdate(branch_pc, taken, bi);
85  }
86 
87  if ((bi->longestMatchPred != bi->altTaken) &&
88  (bi->longestMatchPred == taken) &&
89  (gtable[bi->hitBank][bi->hitBankIndex].u < (1 << tagTableUBits) -1)) {
90  gtable[bi->hitBank][bi->hitBankIndex].u++;
91  }
92 }
93 
94 void
95 MPP_TAGE::handleAllocAndUReset(bool alloc, bool taken,
96  TAGEBase::BranchInfo* bi, int nrand)
97 {
98  if (!alloc) {
99  return;
100  }
101 
102  int a = 1;
103 
104  if ((random_mt.random<int>() & 127) < 32) {
105  a = 2;
106  }
107  int dep = bi->hitBank + a;
108 
109  int penalty = 0;
110  int numAllocated = 0;
111  int T = 1;
112 
113  for (int i = dep; i <= nHistoryTables; i += 1) {
114  if (noSkip[i]) {
115  if (gtable[i][bi->tableIndices[i]].u == 0) {
116  gtable[i][bi->tableIndices[i]].tag = bi->tableTags[i];
117  gtable[i][bi->tableIndices[i]].ctr = taken ? 0 : -1;
118  numAllocated++;
119  if (T <= 0) {
120  break;
121  }
122  i += 1;
123  T -= 1;
124  } else {
125  penalty++;
126  }
127  } else { assert(false); }
128  }
129 
130  tCounter += (penalty - numAllocated);
131 
132  handleUReset();
133 }
134 
135 void
137 {
138  //just the best formula for the Championship:
139  //In practice when one out of two entries are useful
140  if (tCounter < 0) {
141  tCounter = 0;
142  }
143 
144  if (tCounter >= ((1ULL << logUResetPeriod))) {
145  // Update the u bits for the short tags table
146  for (int i = 1; i <= nHistoryTables; i++) {
147  for (int j = 0; j < (1ULL << logTagTableSizes[i]); j++) {
148  resetUctr(gtable[i][j].u);
149  }
150  }
151 
152  tCounter = 0;
153  }
154 }
155 
156 void
158 {
159  // On real HW it should be u >>= 1 instead of if > 0 then u--
160  if (u > 0) {
161  u--;
162  }
163 }
164 
165 
166 int
167 MPP_TAGE::bindex(Addr pc_in) const
168 {
169  uint32_t pc = (uint32_t) pc_in;
170  return ((pc ^ (pc >> 4)) & ((1ULL << (logTagTableSizes[0])) - 1));
171 }
172 
173 unsigned
175 {
176  uint32_t hpc = ((uint32_t) branch_pc);
177  hpc = (hpc ^(hpc >> 4));
178  return 2 * ((hpc & ((numUseAltOnNa/2)-1)) ^ bi->longestMatchPred) +
179  ((bi->hitBank > (nHistoryTables / 3)) ? 1 : 0);
180 }
181 
182 void
183 MPP_TAGE::adjustAlloc(bool & alloc, bool taken, bool pred_taken)
184 {
185  // Do not allocate too often if the prediction is ok
186  if ((taken == pred_taken) && ((random_mt.random<int>() & 31) != 0)) {
187  alloc = false;
188  }
189 }
190 
191 void
193  ThreadID tid, Addr branch_pc, bool taken, TAGEBase::BranchInfo* b,
194  bool speculative, const StaticInstPtr &inst, Addr target)
195 {
196  if (speculative != speculativeHistUpdate) {
197  return;
198  }
199  // speculation is not implemented
200  assert(! speculative);
201 
202  ThreadHistory& tHist = threadHistory[tid];
203 
204  int brtype = inst->isDirectCtrl() ? 0 : 2;
205  if (! inst->isUncondCtrl()) {
206  ++brtype;
207  }
208  updatePathAndGlobalHistory(tHist, brtype, taken, branch_pc, target);
209 }
210 
211 void
213  ThreadHistory& tHist, int brtype, bool taken, Addr branch_pc, Addr target)
214 {
215  // TAGE update
216  int tmp = (branch_pc << 1) + taken;
217  int path = branch_pc;
218 
219  int maxt = (brtype & 1) ? 1 : 4;
220 
221  for (int t = 0; t < maxt; t++) {
222  bool dir = (tmp & 1);
223  tmp >>= 1;
224  int pathbit = (path & 127);
225  path >>= 1;
226  updateGHist(tHist.gHist, dir, tHist.globalHistory, tHist.ptGhist);
227  tHist.pathHist = (tHist.pathHist << 1) ^ pathbit;
228  for (int i = 1; i <= nHistoryTables; i++) {
229  tHist.computeIndices[i].update(tHist.gHist);
230  tHist.computeTags[0][i].update(tHist.gHist);
231  tHist.computeTags[1][i].update(tHist.gHist);
232  }
233  }
234 }
235 
236 bool
238 {
239  if (bi->hitBank > 0) {
240  return (abs(2 * gtable[bi->hitBank][bi->hitBankIndex].ctr + 1)) >=
241  ((1 << tagTableCounterBits) - 1);
242  } else {
243  int bim = (btablePrediction[bi->bimodalIndex] << 1)
244  + btableHysteresis[bi->bimodalIndex >> logRatioBiModalHystEntries];
245  return (bim == 0) || (bim == 3);
246  }
247 
248 }
249 
250 bool
252 {
253  return LoopPredictor::calcConf(index) ||
255 }
256 
257 bool
259 {
260  return ((random_mt.random<int>() & 7) == 0);
261 }
262 
264  const MPP_StatisticalCorrectorParams &p) : StatisticalCorrector(p),
265  thirdH(0), pnb(p.pnb), logPnb(p.logPnb), pm(p.pm), gnb(p.gnb),
266  logGnb(p.logGnb), gm(p.gm)
267 {
268  initGEHLTable(pnb, pm, pgehl, logPnb, wp, -1);
269  initGEHLTable(gnb, gm, ggehl, logGnb, wg, -1);
270 
271  for (int8_t &pos : wl) {
272  pos = -1;
273  }
274 }
275 
276 void
278 {
279  for (int j = 0; j < (1 << logBias); j++) {
280  if (j & 1) {
281  bias[j] = 15;
282  biasSK[j] = 15;
283  } else {
284  bias[j] = -16;
285  biasSK[j] = -16;
286  }
287  }
288 }
289 
290 unsigned
292  StatisticalCorrector::BranchInfo* bi, bool bias) const
293 {
294  unsigned int truncated_pc = branch_pc;
295  return ((truncated_pc << 1) + bi->predBeforeSC) & ((1 << logBias) - 1);
296 }
297 
298 unsigned
301 {
302  return (((branch_pc ^ (branch_pc >> (logBias - 1))) << 1)
303  + bi->predBeforeSC) & ((1 << logBias) - 1);
304 }
305 
306 unsigned
308  StatisticalCorrector::BranchInfo* bi, int hitBank, int altBank) const
309 {
310  return 0;
311 }
312 
313 int
315 {
316  return (i >= (nbr - 2)) ? 1 : 0;
317 }
318 
319 unsigned
321 {
322  return ((branch_pc ^ (branch_pc >> 4)) & ((1 << (logSizeUp)) - 1));
323 }
324 
325 void
326 MPP_StatisticalCorrector::gUpdate(Addr branch_pc, bool taken, int64_t hist,
327  std::vector<int> & length, std::vector<int8_t> * tab,
328  int nbr, int logs, std::vector<int8_t> & w,
330 {
331  for (int i = 0; i < nbr; i++) {
332  int64_t bhist = hist & ((int64_t) ((1 << length[i]) - 1));
333  int64_t index = gIndex(branch_pc, bhist, logs, nbr, i);
334  ctrUpdate(tab[i][index], taken, scCountersWidth - (i < (nbr - 1)));
335  }
336 }
337 
338 bool
340  bool cond_branch, StatisticalCorrector::BranchInfo* bi,
341  bool prev_pred_taken, bool bias_bit, bool use_conf_ctr,
342  int8_t conf_ctr, unsigned conf_bits, int hitBank, int altBank,
343  int64_t phist, int init_lsum)
344 {
345  bool pred_taken = prev_pred_taken;
346  if (cond_branch) {
347 
348  bi->predBeforeSC = prev_pred_taken;
349 
350  int lsum = init_lsum;
351 
352  getBiasLSUM(branch_pc, bi, lsum);
353 
354  int thres = gPredictions(tid, branch_pc, bi, lsum, phist);
355 
356  // These will be needed at update time
357  bi->lsum = lsum;
358  bi->thres = thres;
359  bi->scPred = (lsum >= 0);
360 
361  if (pred_taken != bi->scPred) {
362  pred_taken = bi->scPred;
363 
364  if (bi->highConf /* comes from tage prediction */) {
365  if ((abs(lsum) < thres / 3))
366  pred_taken = (firstH < 0) ? bi->scPred : prev_pred_taken;
367  else if ((abs(lsum) < 2 * thres / 3))
368  pred_taken = (secondH < 0) ? bi->scPred : prev_pred_taken;
369  else if ((abs(lsum) < thres))
370  pred_taken = (thirdH < 0) ? bi->scPred : prev_pred_taken;
371  }
372  }
373  }
374 
375  return pred_taken;
376 }
377 
379  const MultiperspectivePerceptronTAGEParams &p)
380  : MultiperspectivePerceptron(p), tage(p.tage),
381  loopPredictor(p.loop_predictor),
382  statisticalCorrector(p.statistical_corrector)
383 {
385  "Speculative updates support is not implemented");
386 }
387 
388 void
390 {
391  tage->init();
392  int numBitsTage = tage->getSizeInBits();
393  int numBitsLoopPred = loopPredictor->getSizeInBits();
394  int numBitsStatisticalCorrector = statisticalCorrector->getSizeInBits();
395 
396  setExtraBits(numBitsTage + numBitsLoopPred + numBitsStatisticalCorrector);
398 }
399 
400 
401 unsigned int
403  const HistorySpec &spec, int index) const
404 {
405  // get the hash for the feature
406  unsigned int g = spec.getHash(tid, bi.getPC(), bi.getPC() >> 2, index);
407  // shift it and xor it with the hashed PC
408  unsigned long long int h = g;
409  h <<= 20;
410  h ^= (bi.getPC() ^ (bi.getPC() >> 2));
411 
412  // maybe xor in an IMLI counter
413  if ((1ull << index) & imli_mask1) {
414  h += threadData[tid]->imli_counter[0];
415  }
416  if ((1ull << index) & imli_mask4) {
417  h += threadData[tid]->imli_counter[3];
418  }
419 
420  // return it modulo the table size
421  return h % table_sizes[index];
422 }
423 
424 
425 int
427  MPPTAGEBranchInfo &bi) const
428 {
429  int yout = 0;
430  for (int i = 0; i < specs.size(); i += 1) {
431  yout += specs[i]->coeff *
432  threadData[tid]->tables[i][getIndex(tid, bi, *specs[i], i)];
433  }
434  return yout;
435 }
436 
437 void
440  bool taken)
441 {
442  // update tables
443  for (int i = 0; i < specs.size(); i += 1) {
444  unsigned int idx = getIndex(tid, bi, *specs[i], i);
445  short int *c =
446  &threadData[tid]->tables[i][idx];
447  short int max_weight = (1 << (specs[i]->width - 1)) - 1;
448  short int min_weight = -(1 << (specs[i]->width - 1));
449  if (taken) {
450  if (*c < max_weight) {
451  *c += 1;
452  }
453  } else {
454  if (*c > min_weight) {
455  *c -= 1;
456  }
457  }
458  }
459 }
460 
461 void
464  bool taken)
465 {
466  unsigned int hpc = (bi.getPC() ^ (bi.getPC() >> 2));
467  unsigned int pc = bi.getPC();
468 
469  // update recency stack
470  unsigned short recency_pc = pc >> 2;
471  threadData[tid]->insertRecency(recency_pc, assoc);
472 
473  // update acyclic history
474  threadData[tid]->updateAcyclic(taken, hpc);
475 
476  // update modpath histories
477  for (int ii = 0; ii < modpath_indices.size(); ii +=1) {
478  int i = modpath_indices[ii];
479  if (hpc % (i + 2) == 0) {
480  memmove(&threadData[tid]->modpath_histories[i][1],
481  &threadData[tid]->modpath_histories[i][0],
482  sizeof(unsigned short int) * (modpath_lengths[ii] - 1));
483  threadData[tid]->modpath_histories[i][0] = hpc;
484  }
485  }
486 
487  // update modulo histories
488  for (int ii = 0; ii < modhist_indices.size(); ii += 1) {
489  int i = modhist_indices[ii];
490  if (hpc % (i + 2) == 0) {
491  for (int j = modhist_lengths[ii] - 1; j > 0; j -= 1) {
492  threadData[tid]->mod_histories[i][j] =
493  threadData[tid]->mod_histories[i][j-1];
494  }
495  threadData[tid]->mod_histories[i][0] = taken;
496  }
497  }
498 
499  // update blurry history
500  std::vector<std::vector<unsigned int>> &blurrypath_histories =
501  threadData[tid]->blurrypath_histories;
502  for (int i = 0; i < blurrypath_histories.size(); i += 1)
503  {
504  if (blurrypath_histories[i].size() > 0) {
505  unsigned int z = pc >> i;
506  if (blurrypath_histories[i][0] != z) {
507  memmove(&blurrypath_histories[i][1],
508  &blurrypath_histories[i][0],
509  sizeof(unsigned int) *
510  (blurrypath_histories[i].size() - 1));
511  blurrypath_histories[i][0] = z;
512  }
513  }
514  }
515 }
516 
517 bool
519  void * &bp_history)
520 {
522  new MPPTAGEBranchInfo(instPC, pcshift, true, *tage, *loopPredictor,
524  bp_history = (void *)bi;
525  bool pred_taken = tage->tagePredict(tid, instPC, true, bi->tageBranchInfo);
526 
527  pred_taken = loopPredictor->loopPredict(tid, instPC, true,
528  bi->lpBranchInfo, pred_taken, instShiftAmt);
529 
530  bi->scBranchInfo->highConf = tage->isHighConfidence(bi->tageBranchInfo);
531 
532  int init_lsum = 22;
533  if (!pred_taken) {
534  init_lsum = -init_lsum;
535  }
536  init_lsum += computePartialSum(tid, *bi);
537 
538  pred_taken = statisticalCorrector->scPredict(tid, instPC, true,
539  bi->scBranchInfo, pred_taken, false /* bias_bit: unused */,
540  false /* use_tage_ctr: unused */, 0 /* conf_ctr: unused */,
541  0 /* conf_bits: unused */, 0 /* hitBank: unused */,
542  0 /* altBank: unused */, tage->getPathHist(tid), init_lsum);
543  bi->predictedTaken = pred_taken;
544  bi->lpBranchInfo->predTaken = pred_taken;
545  return pred_taken;
546 }
547 
548 
549 void
551  bool taken, StatisticalCorrector::BranchInfo *bi, Addr corrTarget,
552  bool bias_bit, int hitBank, int altBank, int64_t phist)
553 {
554  bool scPred = (bi->lsum >= 0);
555 
556  if (bi->predBeforeSC != scPred) {
557  if (abs(bi->lsum) < bi->thres) {
558  if (bi->highConf) {
559  if (abs(bi->lsum) < bi->thres / 3) {
560  ctrUpdate(firstH, (bi->predBeforeSC == taken),
562  } else if (abs(bi->lsum) < 2 * bi->thres / 3) {
563  ctrUpdate(secondH, (bi->predBeforeSC == taken),
565  } else if (abs(bi->lsum) < bi->thres) {
566  ctrUpdate(thirdH, (bi->predBeforeSC == taken),
568  }
569  }
570  }
571  }
572 
573  if ((scPred != taken) || ((abs(bi->lsum) < bi->thres))) {
574 
575  ctrUpdate(pUpdateThreshold[getIndUpd(branch_pc)], (scPred != taken),
576  pUpdateThresholdWidth + 1); //+1 because the sign is ignored
577  if (pUpdateThreshold[getIndUpd(branch_pc)] < 0)
578  pUpdateThreshold[getIndUpd(branch_pc)] = 0;
579 
580  unsigned indBias = getIndBias(branch_pc, bi, false);
581  unsigned indBiasSK = getIndBiasSK(branch_pc, bi);
582 
583  ctrUpdate(bias[indBias], taken, scCountersWidth);
584  ctrUpdate(biasSK[indBiasSK], taken, scCountersWidth);
585 
586  gUpdates(tid, branch_pc, taken, bi, phist);
587  }
588 }
589 
590 void
592  void *bp_history, bool squashed,
593  const StaticInstPtr & inst,
594  Addr corrTarget)
595 {
596  assert(bp_history);
597  MPPTAGEBranchInfo *bi = static_cast<MPPTAGEBranchInfo*>(bp_history);
598 
599  if (squashed) {
601  // This restores the global history, then update it
602  // and recomputes the folded histories.
603  tage->squash(tid, taken, bi->tageBranchInfo, corrTarget);
604  if (bi->tageBranchInfo->condBranch) {
605  loopPredictor->squashLoop(bi->lpBranchInfo);
606  }
607  }
608  return;
609  }
610 
611  if (bi->isUnconditional()) {
612  statisticalCorrector->scHistoryUpdate(instPC, inst, taken,
613  bi->scBranchInfo, corrTarget);
614  tage->updateHistories(tid, instPC, taken, bi->tageBranchInfo, false,
615  inst, corrTarget);
616  } else {
617  tage->updateStats(taken, bi->tageBranchInfo);
618  loopPredictor->updateStats(taken, bi->lpBranchInfo);
619  statisticalCorrector->updateStats(taken, bi->scBranchInfo);
620 
621  loopPredictor->condBranchUpdate(tid, instPC, taken,
622  bi->tageBranchInfo->tagePred, bi->lpBranchInfo, instShiftAmt);
623 
624  bool scPred = (bi->scBranchInfo->lsum >= 0);
625  if ((scPred != taken) ||
626  ((abs(bi->scBranchInfo->lsum) < bi->scBranchInfo->thres))) {
627  updatePartial(tid, *bi, taken);
628  }
629  statisticalCorrector->condBranchUpdate(tid, instPC, taken,
630  bi->scBranchInfo, corrTarget, false /* bias_bit: unused */,
631  0 /* hitBank: unused */, 0 /* altBank: unused*/,
632  tage->getPathHist(tid));
633 
634  tage->condBranchUpdate(tid, instPC, taken, bi->tageBranchInfo,
635  random_mt.random<int>(), corrTarget,
636  bi->predictedTaken, true);
637 
638  updateHistories(tid, *bi, taken);
639 
641  if (inst->isCondCtrl() && inst->isDirectCtrl()
642  && !inst->isCall() && !inst->isReturn()) {
643  uint32_t truncated_target = corrTarget;
644  uint32_t truncated_pc = instPC;
645  if (truncated_target < truncated_pc) {
646  if (!taken) {
647  threadData[tid]->imli_counter[0] = 0;
648  } else {
649  threadData[tid]->imli_counter[0] += 1;
650  }
651  } else {
652  if (taken) {
653  threadData[tid]->imli_counter[3] = 0;
654  } else {
655  threadData[tid]->imli_counter[3] += 1;
656  }
657  }
658  }
659 
660  statisticalCorrector->scHistoryUpdate(instPC, inst, taken,
661  bi->scBranchInfo, corrTarget);
662 
663  tage->updateHistories(tid, instPC, taken, bi->tageBranchInfo,
664  false, inst, corrTarget);
665  }
666  }
667  delete bi;
668 }
669 
670 void
672  void * &bp_history)
673 {
677  bp_history = (void *) bi;
678 }
679 
680 void
682 {
683  assert(bp_history);
684  MPPTAGEBranchInfo *bi = static_cast<MPPTAGEBranchInfo*>(bp_history);
685  delete bi;
686 }
687 
688 } // namespace branch_prediction
689 } // namespace gem5
static std::stack< std::string > path
Definition: serialize.hh:315
bool isDirectCtrl() const
Definition: static_inst.hh:163
bool isUncondCtrl() const
Definition: static_inst.hh:166
bool isReturn() const
Definition: static_inst.hh:162
bool isCall() const
Definition: static_inst.hh:161
bool isCondCtrl() const
Definition: static_inst.hh:165
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
Definition: bpred_unit.hh:341
void updateStats(bool taken, BranchInfo *bi)
Update the stats.
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, bool tage_pred, BranchInfo *bi, unsigned instShiftAmt)
Update LTAGE for conditional branches.
virtual bool calcConf(int index) const
bool loopPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, unsigned instShiftAmt)
Get the loop prediction.
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
bool scPredict(ThreadID tid, Addr branch_pc, bool cond_branch, StatisticalCorrector::BranchInfo *bi, bool prev_pred_taken, bool bias_bit, bool use_conf_ctr, int8_t conf_ctr, unsigned conf_bits, int hitBank, int altBank, int64_t phist, int init_lsum) override
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, StatisticalCorrector::BranchInfo *bi, Addr corrTarget, bool b, int hitBank, int altBank, int64_t phist) override
unsigned getIndBiasBank(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int hitBank, int altBank) const override
virtual void getBiasLSUM(Addr branch_pc, StatisticalCorrector::BranchInfo *bi, int &lsum) const =0
MPP_StatisticalCorrector(const MPP_StatisticalCorrectorParams &p)
void handleAllocAndUReset(bool alloc, bool taken, TAGEBase::BranchInfo *bi, int nrand) override
Handles Allocation and U bits reset on an update.
void resetUctr(uint8_t &u) override
Algorithm for resetting a single U counter.
int bindex(Addr pc_in) const override
Computes the index used to access the bimodal table.
void calculateParameters() override
Calculates the history lengths and some other paramters in derived classes.
void updatePathAndGlobalHistory(ThreadHistory &tHist, int brtype, bool taken, Addr branch_pc, Addr target)
void updateHistories(ThreadID tid, Addr branch_pc, bool taken, TAGEBase::BranchInfo *b, bool speculative, const StaticInstPtr &inst, Addr target) override
(Speculatively) updates global histories (path and direction).
void handleTAGEUpdate(Addr branch_pc, bool taken, TAGEBase::BranchInfo *bi) override
Handles the update of the TAGE entries.
bool isHighConfidence(TAGEBase::BranchInfo *bi) const override
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 ...
unsigned getUseAltIdx(TAGEBase::BranchInfo *bi, Addr branch_pc) override
Calculation of the index for useAltPredForNewlyAllocated On this base TAGE implementation it is alway...
void handleUReset() override
Handles the U bits reset.
bool lookup(ThreadID tid, Addr instPC, void *&bp_history) override
Looks up a given PC in the BP to see if it is taken or not taken.
void update(ThreadID tid, Addr instPC, bool taken, void *bp_history, bool squashed, const StaticInstPtr &inst, Addr corrTarget) override
Updates the BP with taken/not taken information.
int computePartialSum(ThreadID tid, MPPTAGEBranchInfo &bi) const
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
MultiperspectivePerceptronTAGE(const MultiperspectivePerceptronTAGEParams &p)
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history) override
unsigned int getIndex(ThreadID tid, MPPTAGEBranchInfo &bi, const HistorySpec &spec, int index) const
void updatePartial(ThreadID tid, MPPTAGEBranchInfo &bi, bool taken)
void updateHistories(ThreadID tid, MPPTAGEBranchInfo &bi, bool taken)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void setExtraBits(int bits)
Sets the starting number of storage bits to compute the number of table entries.
std::vector< HistorySpec * > specs
Predictor tables.
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)
virtual void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo *bi, int64_t phist)=0
virtual bool scPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, bool bias_bit, bool use_conf_ctr, int8_t conf_ctr, unsigned conf_bits, int hitBank, int altBank, int64_t phist, int init_lsum=0)
void ctrUpdate(T &ctr, bool taken, int nbits)
virtual int gPredictions(ThreadID tid, Addr branch_pc, BranchInfo *bi, int &lsum, int64_t phist)=0
virtual void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *bi, Addr corrTarget, bool bias_bit, int hitBank, int altBank, int64_t phist)
int64_t gIndex(Addr branch_pc, int64_t bhist, int logs, int nbr, int i)
virtual void updateHistories(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *b, bool speculative, const StaticInstPtr &inst=nullStaticInstPtr, Addr target=MaxAddr)
(Speculatively) updates global histories (path and direction).
Definition: tage_base.cc:588
static void ctrUpdate(T &ctr, bool taken, int nbits)
Updates a direction counter based on the actual branch outcome.
Definition: tage_base.cc:261
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: tage_base.cc:87
virtual void updateStats(bool taken, BranchInfo *bi)
Update the stats.
Definition: tage_base.cc:662
const unsigned logRatioBiModalHystEntries
Definition: tage_base.hh:424
std::vector< bool > btableHysteresis
Definition: tage_base.hh:437
void updateGHist(uint8_t *&h, bool dir, uint8_t *tab, int &PT)
(Speculatively) updates the global branch history.
Definition: tage_base.cc:322
std::vector< bool > btablePrediction
Definition: tage_base.hh:436
std::vector< ThreadHistory > threadHistory
Definition: tage_base.hh:464
std::vector< int > logTagTableSizes
Definition: tage_base.hh:434
void baseUpdate(Addr pc, bool taken, BranchInfo *bi)
Updates the bimodal predictor.
Definition: tage_base.cc:302
virtual void squash(ThreadID tid, bool taken, BranchInfo *bi, Addr target)
Restores speculatively updated path and direction histories.
Definition: tage_base.cc:629
virtual bool isHighConfidence(BranchInfo *bi) const
Definition: tage_base.hh:410
bool tagePredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi)
TAGE prediction called from TAGE::predict.
Definition: tage_base.cc:360
std::vector< bool > noSkip
Definition: tage_base.hh:486
int getPathHist(ThreadID tid) const
Definition: tage_base.cc:780
virtual void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *bi, int nrand, Addr corrTarget, bool pred, bool preAdjustAlloc=false)
Update TAGE for conditional branches.
Definition: tage_base.cc:514
Random random_mt
Definition: random.cc:99
std::enable_if_t< std::is_integral_v< T >, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Definition: random.hh:90
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:226
Bitfield< 7 > b
Definition: misc_types.hh:388
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 8 > a
Definition: misc_types.hh:66
Bitfield< 22 > u
Definition: misc_types.hh:359
Bitfield< 24 > j
Definition: misc_types.hh:57
Bitfield< 4 > pc
Bitfield< 30, 0 > index
Bitfield< 4 > g
Definition: dt_constants.hh:86
Bitfield< 20, 16 > bi
Definition: types.hh:80
Bitfield< 3 > z
Definition: pagetable.hh:62
Bitfield< 2 > c
Definition: pagetable.hh:63
Bitfield< 6 > w
Definition: pagetable.hh:59
Bitfield< 51 > t
Definition: pagetable.hh:56
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
virtual unsigned int getHash(ThreadID tid, Addr pc, Addr pc2, int t) const =0
Gets the hash to index the table, using the pc of the branch, and the index of the table.

Generated on Wed Dec 21 2022 10:22:31 for gem5 by doxygen 1.9.1