Go to the documentation of this file.
38 #include "debug/LTage.hh"
39 #include "params/LoopPredictor.hh"
43 loopTableAgeBits(
p.loopTableAgeBits),
44 loopTableConfidenceBits(
p.loopTableConfidenceBits),
45 loopTableTagBits(
p.loopTableTagBits),
46 loopTableIterBits(
p.loopTableIterBits),
47 logLoopTableAssoc(
p.logLoopTableAssoc),
48 confidenceThreshold((1 << loopTableConfidenceBits) - 1),
49 loopTagMask((1 << loopTableTagBits) - 1),
50 loopNumIterMask((1 << loopTableIterBits) - 1),
51 loopSetMask((1 << (logSizeLoopPred - logLoopTableAssoc)) - 1),
53 withLoopBits(
p.withLoopBits),
54 useDirectionBit(
p.useDirectionBit),
55 useSpeculation(
p.useSpeculation),
56 useHashing(
p.useHashing),
57 restrictAllocation(
p.restrictAllocation),
58 initialLoopIter(
p.initialLoopIter),
59 initialLoopAge(
p.initialLoopAge),
60 optionalAgeReset(
p.optionalAgeReset),
95 Addr pc = pc_in >> instShiftAmt;
113 unsigned instShiftAmt)
const
116 bi->loopPredValid =
false;
132 if (
ltable[idx].tag ==
bi->loopTag) {
139 if ((iter + 1) ==
ltable[idx].numIter) {
158 if (
bi->loopHit>=0) {
179 if (
bi->loopHit >= 0) {
181 if (
bi->loopPredValid) {
182 if (taken !=
bi->loopPred) {
190 DPRINTF(LTage,
"Loop Prediction success:%lx\n",
pc);
199 if (
ltable[idx].numIter != 0) {
210 DPRINTF(LTage,
"Loop End predicted successfully:%lx\n",
pc);
214 if (
ltable[idx].numIter < 3) {
222 DPRINTF(LTage,
"Loop End predicted incorrectly:%lx\n",
pc);
223 if (
ltable[idx].numIter == 0) {
247 if (
ltable[idx].age == 0) {
249 "Allocating loop pred entry for branch %lx\n",
272 BranchInfo*
bi,
bool prev_pred_taken,
unsigned instShiftAmt)
274 bool pred_taken = prev_pred_taken;
280 pred_taken =
bi->loopPred;
281 bi->loopPredUsed =
true;
295 if (
bi->loopHit >= 0) {
306 if (
bi->loopHit >= 0) {
317 if (taken ==
bi->loopPred) {
327 unsigned instShiftAmt)
334 bi->loopPred =
getLoop(branch_pc,
bi,
false, instShiftAmt);
337 if (
bi->loopPredValid) {
338 if (
bi->predTaken !=
bi->loopPred) {
340 (
bi->loopPred == taken),
349 :
Stats::Group(parent),
351 "Number of times the loop predictor is the provider and the "
352 "prediction is correct"),
354 "Number of times the loop predictor is the provider and the "
355 "prediction is wrong")
const unsigned loopTableConfidenceBits
static void unsignedCtrUpdate(uint8_t &ctr, bool up, unsigned nbits)
Updates an unsigned counter based on up/down parameter.
void updateStats(bool taken, BranchInfo *bi)
Update the stats.
int16_t ThreadID
Thread index/ID type.
LoopPredictor::LoopPredictorStats stats
void squash(ThreadID tid, BranchInfo *bi)
int finallindex(int lindex, int lowPcBits, int way) const
Computes the index used to access the ltable structures.
const uint8_t confidenceThreshold
void specLoopUpdate(bool taken, BranchInfo *bi)
Speculatively updates the loop predictor iteration count (only for useSpeculation).
void loopUpdate(Addr pc, bool Taken, BranchInfo *bi, bool tage_pred)
Updates the loop predictor.
const unsigned initialLoopAge
virtual bool optionalAgeInc() const
const bool optionalAgeReset
std::enable_if_t< std::is_integral< T >::value, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
virtual bool calcConf(int index) const
virtual BranchInfo * makeBranchInfo()
const bool useSpeculation
void init() override
Initialize the loop predictor.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
const uint16_t loopTagMask
LoopPredictorStats(Stats::Group *parent)
const unsigned logSizeLoopPred
void squashLoop(BranchInfo *bi)
const unsigned initialLoopIter
const unsigned loopTableIterBits
bool getLoop(Addr pc, BranchInfo *bi, bool speculative, unsigned instShiftAmt) const
Get a branch prediction from the loop predictor.
static void signedCtrUpdate(int8_t &ctr, bool up, unsigned nbits)
bool loopPredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, unsigned instShiftAmt)
Get the loop prediction.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const unsigned loopTableTagBits
const bool restrictAllocation
const unsigned loopTableAgeBits
size_t getSizeInBits() const
LoopPredictor(const LoopPredictorParams &p)
void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, bool tage_pred, BranchInfo *bi, unsigned instShiftAmt)
Update LTAGE for conditional branches.
int lindex(Addr pc_in, unsigned instShiftAmt) const
Computes the index used to access the loop predictor.
const unsigned logLoopTableAssoc
const uint16_t loopNumIterMask
#define ULL(N)
uint64_t constant
const bool useDirectionBit
Abstract superclass for simulation objects.
Generated on Tue Mar 23 2021 19:41:25 for gem5 by doxygen 1.8.17