Go to the documentation of this file.
   42 #include "debug/Fetch.hh" 
   43 #include "debug/Tage.hh" 
   48 namespace branch_prediction
 
   53      logRatioBiModalHystEntries(
p.logRatioBiModalHystEntries),
 
   54      nHistoryTables(
p.nHistoryTables),
 
   55      tagTableCounterBits(
p.tagTableCounterBits),
 
   56      tagTableUBits(
p.tagTableUBits),
 
   57      histBufferSize(
p.histBufferSize),
 
   60      pathHistBits(
p.pathHistBits),
 
   61      tagTableTagWidths(
p.tagTableTagWidths),
 
   62      logTagTableSizes(
p.logTagTableSizes),
 
   63      threadHistory(
p.numThreads),
 
   64      logUResetPeriod(
p.logUResetPeriod),
 
   65      initialTCounterValue(
p.initialTCounterValue),
 
   66      numUseAltOnNa(
p.numUseAltOnNa),
 
   67      useAltOnNaBits(
p.useAltOnNaBits),
 
   68      maxNumAlloc(
p.maxNumAlloc),
 
   70      speculativeHistUpdate(
p.speculativeHistUpdate),
 
   71      instShiftAmt(
p.instShiftAmt),
 
   73      stats(this, nHistoryTables)
 
  111         history.pathHist = 0;
 
  113         history.gHist = history.globalHistory;
 
  160         DPRINTF(Tage, 
"HistLength:%d, TTSize:%d, TTTWidth:%d\n",
 
  192         DPRINTF(Tage, 
"BTB miss resets prediction: %lx\n", branch_pc);
 
  217     A = A & ((1ULL << size) - 1);
 
  263     assert(nbits <= 
sizeof(T) << 3);
 
  265         if (ctr < ((1 << (nbits - 1)) - 1))
 
  268         if (ctr > -(1 << (nbits - 1)))
 
  281     assert(nbits <= 
sizeof(uint8_t) << 3);
 
  283         if (ctr < ((1 << nbits) - 1))
 
  309     } 
else if (inter > 0) {
 
  312     const bool pred = inter >> 1;
 
  313     const bool hyst = inter & 1;
 
  316     DPRINTF(Tage, 
"Updating branch %lx, pred:%d, hyst:%d\n", 
pc, pred, hyst);
 
  325         DPRINTF(Tage, 
"Rolling over the histories\n");
 
  336     h[0] = (dir) ? 1 : 0;
 
  364     bool pred_taken = 
true;
 
  385         for (
int i = 
bi->hitBank - 1; 
i > 0; 
i--) {
 
  394         if (
bi->hitBank > 0) {
 
  395             if (
bi->altBank > 0) {
 
  403             bi->longestMatchPred =
 
  412                 || ! 
bi->pseudoNewAlloc) {
 
  413                 bi->tagePred = 
bi->longestMatchPred;
 
  416                 bi->tagePred = 
bi->altTaken;
 
  422             bi->tagePred = 
bi->altTaken;
 
  423             bi->longestMatchPred = 
bi->altTaken;
 
  428         pred_taken = (
bi->tagePred);
 
  429         DPRINTF(Tage, 
"Predict for %lx: taken?:%d, tagePred:%d, altPred:%d\n",
 
  430                 branch_pc, pred_taken, 
bi->tagePred, 
bi->altTaken);
 
  432     bi->branchPC = branch_pc;
 
  433     bi->condBranch = cond_branch;
 
  461         int X = 
bi->hitBank + 1;
 
  474         unsigned numAllocated = 0;
 
  521     if (preAdjustAlloc) {
 
  525     if (
bi->hitBank > 0) {
 
  528         bool PseudoNewAlloc = 
bi->pseudoNewAlloc;
 
  531         if (PseudoNewAlloc) {
 
  532             if (
bi->longestMatchPred == taken) {
 
  537             if (
bi->longestMatchPred != 
bi->altTaken) {
 
  545     if (!preAdjustAlloc) {
 
  557     if (
bi->hitBank > 0) {
 
  558         DPRINTF(Tage, 
"Updating tag table entry (%d,%d) for branch %lx\n",
 
  559                 bi->hitBank, 
bi->hitBankIndex, branch_pc);
 
  564         if (
gtable[
bi->hitBank][
bi->hitBankIndex].
u == 0) {
 
  565             if (
bi->altBank > 0) {
 
  568                 DPRINTF(Tage, 
"Updating tag table entry (%d,%d) for" 
  569                         " branch %lx\n", 
bi->hitBank, 
bi->hitBankIndex,
 
  572             if (
bi->altBank == 0) {
 
  578         if (
bi->tagePred != 
bi->altTaken) {
 
  621     DPRINTF(Tage, 
"Updating global histories with branch:%lx; taken?:%d, " 
  622             "path Hist: %x; pointer:%d\n", branch_pc, taken, tHist.
pathHist,
 
  638     DPRINTF(Tage, 
"Restoring branch info: %lx; taken? %d; PathHistory:%x, " 
  639             "pointer:%d\n", 
bi->branchPC,taken, 
bi->pathHist, 
bi->ptGhist);
 
  643     tHist.
gHist[0] = (taken ? 1 : 0);
 
  664     if (taken == 
bi->tagePred) {
 
  666         switch (
bi->provider) {
 
  676         switch (
bi->provider) {
 
  680             if (
bi->altTaken == taken) {
 
  692         switch (
bi->provider) {
 
  695             if (
bi->longestMatchPred == taken) {
 
  701     switch (
bi->provider) {
 
  714     for (
unsigned i = 0; 
i < 32; 
i++) {
 
  716         int gh_offset = 
bi->ptGhist + 
i;
 
  727     : statistics::
Group(parent),
 
  728       ADD_STAT(longestMatchProviderCorrect, statistics::units::Count::get(),
 
  729                "Number of times TAGE Longest Match is the provider and the " 
  730                "prediction is correct"),
 
  731       ADD_STAT(altMatchProviderCorrect, statistics::units::Count::get(),
 
  732                "Number of times TAGE Alt Match is the provider and the " 
  733                "prediction is correct"),
 
  734       ADD_STAT(bimodalAltMatchProviderCorrect, statistics::units::Count::get(),
 
  735                "Number of times TAGE Alt Match is the bimodal and it is the " 
  736                "provider and the prediction is correct"),
 
  737       ADD_STAT(bimodalProviderCorrect, statistics::units::Count::get(),
 
  738                "Number of times there are no hits on the TAGE tables and the " 
  739                "bimodal prediction is correct"),
 
  740       ADD_STAT(longestMatchProviderWrong, statistics::units::Count::get(),
 
  741                "Number of times TAGE Longest Match is the provider and the " 
  742                "prediction is wrong"),
 
  743       ADD_STAT(altMatchProviderWrong, statistics::units::Count::get(),
 
  744                "Number of times TAGE Alt Match is the provider and the " 
  745                "prediction is wrong"),
 
  746       ADD_STAT(bimodalAltMatchProviderWrong, statistics::units::Count::get(),
 
  747                "Number of times TAGE Alt Match is the bimodal and it is the " 
  748                "provider and the prediction is wrong"),
 
  749       ADD_STAT(bimodalProviderWrong, statistics::units::Count::get(),
 
  750                "Number of times there are no hits on the TAGE tables and the " 
  751                "bimodal prediction is wrong"),
 
  752       ADD_STAT(altMatchProviderWouldHaveHit, statistics::units::Count::get(),
 
  753                "Number of times TAGE Longest Match is the provider, the " 
  754                "prediction is wrong and Alt Match prediction was correct"),
 
  755       ADD_STAT(longestMatchProviderWouldHaveHit, statistics::units::Count::get(),
 
  756                "Number of times TAGE Alt Match is the provider, the " 
  757                "prediction is wrong and Longest Match prediction was correct"),
 
  758       ADD_STAT(longestMatchProvider, statistics::units::Count::get(),
 
  759                "TAGE provider for longest match"),
 
  760       ADD_STAT(altMatchProvider, statistics::units::Count::get(),
 
  761                "TAGE provider for alt match")
 
  770     return gtable[hitBank][hitBankIndex].
ctr;
 
  800     bits += bimodalTableSize;
 
  
size_t getSizeInBits() const
const bool speculativeHistUpdate
virtual void squash(ThreadID tid, bool taken, BranchInfo *bi, Addr target)
Restores speculatively updated path and direction histories.
virtual void buildTageTables()
Instantiates the TAGE table entries.
const int64_t initialTCounterValue
const unsigned tagTableUBits
std::vector< ThreadHistory > threadHistory
TAGEBaseStats(statistics::Group *parent, unsigned nHistoryTables)
FoldedHistory * computeIndices
bool isSpeculativeUpdateEnabled() const
virtual BranchInfo * makeBranchInfo()
virtual void handleAllocAndUReset(bool alloc, bool taken, BranchInfo *bi, int nrand)
Handles Allocation and U bits reset on an update.
unsigned getTageCtrBits() const
virtual bool getBimodePred(Addr pc, BranchInfo *bi) const
Get a branch prediction from the bimodal predictor.
void init(int original_length, int compressed_length)
virtual void calculateIndicesAndTags(ThreadID tid, Addr branch_pc, BranchInfo *bi)
On a prediction, calculates the TAGE indices and tags for all the different history lengths.
statistics::Scalar bimodalProviderWrong
virtual void updateStats(bool taken, BranchInfo *bi)
Update the stats.
statistics::Scalar altMatchProviderWrong
virtual int F(int phist, int size, int bank) const
Utility function to shuffle the path history depending on which tagged table we are accessing.
statistics::Scalar longestMatchProviderWrong
static void ctrUpdate(T &ctr, bool taken, int nbits)
Updates a direction counter based on the actual branch outcome.
std::vector< bool > noSkip
virtual uint16_t gtag(ThreadID tid, Addr pc, int bank) const
Computes the partial tag of a tagged table.
static void unsignedCtrUpdate(uint8_t &ctr, bool up, unsigned nbits)
Updates an unsigned counter based on up/down parameter.
const unsigned logRatioBiModalHystEntries
const unsigned tagTableCounterBits
statistics::Scalar bimodalAltMatchProviderCorrect
void baseUpdate(Addr pc, bool taken, BranchInfo *bi)
Updates the bimodal predictor.
int8_t getCtr(int hitBank, int hitBankIndex) const
statistics::Scalar longestMatchProviderWouldHaveHit
std::vector< unsigned > tagTableTagWidths
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< bool > btablePrediction
gem5::branch_prediction::TAGEBase::TAGEBaseStats stats
virtual unsigned getUseAltIdx(BranchInfo *bi, Addr branch_pc)
Calculation of the index for useAltPredForNewlyAllocated On this base TAGE implementation it is alway...
virtual void initFoldedHistories(ThreadHistory &history)
Initialization of the folded histories.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
statistics::Vector longestMatchProvider
const unsigned pathHistBits
const unsigned nHistoryTables
statistics::Scalar longestMatchProviderCorrect
virtual void extraAltCalc(BranchInfo *bi)
Extra steps for calculating altTaken For this base TAGE class it does nothing.
FoldedHistory * computeTags[2]
statistics::Scalar bimodalAltMatchProviderWrong
int getPathHist(ThreadID tid) const
std::vector< bool > btableHysteresis
virtual void updateHistories(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *b, bool speculative, const StaticInstPtr &inst=nullStaticInstPtr, Addr target=MaxAddr)
(Speculatively) updates global histories (path and direction).
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Abstract superclass for simulation objects.
virtual int gindex(ThreadID tid, Addr pc, int bank) const
Computes the index used to access a partially tagged table.
virtual void condBranchUpdate(ThreadID tid, Addr branch_pc, bool taken, BranchInfo *bi, int nrand, Addr corrTarget, bool pred, bool preAdjustAlloc=false)
Update TAGE for conditional branches.
virtual void calculateParameters()
Calculates the history lengths and some other paramters in derived classes.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
statistics::Scalar altMatchProviderWouldHaveHit
virtual int bindex(Addr pc_in) const
Computes the index used to access the bimodal table.
virtual void handleUReset()
Handles the U bits reset.
std::vector< int > logTagTableSizes
statistics::Scalar bimodalProviderCorrect
void btbUpdate(ThreadID tid, Addr branch_addr, BranchInfo *&bi)
statistics::Vector altMatchProvider
std::vector< int8_t > useAltPredForNewlyAllocated
const unsigned instShiftAmt
unsigned getGHR(ThreadID tid, BranchInfo *bi) const
TAGEBase(const TAGEBaseParams &p)
virtual void adjustAlloc(bool &alloc, bool taken, bool pred_taken)
Extra calculation to tell whether TAGE allocaitons may happen or not on an update For this base TAGE ...
void updateGHist(uint8_t *&h, bool dir, uint8_t *tab, int &PT)
(Speculatively) updates the global branch history.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const unsigned histBufferSize
Derived & init(size_type size)
Set this vector to have the given size.
statistics::Scalar altMatchProviderCorrect
virtual void resetUctr(uint8_t &u)
Algorithm for resetting a single U counter.
int16_t ThreadID
Thread index/ID type.
bool tagePredict(ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi)
TAGE prediction called from TAGE::predict.
virtual void handleTAGEUpdate(Addr branch_pc, bool taken, BranchInfo *bi)
Handles the update of the TAGE entries.
Generated on Tue Sep 21 2021 12:25:05 for gem5 by  doxygen 1.8.17