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

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