42#ifndef __CPU_PRED_STATISTICAL_CORRECTOR_HH__
43#define __CPU_PRED_STATISTICAL_CORRECTOR_HH__
53struct StatisticalCorrectorParams;
55namespace branch_prediction
62 inline void ctrUpdate(T & ctr,
bool taken,
int nbits) {
63 assert(nbits <=
sizeof(T) << 3);
66 if (ctr < ((1 << (nbits - 1)) - 1))
69 if (ctr > -(1 << (nbits - 1)))
104 unsigned idx = ordinal - 1;
109 int ordinal,
Addr branch_pc,
bool taken,
Addr extraXor = 0)
112 unsigned idx = ordinal - 1;
114 unsigned entry =
getEntry(branch_pc, idx);
118 hist = hist ^ extraXor;
230 bool prev_pred_taken,
bool bias_bit,
bool use_conf_ctr,
231 int8_t conf_ctr,
unsigned conf_bits,
int hitBank,
int altBank,
232 int64_t phist,
int init_lsum = 0);
239 int hitBank,
int altBank)
const = 0;
245 int & lsum, int64_t phist) = 0;
247 int64_t
gIndex(
Addr branch_pc, int64_t bhist,
int logs,
int nbr,
int i);
273 void init()
override;
278 int hitBank,
int altBank, int64_t phist);
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Abstract superclass for simulation objects.
const unsigned logSizeUps
void initGEHLTable(unsigned numLenghts, std::vector< int > lengths, std::vector< int8_t > *&table, unsigned logNumEntries, std::vector< int8_t > &w, int8_t wInitValue)
std::vector< int8_t > * lgehl
gem5::branch_prediction::StatisticalCorrector::StatisticalCorrectorStats stats
virtual void scHistoryUpdate(Addr branch_pc, const StaticInstPtr &inst, bool taken, BranchInfo *tage_bi, Addr corrTarget)
virtual void gUpdates(ThreadID tid, Addr pc, bool taken, BranchInfo *bi, int64_t phist)=0
void updateStats(bool taken, BranchInfo *bi)
virtual unsigned getIndBiasSK(Addr branch_pc, BranchInfo *bi) const
int gPredict(Addr branch_pc, int64_t hist, std::vector< int > &length, std::vector< int8_t > *tab, int nbr, int logs, std::vector< int8_t > &w)
const unsigned scCountersWidth
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)
const unsigned numEntriesFirstLocalHistories
StatisticalCorrector(const StatisticalCorrectorParams &p)
virtual unsigned getIndUpd(Addr branch_pc) const
virtual unsigned getIndBias(Addr branch_pc, BranchInfo *bi, bool b) const
void ctrUpdate(T &ctr, bool taken, int nbits)
const unsigned extraWeightsWidth
SCThreadHistory * scHistory
const unsigned chooserConfWidth
virtual size_t getSizeInBits() const
virtual 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, BranchInfo *bi)
std::vector< int8_t > biasSK
std::vector< int8_t > * bwgehl
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< int8_t > biasBank
virtual int gPredictions(ThreadID tid, Addr branch_pc, BranchInfo *bi, int &lsum, int64_t phist)=0
std::vector< int > pUpdateThreshold
virtual unsigned getIndBiasBank(Addr branch_pc, BranchInfo *bi, int hitBank, int altBank) const =0
virtual SCThreadHistory * makeThreadHistory()
unsigned getIndUpds(Addr branch_pc) const
virtual void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *bi, Addr corrTarget, bool bias_bit, int hitBank, int altBank, int64_t phist)
std::vector< int8_t > wbw
const unsigned updateThresholdWidth
virtual int gIndexLogsSubstr(int nbr, int i)=0
int64_t gIndex(Addr branch_pc, int64_t bhist, int logs, int nbr, int i)
std::vector< int8_t > * igehl
virtual BranchInfo * makeBranchInfo()
std::vector< int8_t > bias
const unsigned pUpdateThresholdWidth
This is a simple scalar statistic, like a counter.
static constexpr bool isPowerOf2(const T &n)
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.
Declaration of Statistics objects.
std::vector< int64_t > * localHistories
std::vector< int > shifts
unsigned getEntry(Addr pc, unsigned idx)
void initLocalHistory(int ordinal, int numHistories, int shift)
void updateLocalHistory(int ordinal, Addr branch_pc, bool taken, Addr extraXor=0)
unsigned numOrdinalHistories
void setNumOrdinalHistories(unsigned num)
int64_t getLocalHistory(int ordinal, Addr pc)
statistics::Scalar correct
StatisticalCorrectorStats(statistics::Group *parent)