Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Hybrid predictor is actually a tournament predictor. You now need to look at its source code (which is in BPred.h and BPRed.cpp files in

The Hybrid predictor is actually a tournament predictor. You now need to look at its source code (which is in BPred.h and BPRed.cpp files in the ~/sesc/src/libcore/ directory) and determine which of the parameters in the configuration file controls which aspect of the predictor. Hint: the Hybrid predictor is implemented in the BPHybrid class, so its constructor and predict method will tell you most of what you need to find out.

The meta-predictor in this hybrid predictor is a table that has__________ entries and each entry is a_________ bit counter. This meta-predictor decides, based on the PC address (i.e. the address from which we fetched the branch instruction), whether to make the prediction using a simple (no history) array of counters, or to use a (is it local or global?)_________history predictor. The simpler (non-history) predictor uses__________-bit counters, and has______of them (this number is specified using a parameter label_______ in the BPredIssueX section of the configuration file). The history-based predictor has________bits of history, which are combined with the PC address to index into an array that has________entries (this number of entries is specified in the configuration file using parameter label_________), and each entry is a_________-bit counter.

BPred.h

class BPHybrid:public BPred { private: BPBTB btb;

const ushort historySize; const HistoryType historyMask;

SCTable globalTable;

HistoryType ghr; // Global History Register

SCTable localTable; SCTable metaTable;

protected: public: BPHybrid(int32_t i, int32_t fetchWidth, const char *section); ~BPHybrid();

BPRed.cpp

BPHybrid::BPHybrid(int32_t i, int32_t fetchWidth, const char *section) :BPred(i, fetchWidth, section,"Hybrid") ,btb( i, fetchWidth, section) ,historySize(SescConf->getInt(section,"historySize")) ,historyMask((1 << historySize) - 1) ,globalTable(i,section ,SescConf->getInt(section,"l2Size") ,SescConf->getInt(section,"l2Bits")) ,ghr(0) ,localTable(i,section ,SescConf->getInt(section,"localSize") ,SescConf->getInt(section,"localBits")) ,metaTable(i,section ,SescConf->getInt(section,"MetaSize") ,SescConf->getInt(section,"MetaBits"))

{ // Constraints SescConf->isInt(section, "localSize"); SescConf->isPower2(section, "localSize"); SescConf->isBetween(section, "localBits", 1, 7);

SescConf->isInt(section , "MetaSize"); SescConf->isPower2(section , "MetaSize"); SescConf->isBetween(section , "MetaBits", 1, 7);

SescConf->isInt(section, "historySize"); SescConf->isBetween(section, "historySize", 1, 63);

SescConf->isInt(section, "l2Size"); SescConf->isPower2(section, "l2Size"); SescConf->isBetween(section,"l2Bits", 1, 7); }

BPHybrid::~BPHybrid() { }

PredType BPHybrid::predict(const Instruction *inst, InstID oracleID, bool doUpdate) { bpredEnergy->inc();

if( inst->isBranchTaken() ) return btb.predict(inst, oracleID, doUpdate);

bool taken = (inst->calcNextInstID() != oracleID); HistoryType iID = calcInstID(inst); HistoryType l2Index = ghr;

// update historyTable statistics if (doUpdate) { ghr = ((ghr << 1) | ((iID>>2 & 1)^(taken?1:0))) & historyMask; }

// calculate Table possition l2Index = ((l2Index ^ iID) & historyMask ) | (iID<

bool globalTaken; bool localTaken; if (doUpdate) { globalTaken = globalTable.predict(l2Index, taken); localTaken = localTable.predict(iID, taken); } else { globalTaken = globalTable.predict(l2Index); localTaken = localTable.predict(iID); }

bool metaOut; if (!doUpdate) { metaOut = metaTable.predict(l2Index); // do not update meta } else if( globalTaken == taken && localTaken != taken) { // global is correct, local incorrect metaOut = metaTable.predict(l2Index, false); } else if( globalTaken != taken && localTaken == taken) { // global is incorrect, local correct metaOut = metaTable.predict(l2Index, true); } else { metaOut = metaTable.predict(l2Index); // do not update meta }

bool ptaken = metaOut ? localTaken : globalTaken;

if (taken != ptaken) { if (doUpdate) btb.updateOnly(inst,oracleID); return MissPrediction; }

return ptaken ? btb.predict(inst, oracleID, doUpdate) : CorrectPrediction; }

void BPHybrid::switchIn(Pid_t pid) { }

void BPHybrid::switchOut(Pid_t pid)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago