gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
multiperspective_perceptron_tage.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 The University of Edinburgh
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright 2019 Texas A&M University
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are met:
18 *
19 * 1. Redistributions of source code must retain the above copyright notice,
20 * this list of conditions and the following disclaimer.
21 *
22 * 2. Redistributions in binary form must reproduce the above copyright notice,
23 * this list of conditions and the following disclaimer in the documentation
24 * and/or other materials provided with the distribution.
25 *
26 * 3. Neither the name of the copyright holder nor the names of its
27 * contributors may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * Author: Daniel A. Jiménez
43 * Adapted to gem5 by: Javier Bueno Hedo
44 *
45 */
46
47/*
48 * Multiperspective Perceptron Predictor with TAGE (by Daniel A. Jiménez)
49 */
50
52
53#include "base/random.hh"
54
55namespace gem5
56{
57
58namespace branch_prediction
59{
60
61void
63{
64 assert(tunedHistoryLengths.size() == (nHistoryTables+1));
65 for (int i = 0; i <= nHistoryTables; i += 1) {
67 }
68}
69
70void
71MPP_TAGE::handleTAGEUpdate(Addr branch_pc, bool taken,
73{
74 if (bi->hitBank > 0) {
75 if (abs (2 * gtable[bi->hitBank][bi->hitBankIndex].ctr + 1) == 1) {
76 if (bi->longestMatchPred != taken) {
77 // acts as a protection
78 if (bi->altBank > 0) {
79 ctrUpdate(gtable[bi->altBank][bi->altBankIndex].ctr, taken,
81 }
82 if (bi->altBank == 0){
83 baseUpdate(branch_pc, taken, bi);
84 }
85 }
86 }
87
88 ctrUpdate(gtable[bi->hitBank][bi->hitBankIndex].ctr, taken,
90
91 //sign changes: no way it can have been useful
92 if (abs (2 * gtable[bi->hitBank][bi->hitBankIndex].ctr + 1) == 1) {
93 gtable[bi->hitBank][bi->hitBankIndex].u = 0;
94 }
95 } else {
96 baseUpdate(branch_pc, taken, bi);
97 }
98
99 if ((bi->longestMatchPred != bi->altTaken) &&
100 (bi->longestMatchPred == taken) &&
101 (gtable[bi->hitBank][bi->hitBankIndex].u < (1 << tagTableUBits) -1)) {
102 gtable[bi->hitBank][bi->hitBankIndex].u++;
103 }
104}
105
106void
107MPP_TAGE::handleAllocAndUReset(bool alloc, bool taken,
108 TAGEBase::BranchInfo* bi, int nrand)
109{
110 if (!alloc) {
111 return;
112 }
113
114 int a = 1;
115
116 if ((rng->random<int>() & 127) < 32) {
117 a = 2;
118 }
119 int dep = bi->hitBank + a;
120
121 int penalty = 0;
122 int numAllocated = 0;
123 int T = 1;
124
125 for (int i = dep; i <= nHistoryTables; i += 1) {
126 if (noSkip[i]) {
127 if (gtable[i][bi->tableIndices[i]].u == 0) {
128 gtable[i][bi->tableIndices[i]].tag = bi->tableTags[i];
129 gtable[i][bi->tableIndices[i]].ctr = taken ? 0 : -1;
130 numAllocated++;
131 if (T <= 0) {
132 break;
133 }
134 i += 1;
135 T -= 1;
136 } else {
137 penalty++;
138 }
139 } else { assert(false); }
140 }
141
142 tCounter += (penalty - numAllocated);
143
144 handleUReset();
145}
146
147void
149{
150 //just the best formula for the Championship:
151 //In practice when one out of two entries are useful
152 if (tCounter < 0) {
153 tCounter = 0;
154 }
155
156 if (tCounter >= ((1ULL << logUResetPeriod))) {
157 // Update the u bits for the short tags table
158 for (int i = 1; i <= nHistoryTables; i++) {
159 for (int j = 0; j < (1ULL << logTagTableSizes[i]); j++) {
160 resetUctr(gtable[i][j].u);
161 }
162 }
163
164 tCounter = 0;
165 }
166}
167
168void
170{
171 // On real HW it should be u >>= 1 instead of if > 0 then u--
172 if (u > 0) {
173 u--;
174 }
175}
176
177
178int
180{
181 uint32_t pc = (uint32_t) pc_in;
182 return ((pc ^ (pc >> 4)) & ((1ULL << (logTagTableSizes[0])) - 1));
183}
184
185unsigned
187{
188 uint32_t hpc = ((uint32_t) branch_pc);
189 hpc = (hpc ^(hpc >> 4));
190 return 2 * ((hpc & ((numUseAltOnNa/2)-1)) ^ bi->longestMatchPred) +
191 ((bi->hitBank > (nHistoryTables / 3)) ? 1 : 0);
192}
193
194void
195MPP_TAGE::adjustAlloc(bool & alloc, bool taken, bool pred_taken)
196{
197 // Do not allocate too often if the prediction is ok
198 if ((taken == pred_taken) && ((rng->random<int>() & 31) != 0)) {
199 alloc = false;
200 }
201}
202
203void
204MPP_TAGE::updateHistories(ThreadID tid, Addr branch_pc, bool speculative,
205 bool taken, Addr target, const StaticInstPtr &inst,
207{
208 if (speculative != speculativeHistUpdate) {
209 return;
210 }
211 // speculation is not implemented
212 assert(! speculative);
213
214 int brtype = inst->isDirectCtrl() ? 0 : 2;
215 if (! inst->isUncondCtrl()) {
216 ++brtype;
217 }
218
219 // TAGE update
220 int tmp = (branch_pc << 1) + taken;
221 int path = branch_pc;
222
223 int maxt = (brtype & 1) ? 1 : 4;
224
225 // Update path history
226 for (int t = 0; t < maxt; t++) {
227 int pathbit = (path & 127);
228 path >>= 1;
229 threadHistory[tid].pathHist
230 = (threadHistory[tid].pathHist << 1) ^ pathbit;
231 }
232
233 // Update global history
234 updateGHist(tid, tmp, maxt);
235}
236
237bool
239{
240 if (bi->hitBank > 0) {
241 return (abs(2 * gtable[bi->hitBank][bi->hitBankIndex].ctr + 1)) >=
242 ((1 << tagTableCounterBits) - 1);
243 } else {
244 int bim = (btablePrediction[bi->bimodalIndex] << 1)
246 return (bim == 0) || (bim == 3);
247 }
248
249}
250
251bool
253{
255 (ltable[index].confidence * ltable[index].numIter > 128);
256}
257
258bool
260{
261 return ((rng->random<int>() & 7) == 0);
262}
263
265 const MPP_StatisticalCorrectorParams &p) : StatisticalCorrector(p),
266 thirdH(0), pnb(p.pnb), logPnb(p.logPnb), pm(p.pm), gnb(p.gnb),
267 logGnb(p.logGnb), gm(p.gm)
268{
271
272 for (int8_t &pos : wl) {
273 pos = -1;
274 }
275}
276
277void
279{
280 for (int j = 0; j < (1 << logBias); j++) {
281 if (j & 1) {
282 bias[j] = 15;
283 biasSK[j] = 15;
284 } else {
285 bias[j] = -16;
286 biasSK[j] = -16;
287 }
288 }
289}
290
291unsigned
294{
295 unsigned int truncated_pc = branch_pc;
296 return ((truncated_pc << 1) + bi->predBeforeSC) & ((1 << logBias) - 1);
297}
298
299unsigned
302{
303 return (((branch_pc ^ (branch_pc >> (logBias - 1))) << 1)
304 + bi->predBeforeSC) & ((1 << logBias) - 1);
305}
306
307unsigned
309 StatisticalCorrector::BranchInfo* bi, int hitBank, int altBank) const
310{
311 return 0;
312}
313
314int
316{
317 return (i >= (nbr - 2)) ? 1 : 0;
318}
319
320unsigned
322{
323 return ((branch_pc ^ (branch_pc >> 4)) & ((1 << (logSizeUp)) - 1));
324}
325
326void
327MPP_StatisticalCorrector::gUpdate(Addr branch_pc, bool taken, int64_t hist,
329 int nbr, int logs, std::vector<int8_t> & w,
331{
332 for (int i = 0; i < nbr; i++) {
333 int64_t bhist = hist & ((int64_t) ((1 << length[i]) - 1));
334 int64_t index = gIndex(branch_pc, bhist, logs, nbr, i);
335 ctrUpdate(tab[i][index], taken, scCountersWidth - (i < (nbr - 1)));
336 }
337}
338
339bool
341 bool cond_branch, StatisticalCorrector::BranchInfo* bi,
342 bool prev_pred_taken, bool bias_bit, bool use_conf_ctr,
343 int8_t conf_ctr, unsigned conf_bits, int hitBank, int altBank,
344 int init_lsum)
345{
346 bool pred_taken = prev_pred_taken;
347 if (cond_branch) {
348
349 bi->predBeforeSC = prev_pred_taken;
350
351 int lsum = init_lsum;
352
353 getBiasLSUM(branch_pc, bi, lsum);
354
355 int thres = gPredictions(tid, branch_pc, bi, lsum);
356
357 // These will be needed at update time
358 bi->lsum = lsum;
359 bi->thres = thres;
360 bi->scPred = (lsum >= 0);
361
362 if (pred_taken != bi->scPred) {
363 pred_taken = bi->scPred;
364
365 if (bi->highConf /* comes from tage prediction */) {
366 if ((abs(lsum) < thres / 3))
367 pred_taken = (firstH < 0) ? bi->scPred : prev_pred_taken;
368 else if ((abs(lsum) < 2 * thres / 3))
369 pred_taken = (secondH < 0) ? bi->scPred : prev_pred_taken;
370 else if ((abs(lsum) < thres))
371 pred_taken = (thirdH < 0) ? bi->scPred : prev_pred_taken;
372 }
373 }
374 }
375
376 return pred_taken;
377}
378
380 const MultiperspectivePerceptronTAGEParams &p)
382 loopPredictor(p.loop_predictor),
383 statisticalCorrector(p.statistical_corrector)
384{
385 fatal_if(tage->isSpeculativeUpdateEnabled(),
386 "Speculative updates support is not implemented");
387}
388
389void
391{
392 tage->init();
393 int numBitsTage = tage->getSizeInBits();
394 int numBitsLoopPred = loopPredictor->getSizeInBits();
395 int numBitsStatisticalCorrector = statisticalCorrector->getSizeInBits();
396
397 setExtraBits(numBitsTage + numBitsLoopPred + numBitsStatisticalCorrector);
399}
400
401
402unsigned int
404 const HistorySpec &spec, int index) const
405{
406 // get the hash for the feature
407 unsigned int g = spec.getHash(tid, bi.getPC(), bi.getPC() >> 2, index);
408 // shift it and xor it with the hashed PC
409 unsigned long long int h = g;
410 h <<= 20;
411 h ^= (bi.getPC() ^ (bi.getPC() >> 2));
412
413 // maybe xor in an IMLI counter
414 if ((1ull << index) & imli_mask1) {
415 h += threadData[tid]->imli_counter[0];
416 }
417 if ((1ull << index) & imli_mask4) {
418 h += threadData[tid]->imli_counter[3];
419 }
420
421 // return it modulo the table size
422 return h % table_sizes[index];
423}
424
425
426int
428 MPPTAGEBranchInfo &bi) const
429{
430 int yout = 0;
431 for (int i = 0; i < specs.size(); i += 1) {
432 yout += specs[i]->coeff *
433 threadData[tid]->tables[i][getIndex(tid, bi, *specs[i], i)];
434 }
435 return yout;
436}
437
438void
441 bool taken)
442{
443 // update tables
444 for (int i = 0; i < specs.size(); i += 1) {
445 unsigned int idx = getIndex(tid, bi, *specs[i], i);
446 short int *c =
447 &threadData[tid]->tables[i][idx];
448 short int max_weight = (1 << (specs[i]->width - 1)) - 1;
449 short int min_weight = -(1 << (specs[i]->width - 1));
450 if (taken) {
451 if (*c < max_weight) {
452 *c += 1;
453 }
454 } else {
455 if (*c > min_weight) {
456 *c -= 1;
457 }
458 }
459 }
460}
461
462void
465 bool taken)
466{
467 unsigned int hpc = (bi.getPC() ^ (bi.getPC() >> 2));
468 unsigned int pc = bi.getPC();
469
470 // update recency stack
471 unsigned short recency_pc = pc >> 2;
472 threadData[tid]->insertRecency(recency_pc, assoc);
473
474 // update acyclic history
475 threadData[tid]->updateAcyclic(taken, hpc);
476
477 // update modpath histories
478 for (int ii = 0; ii < modpath_indices.size(); ii +=1) {
479 int i = modpath_indices[ii];
480 if (hpc % (i + 2) == 0) {
481 memmove(&threadData[tid]->modpath_histories[i][1],
482 &threadData[tid]->modpath_histories[i][0],
483 sizeof(unsigned short int) * (modpath_lengths[ii] - 1));
484 threadData[tid]->modpath_histories[i][0] = hpc;
485 }
486 }
487
488 // update modulo histories
489 for (int ii = 0; ii < modhist_indices.size(); ii += 1) {
490 int i = modhist_indices[ii];
491 if (hpc % (i + 2) == 0) {
492 for (int j = modhist_lengths[ii] - 1; j > 0; j -= 1) {
493 threadData[tid]->mod_histories[i][j] =
494 threadData[tid]->mod_histories[i][j-1];
495 }
496 threadData[tid]->mod_histories[i][0] = taken;
497 }
498 }
499
500 // update blurry history
501 std::vector<std::vector<unsigned int>> &blurrypath_histories =
502 threadData[tid]->blurrypath_histories;
503 for (int i = 0; i < blurrypath_histories.size(); i += 1)
504 {
505 if (blurrypath_histories[i].size() > 0) {
506 unsigned int z = pc >> i;
507 if (blurrypath_histories[i][0] != z) {
508 memmove(&blurrypath_histories[i][1],
509 &blurrypath_histories[i][0],
510 sizeof(unsigned int) *
511 (blurrypath_histories[i].size() - 1));
512 blurrypath_histories[i][0] = z;
513 }
514 }
515 }
516}
517
518bool
520 void * &bp_history)
521{
523 new MPPTAGEBranchInfo(instPC, pcshift, true, *tage, *loopPredictor,
525 bp_history = (void *)bi;
526 bool pred_taken = tage->tagePredict(tid, instPC, true, bi->tageBranchInfo);
527
528 pred_taken = loopPredictor->loopPredict(tid, instPC, true,
529 bi->lpBranchInfo, pred_taken, instShiftAmt);
530
531 bi->scBranchInfo->highConf = tage->isHighConfidence(bi->tageBranchInfo);
532
533 int init_lsum = 22;
534 if (!pred_taken) {
535 init_lsum = -init_lsum;
536 }
537 init_lsum += computePartialSum(tid, *bi);
538
539 pred_taken = statisticalCorrector->scPredict(tid, instPC, true,
540 bi->scBranchInfo, pred_taken, false /* bias_bit: unused */,
541 false /* use_tage_ctr: unused */, 0 /* conf_ctr: unused */,
542 0 /* conf_bits: unused */, 0 /* hitBank: unused */,
543 0 /* altBank: unused */, init_lsum);
544 bi->predictedTaken = pred_taken;
545 bi->lpBranchInfo->predTaken = pred_taken;
546 return pred_taken;
547}
548
549
550void
552 bool taken, StatisticalCorrector::BranchInfo *bi, Addr target,
553 bool bias_bit, int hitBank, int altBank)
554{
555 bool scPred = (bi->lsum >= 0);
556
557 if (bi->predBeforeSC != scPred) {
558 if (abs(bi->lsum) < bi->thres) {
559 if (bi->highConf) {
560 if (abs(bi->lsum) < bi->thres / 3) {
561 ctrUpdate(firstH, (bi->predBeforeSC == taken),
563 } else if (abs(bi->lsum) < 2 * bi->thres / 3) {
564 ctrUpdate(secondH, (bi->predBeforeSC == taken),
566 } else if (abs(bi->lsum) < bi->thres) {
567 ctrUpdate(thirdH, (bi->predBeforeSC == taken),
569 }
570 }
571 }
572 }
573
574 if ((scPred != taken) || ((abs(bi->lsum) < bi->thres))) {
575
576 ctrUpdate(pUpdateThreshold[getIndUpd(branch_pc)], (scPred != taken),
577 pUpdateThresholdWidth + 1); //+1 because the sign is ignored
578 if (pUpdateThreshold[getIndUpd(branch_pc)] < 0)
579 pUpdateThreshold[getIndUpd(branch_pc)] = 0;
580
581 unsigned indBias = getIndBias(branch_pc, bi, false);
582 unsigned indBiasSK = getIndBiasSK(branch_pc, bi);
583
584 ctrUpdate(bias[indBias], taken, scCountersWidth);
585 ctrUpdate(biasSK[indBiasSK], taken, scCountersWidth);
586
587 gUpdates(tid, branch_pc, taken, bi);
588 }
589}
590
591void
593 void * &bp_history, bool squashed,
594 const StaticInstPtr & inst,
595 Addr target)
596{
597 assert(bp_history);
598 MPPTAGEBranchInfo *bi = static_cast<MPPTAGEBranchInfo*>(bp_history);
599
600 if (squashed) {
601 if (tage->isSpeculativeUpdateEnabled()) {
602 // This restores the global history, then update it
603 // and recomputes the folded histories.
604 tage->squash(tid, taken, target, inst, bi->tageBranchInfo);
605 if (bi->tageBranchInfo->condBranch) {
606 loopPredictor->squashLoop(bi->lpBranchInfo);
607 }
608 }
609 return;
610 }
611
612 if (bi->isUnconditional()) {
613 tage->updateHistories(tid, pc, false, taken, target,
614 inst, bi->tageBranchInfo);
615 statisticalCorrector->updateHistories(pc, false, inst, taken,
616 bi->scBranchInfo, target,
617 tage->getPathHist(tid, false));
618 } else {
619 tage->updateStats(taken, bi->tageBranchInfo);
620 loopPredictor->updateStats(taken, bi->lpBranchInfo);
621 statisticalCorrector->updateStats(taken, bi->scBranchInfo);
622
623 loopPredictor->condBranchUpdate(tid, pc, taken,
624 bi->tageBranchInfo->tagePred, bi->lpBranchInfo, instShiftAmt);
625
626 bool scPred = (bi->scBranchInfo->lsum >= 0);
627 if ((scPred != taken) ||
628 ((abs(bi->scBranchInfo->lsum) < bi->scBranchInfo->thres))) {
629 updatePartial(tid, *bi, taken);
630 }
631 statisticalCorrector->condBranchUpdate(tid, pc, taken,
632 bi->scBranchInfo, target,
633 false /* bias_bit: unused */,
634 0 /* hitBank: unused */,
635 0 /* altBank: unused*/);
636
637 tage->condBranchUpdate(tid, pc, taken, bi->tageBranchInfo,
638 rng->random<int>(), target,
639 bi->predictedTaken, true);
640
641 updateHistories(tid, *bi, taken);
642
643 if (!tage->isSpeculativeUpdateEnabled()) {
644 if (inst->isCondCtrl() && inst->isDirectCtrl()
645 && !inst->isCall() && !inst->isReturn()) {
646 uint32_t truncated_target = target;
647 uint32_t truncated_pc = pc;
648 if (truncated_target < truncated_pc) {
649 if (!taken) {
650 threadData[tid]->imli_counter[0] = 0;
651 } else {
652 threadData[tid]->imli_counter[0] += 1;
653 }
654 } else {
655 if (taken) {
656 threadData[tid]->imli_counter[3] = 0;
657 } else {
658 threadData[tid]->imli_counter[3] += 1;
659 }
660 }
661 }
662
663 tage->updateHistories(tid, pc, false, taken, target,
664 inst, bi->tageBranchInfo);
665 statisticalCorrector->updateHistories(pc, false, inst, taken,
666 bi->scBranchInfo, target,
667 tage->getPathHist(tid,
668 false));
669 }
670 }
671 delete bi;
672 bp_history = nullptr;
673}
674
675void
677 bool uncond, bool taken, Addr target,
678 const StaticInstPtr &inst,
679 void * &bp_history)
680{
681 assert(uncond || bp_history);
682
683 // For perceptron there is no speculative history correction.
684 // Conditional branches are done.
685 if (!uncond) return;
686
690 bp_history = (void *) bi;
691}
692
693void
695{
696 assert(bp_history);
697 MPPTAGEBranchInfo *bi = static_cast<MPPTAGEBranchInfo*>(bp_history);
698 delete bi;
699 bp_history = nullptr;
700}
701
702} // namespace branch_prediction
703} // namespace gem5
static std::stack< std::string > path
Definition serialize.hh:315
bool isDirectCtrl() const
bool isUncondCtrl() const
bool isReturn() const
bool isCall() const
bool isCondCtrl() const
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
virtual bool calcConf(int index) const
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, int init_lsum) override
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, StatisticalCorrector::BranchInfo *bi, Addr target, bool b, int hitBank, int altBank) 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 updateHistories(ThreadID tid, Addr branch_pc, bool speculative, bool taken, Addr target, const StaticInstPtr &inst, TAGEBase::BranchInfo *bi) 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 conditional branch PC of in the BP to see if it is taken or not taken.
void update(ThreadID tid, Addr pc, bool taken, void *&bp_history, bool squashed, const StaticInstPtr &inst, Addr target) override
Updates the BP with taken/not taken information.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
MultiperspectivePerceptronTAGE(const MultiperspectivePerceptronTAGEParams &p)
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)
MultiperspectivePerceptron(const MultiperspectivePerceptronParams &params)
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 int gPredictions(ThreadID tid, Addr branch_pc, BranchInfo *bi, int &lsum)=0
StatisticalCorrector(const StatisticalCorrectorParams &p)
void ctrUpdate(T &ctr, bool taken, int nbits)
int64_t gIndex(Addr branch_pc, int64_t bhist, int logs, int nbr, int i)
virtual void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo *bi)=0
static void ctrUpdate(T &ctr, bool taken, int nbits)
Updates a direction counter based on the actual branch outcome.
Definition tage_base.cc:244
const unsigned logRatioBiModalHystEntries
Definition tage_base.hh:484
std::vector< bool > btableHysteresis
Definition tage_base.hh:497
std::vector< bool > btablePrediction
Definition tage_base.hh:496
std::vector< ThreadHistory > threadHistory
Definition tage_base.hh:526
std::vector< int > logTagTableSizes
Definition tage_base.hh:494
void baseUpdate(Addr pc, bool taken, BranchInfo *bi)
Updates the bimodal predictor.
Definition tage_base.cc:285
void updateGHist(ThreadID tid, uint64_t bv, uint8_t n)
Internal history update function.
Definition tage_base.cc:305
STL vector class.
Definition stl.hh:37
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:268
Bitfield< 5 > t
Definition misc_types.hh:71
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 11 > z
Bitfield< 29 > c
Definition misc_types.hh:53
Bitfield< 8 > a
Definition misc_types.hh:66
Bitfield< 22 > u
Bitfield< 4 > pc
Bitfield< 30, 0 > index
Bitfield< 4 > g
Bitfield< 0 > p
Bitfield< 0 > w
Bitfield< 20, 16 > bi
Definition types.hh:80
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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
RefCountingPtr< StaticInst > StaticInstPtr
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 Mon May 26 2025 09:19:08 for gem5 by doxygen 1.13.2