Go to the documentation of this file.
38 #include "debug/LTage.hh"
39 #include "params/LoopPredictor.hh"
44 namespace branch_prediction
49 loopTableAgeBits(
p.loopTableAgeBits),
50 loopTableConfidenceBits(
p.loopTableConfidenceBits),
51 loopTableTagBits(
p.loopTableTagBits),
52 loopTableIterBits(
p.loopTableIterBits),
53 logLoopTableAssoc(
p.logLoopTableAssoc),
54 confidenceThreshold((1 << loopTableConfidenceBits) - 1),
55 loopTagMask((1 << loopTableTagBits) - 1),
56 loopNumIterMask((1 << loopTableIterBits) - 1),
57 loopSetMask((1 << (logSizeLoopPred - logLoopTableAssoc)) - 1),
59 withLoopBits(
p.withLoopBits),
60 useDirectionBit(
p.useDirectionBit),
61 useSpeculation(
p.useSpeculation),
62 useHashing(
p.useHashing),
63 restrictAllocation(
p.restrictAllocation),
64 initialLoopIter(
p.initialLoopIter),
65 initialLoopAge(
p.initialLoopAge),
66 optionalAgeReset(
p.optionalAgeReset),
101 Addr pc = pc_in >> instShiftAmt;
119 unsigned instShiftAmt)
const
122 bi->loopPredValid =
false;
138 if (
ltable[idx].tag ==
bi->loopTag) {
145 if ((iter + 1) ==
ltable[idx].numIter) {
164 if (
bi->loopHit>=0) {
185 if (
bi->loopHit >= 0) {
187 if (
bi->loopPredValid) {
188 if (taken !=
bi->loopPred) {
196 DPRINTF(LTage,
"Loop Prediction success:%lx\n",
pc);
205 if (
ltable[idx].numIter != 0) {
216 DPRINTF(LTage,
"Loop End predicted successfully:%lx\n",
pc);
220 if (
ltable[idx].numIter < 3) {
228 DPRINTF(LTage,
"Loop End predicted incorrectly:%lx\n",
pc);
229 if (
ltable[idx].numIter == 0) {
253 if (
ltable[idx].age == 0) {
255 "Allocating loop pred entry for branch %lx\n",
278 BranchInfo*
bi,
bool prev_pred_taken,
unsigned instShiftAmt)
280 bool pred_taken = prev_pred_taken;
286 pred_taken =
bi->loopPred;
287 bi->loopPredUsed =
true;
301 if (
bi->loopHit >= 0) {
312 if (
bi->loopHit >= 0) {
323 if (taken ==
bi->loopPred) {
333 unsigned instShiftAmt)
340 bi->loopPred =
getLoop(branch_pc,
bi,
false, instShiftAmt);
343 if (
bi->loopPredValid) {
344 if (
bi->predTaken !=
bi->loopPred) {
346 (
bi->loopPred == taken),
356 : statistics::
Group(parent),
358 "Number of times the loop predictor is the provider and the "
359 "prediction is correct"),
361 "Number of times the loop predictor is the provider and the "
362 "prediction is wrong")
int lindex(Addr pc_in, unsigned instShiftAmt) const
Computes the index used to access the loop predictor.
void squashLoop(BranchInfo *bi)
const unsigned logLoopTableAssoc
void init() override
Initialize the loop predictor.
const unsigned initialLoopIter
void squash(ThreadID tid, BranchInfo *bi)
bool loopPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, unsigned instShiftAmt)
Get the loop prediction.
size_t getSizeInBits() const
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...
void specLoopUpdate(bool taken, BranchInfo *bi)
Speculatively updates the loop predictor iteration count (only for useSpeculation).
const unsigned logSizeLoopPred
const bool optionalAgeReset
const uint16_t loopNumIterMask
static void signedCtrUpdate(int8_t &ctr, bool up, unsigned nbits)
const bool useDirectionBit
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
virtual bool optionalAgeInc() const
const unsigned loopTableTagBits
static void unsignedCtrUpdate(uint8_t &ctr, bool up, unsigned nbits)
Updates an unsigned counter based on up/down parameter.
const unsigned loopTableConfidenceBits
const uint16_t loopTagMask
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, bool tage_pred, BranchInfo *bi, unsigned instShiftAmt)
Update LTAGE for conditional branches.
Abstract superclass for simulation objects.
LoopPredictorStats(statistics::Group *parent)
void loopUpdate(Addr pc, bool Taken, BranchInfo *bi, bool tage_pred)
Updates the loop predictor.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const unsigned initialLoopAge
int finallindex(int lindex, int lowPcBits, int way) const
Computes the index used to access the ltable structures.
void updateStats(bool taken, BranchInfo *bi)
Update the stats.
bool getLoop(Addr pc, BranchInfo *bi, bool speculative, unsigned instShiftAmt) const
Get a branch prediction from the loop predictor.
const bool useSpeculation
const uint8_t confidenceThreshold
virtual bool calcConf(int index) const
const unsigned loopTableAgeBits
const unsigned loopTableIterBits
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
statistics::Scalar correct
LoopPredictor(const LoopPredictorParams &p)
const bool restrictAllocation
virtual BranchInfo * makeBranchInfo()
int16_t ThreadID
Thread index/ID type.
gem5::branch_prediction::LoopPredictor::LoopPredictorStats stats
Generated on Sun Jul 30 2023 01:56:53 for gem5 by doxygen 1.8.17