53namespace branch_prediction
58 globalHistoryReg(params.numThreads, 0),
59 globalHistoryBits(
ceilLog2(params.globalPredictorSize)),
60 choicePredictorSize(params.choicePredictorSize),
61 choiceCtrBits(params.choiceCtrBits),
62 globalPredictorSize(params.globalPredictorSize),
63 globalCtrBits(params.globalCtrBits),
64 choiceCounters(choicePredictorSize,
SatCounter8(choiceCtrBits)),
65 takenCounters(globalPredictorSize,
SatCounter8(globalCtrBits)),
66 notTakenCounters(globalPredictorSize,
SatCounter8(globalCtrBits))
69 fatal(
"Invalid choice predictor size.\n");
71 fatal(
"Invalid global history predictor size.\n");
96 bp_history =
static_cast<void*
>(history);
101 bool taken,
Addr target,
void * &bp_history)
103 assert(uncond || bp_history);
118 bp_history =
nullptr;
133 unsigned choiceHistoryIdx = ((branchAddr >>
instShiftAmt)
135 unsigned globalHistoryIdx = (((branchAddr >>
instShiftAmt)
148 bool finalPrediction;
156 if (choicePrediction) {
157 finalPrediction = takenGHBPrediction;
159 finalPrediction = notTakenGHBPrediction;
163 bp_history =
static_cast<void*
>(history);
165 return finalPrediction;
190 unsigned choiceHistoryIdx = ((branchAddr >>
instShiftAmt)
192 unsigned globalHistoryIdx = (((branchAddr >>
instShiftAmt)
243 bp_history =
nullptr;
Basically a wrapper class to hold both the branch predictor and the BTB.
const unsigned instShiftAmt
Number of bits to shift instructions by for predictor addresses.
void updateHistories(ThreadID tid, Addr pc, bool uncond, bool taken, Addr target, void *&bp_history) override
Ones done with the prediction this function updates the path and global history.
unsigned globalHistoryBits
std::vector< unsigned > globalHistoryReg
std::vector< SatCounter8 > notTakenCounters
void updateGlobalHistReg(ThreadID tid, bool taken)
void uncondBranch(ThreadID tid, Addr pc, void *&bp_history)
unsigned globalHistoryMask
void squash(ThreadID tid, void *&bp_history) override
std::vector< SatCounter8 > takenCounters
unsigned historyRegisterMask
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.
std::vector< SatCounter8 > choiceCounters
unsigned choiceHistoryMask
unsigned globalPredictorSize
unsigned notTakenThreshold
bool lookup(ThreadID tid, Addr pc, void *&bp_history) override
Looks up a given conditional branch PC of in the BP to see if it is taken or not taken.
unsigned choicePredictorSize
BiModeBP(const BiModeBPParams ¶ms)
static constexpr int ceilLog2(const T &n)
static constexpr bool isPowerOf2(const T &n)
#define fatal(...)
This implements a cprintf based fatal() function.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
int16_t ThreadID
Thread index/ID type.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
unsigned globalHistoryReg