gem5  v22.1.0.0
Classes | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
gem5::branch_prediction::LoopPredictor Class Reference

#include <loop_predictor.hh>

Inheritance diagram for gem5::branch_prediction::LoopPredictor:
gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named gem5::branch_prediction::MPP_LoopPredictor gem5::branch_prediction::TAGE_SC_L_LoopPredictor gem5::branch_prediction::MPP_LoopPredictor_8KB

Classes

struct  BranchInfo
 
struct  LoopEntry
 
struct  LoopPredictorStats
 

Public Member Functions

int lindex (Addr pc_in, unsigned instShiftAmt) const
 Computes the index used to access the loop predictor. More...
 
int finallindex (int lindex, int lowPcBits, int way) const
 Computes the index used to access the ltable structures. More...
 
bool getLoop (Addr pc, BranchInfo *bi, bool speculative, unsigned instShiftAmt) const
 Get a branch prediction from the loop predictor. More...
 
void loopUpdate (Addr pc, bool Taken, BranchInfo *bi, bool tage_pred)
 Updates the loop predictor. More...
 
void specLoopUpdate (bool taken, BranchInfo *bi)
 Speculatively updates the loop predictor iteration count (only for useSpeculation). More...
 
void condBranchUpdate (ThreadID tid, Addr branch_pc, bool taken, bool tage_pred, BranchInfo *bi, unsigned instShiftAmt)
 Update LTAGE for conditional branches. More...
 
bool loopPredict (ThreadID tid, Addr branch_pc, bool cond_branch, BranchInfo *bi, bool prev_pred_taken, unsigned instShiftAmt)
 Get the loop prediction. More...
 
void updateStats (bool taken, BranchInfo *bi)
 Update the stats. More...
 
void squashLoop (BranchInfo *bi)
 
void squash (ThreadID tid, BranchInfo *bi)
 
virtual bool calcConf (int index) const
 
virtual bool optionalAgeInc () const
 
virtual BranchInfomakeBranchInfo ()
 
int8_t getLoopUseCounter () const
 Gets the value of the loop use counter. More...
 
void init () override
 Initialize the loop predictor. More...
 
 LoopPredictor (const LoopPredictorParams &p)
 
size_t getSizeInBits () const
 
- Public Member Functions inherited from gem5::SimObject
const Paramsparams () const
 
 SimObject (const Params &p)
 
virtual ~SimObject ()
 
virtual void loadState (CheckpointIn &cp)
 loadState() is called on each SimObject when restoring from a checkpoint. More...
 
virtual void initState ()
 initState() is called on each SimObject when not restoring from a checkpoint. More...
 
virtual void regProbePoints ()
 Register probe points for this object. More...
 
virtual void regProbeListeners ()
 Register probe listeners for this object. More...
 
ProbeManagergetProbeManager ()
 Get the probe manager for this object. More...
 
virtual PortgetPort (const std::string &if_name, PortID idx=InvalidPortID)
 Get a port with a given name and index. More...
 
virtual void startup ()
 startup() is the final initialization call before simulation. More...
 
DrainState drain () override
 Provide a default implementation of the drain interface for objects that don't need draining. More...
 
virtual void memWriteback ()
 Write back dirty buffers to memory using functional writes. More...
 
virtual void memInvalidate ()
 Invalidate the contents of memory buffers. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize an object. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize an object. More...
 
- Public Member Functions inherited from gem5::EventManager
EventQueueeventQueue () const
 
void schedule (Event &event, Tick when)
 
void deschedule (Event &event)
 
void reschedule (Event &event, Tick when, bool always=false)
 
void schedule (Event *event, Tick when)
 
void deschedule (Event *event)
 
void reschedule (Event *event, Tick when, bool always=false)
 
void wakeupEventQueue (Tick when=(Tick) -1)
 This function is not needed by the usual gem5 event loop but may be necessary in derived EventQueues which host gem5 on other schedulers. More...
 
void setCurTick (Tick newVal)
 
 EventManager (EventManager &em)
 Event manger manages events in the event queue. More...
 
 EventManager (EventManager *em)
 
 EventManager (EventQueue *eq)
 
- Public Member Functions inherited from gem5::Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 
- Public Member Functions inherited from gem5::Drainable
DrainState drainState () const
 Return the current drain state of an object. More...
 
virtual void notifyFork ()
 Notify a child process of a fork. More...
 
- Public Member Functions inherited from gem5::statistics::Group
 Group (Group *parent, const char *name=nullptr)
 Construct a new statistics group. More...
 
virtual ~Group ()
 
virtual void regStats ()
 Callback to set stat parameters. More...
 
virtual void resetStats ()
 Callback to reset stats. More...
 
virtual void preDumpStats ()
 Callback before stats are dumped. More...
 
void addStat (statistics::Info *info)
 Register a stat with this group. More...
 
const std::map< std::string, Group * > & getStatGroups () const
 Get all child groups associated with this object. More...
 
const std::vector< Info * > & getStats () const
 Get all stats associated with this object. More...
 
void addStatGroup (const char *name, Group *block)
 Add a stat block as a child of this block. More...
 
const InforesolveStat (std::string name) const
 Resolve a stat by its name within this group. More...
 
void mergeStatGroup (Group *block)
 Merge the contents (stats & children) of a block to this block. More...
 
 Group ()=delete
 
 Group (const Group &)=delete
 
Groupoperator= (const Group &)=delete
 
- Public Member Functions inherited from gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 

Static Protected Member Functions

static void unsignedCtrUpdate (uint8_t &ctr, bool up, unsigned nbits)
 Updates an unsigned counter based on up/down parameter. More...
 
static void signedCtrUpdate (int8_t &ctr, bool up, unsigned nbits)
 

Protected Attributes

const unsigned logSizeLoopPred
 
const unsigned loopTableAgeBits
 
const unsigned loopTableConfidenceBits
 
const unsigned loopTableTagBits
 
const unsigned loopTableIterBits
 
const unsigned logLoopTableAssoc
 
const uint8_t confidenceThreshold
 
const uint16_t loopTagMask
 
const uint16_t loopNumIterMask
 
const int loopSetMask
 
LoopEntryltable
 
int8_t loopUseCounter
 
unsigned withLoopBits
 
const bool useDirectionBit
 
const bool useSpeculation
 
const bool useHashing
 
const bool restrictAllocation
 
const unsigned initialLoopIter
 
const unsigned initialLoopAge
 
const bool optionalAgeReset
 
gem5::branch_prediction::LoopPredictor::LoopPredictorStats stats
 
- Protected Attributes inherited from gem5::SimObject
const SimObjectParams & _params
 Cached copy of the object parameters. More...
 
- Protected Attributes inherited from gem5::EventManager
EventQueueeventq
 A pointer to this object's event queue. More...
 

Additional Inherited Members

- Public Types inherited from gem5::SimObject
typedef SimObjectParams Params
 
- Static Public Member Functions inherited from gem5::SimObject
static void serializeAll (const std::string &cpt_dir)
 Create a checkpoint by serializing all SimObjects in the system. More...
 
static SimObjectfind (const char *name)
 Find the SimObject with the given name and return a pointer to it. More...
 
static void setSimObjectResolver (SimObjectResolver *resolver)
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
static SimObjectResolvergetSimObjectResolver ()
 There is a single object name resolver, and it is only set when simulation is restoring from checkpoints. More...
 
- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section. More...
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it. More...
 
- Protected Member Functions inherited from gem5::Drainable
 Drainable ()
 
virtual ~Drainable ()
 
virtual void drainResume ()
 Resume execution after a successful drain. More...
 
void signalDrainDone () const
 Signal that an object is drained. More...
 

Detailed Description

Definition at line 49 of file loop_predictor.hh.

Constructor & Destructor Documentation

◆ LoopPredictor()

gem5::branch_prediction::LoopPredictor::LoopPredictor ( const LoopPredictorParams &  p)

Definition at line 47 of file loop_predictor.cc.

References initialLoopAge, and loopTableAgeBits.

Member Function Documentation

◆ calcConf()

bool gem5::branch_prediction::LoopPredictor::calcConf ( int  index) const
virtual

◆ condBranchUpdate()

void gem5::branch_prediction::LoopPredictor::condBranchUpdate ( ThreadID  tid,
Addr  branch_pc,
bool  taken,
bool  tage_pred,
BranchInfo bi,
unsigned  instShiftAmt 
)

Update LTAGE for conditional branches.

Parameters
branch_pcThe unshifted branch PC.
takenActual branch outcome.
tage_predPrediction from TAGE
biPointer to information on the prediction recorded at prediction time.
instShiftAmtNumber of bits to shift instructions

Definition at line 331 of file loop_predictor.cc.

References gem5::PowerISA::bi, getLoop(), loopUpdate(), loopUseCounter, signedCtrUpdate(), useSpeculation, and withLoopBits.

Referenced by gem5::branch_prediction::LTAGE::update(), gem5::branch_prediction::TAGE_SC_L::update(), and gem5::branch_prediction::MultiperspectivePerceptronTAGE::update().

◆ finallindex()

int gem5::branch_prediction::LoopPredictor::finallindex ( int  lindex,
int  lowPcBits,
int  way 
) const

Computes the index used to access the ltable structures.

It may take hashing into account

Parameters
indexResult of lindex function
lowPcBitsPC bits masked with set size
wayWay to be used

Definition at line 109 of file loop_predictor.cc.

References gem5::MipsISA::index, logLoopTableAssoc, and useHashing.

Referenced by getLoop(), loopUpdate(), specLoopUpdate(), squash(), and squashLoop().

◆ getLoop()

bool gem5::branch_prediction::LoopPredictor::getLoop ( Addr  pc,
BranchInfo bi,
bool  speculative,
unsigned  instShiftAmt 
) const

Get a branch prediction from the loop predictor.

Parameters
pcThe unshifted branch PC.
biPointer to information on the prediction.
speculativeUse speculative number of iterations
instShiftAmtShift the pc by as many bits (if hashing is not used)
Returns
the result of the prediction, if it could be predicted

Definition at line 118 of file loop_predictor.cc.

References gem5::PowerISA::bi, calcConf(), gem5::branch_prediction::LoopPredictor::LoopEntry::currentIter, gem5::branch_prediction::LoopPredictor::LoopEntry::currentIterSpec, gem5::branch_prediction::LoopPredictor::LoopEntry::dir, finallindex(), gem5::ArmISA::i, lindex(), logLoopTableAssoc, logSizeLoopPred, loopSetMask, loopTableTagBits, loopTagMask, ltable, gem5::MipsISA::pc, useDirectionBit, and useHashing.

Referenced by condBranchUpdate(), and loopPredict().

◆ getLoopUseCounter()

int8_t gem5::branch_prediction::LoopPredictor::getLoopUseCounter ( ) const
inline

Gets the value of the loop use counter.

Returns
the loop use counter value

Definition at line 252 of file loop_predictor.hh.

References loopUseCounter.

Referenced by gem5::branch_prediction::LTAGE::predict().

◆ getSizeInBits()

size_t gem5::branch_prediction::LoopPredictor::getSizeInBits ( ) const

◆ init()

void gem5::branch_prediction::LoopPredictor::init ( )
overridevirtual

Initialize the loop predictor.

Reimplemented from gem5::SimObject.

Definition at line 73 of file loop_predictor.cc.

References logLoopTableAssoc, logSizeLoopPred, loopTableIterBits, loopTableTagBits, and ltable.

◆ lindex()

int gem5::branch_prediction::LoopPredictor::lindex ( Addr  pc_in,
unsigned  instShiftAmt 
) const

Computes the index used to access the loop predictor.

Parameters
pc_inThe unshifted branch PC.
instShiftAmtShift the pc by as many bits

Definition at line 92 of file loop_predictor.cc.

References logLoopTableAssoc, loopSetMask, gem5::MipsISA::pc, and useHashing.

Referenced by getLoop().

◆ loopPredict()

bool gem5::branch_prediction::LoopPredictor::loopPredict ( ThreadID  tid,
Addr  branch_pc,
bool  cond_branch,
BranchInfo bi,
bool  prev_pred_taken,
unsigned  instShiftAmt 
)

Get the loop prediction.

Parameters
tidThe thread ID to select the global histories to use.
branch_pcThe unshifted branch PC.
cond_branchTrue if the branch is conditional.
biReference to wrapping pointer to allow storing derived class prediction information in the base class.
prev_pred_takenResult of the TAGE prediction
instShiftAmtShift the pc by as many bits
instShiftAmtShift the pc by as many bits
Returns
the prediction, true if taken

Definition at line 277 of file loop_predictor.cc.

References gem5::PowerISA::bi, getLoop(), loopUseCounter, specLoopUpdate(), and useSpeculation.

Referenced by gem5::branch_prediction::MultiperspectivePerceptronTAGE::lookup(), gem5::branch_prediction::LTAGE::predict(), and gem5::branch_prediction::TAGE_SC_L::predict().

◆ loopUpdate()

void gem5::branch_prediction::LoopPredictor::loopUpdate ( Addr  pc,
bool  Taken,
BranchInfo bi,
bool  tage_pred 
)

◆ makeBranchInfo()

LoopPredictor::BranchInfo * gem5::branch_prediction::LoopPredictor::makeBranchInfo ( )
virtual

Definition at line 86 of file loop_predictor.cc.

◆ optionalAgeInc()

bool gem5::branch_prediction::LoopPredictor::optionalAgeInc ( ) const
virtual

◆ signedCtrUpdate()

static void gem5::branch_prediction::LoopPredictor::signedCtrUpdate ( int8_t &  ctr,
bool  up,
unsigned  nbits 
)
inlinestaticprotected

Definition at line 117 of file loop_predictor.hh.

References gem5::ArmISA::up.

Referenced by condBranchUpdate().

◆ specLoopUpdate()

void gem5::branch_prediction::LoopPredictor::specLoopUpdate ( bool  taken,
BranchInfo bi 
)

Speculatively updates the loop predictor iteration count (only for useSpeculation).

Parameters
takenThe predicted branch outcome.
biPointer to information on the prediction recorded at prediction time.

Definition at line 162 of file loop_predictor.cc.

References gem5::PowerISA::bi, gem5::branch_prediction::LoopPredictor::LoopEntry::currentIterSpec, finallindex(), gem5::MipsISA::index, loopNumIterMask, and ltable.

Referenced by loopPredict().

◆ squash()

void gem5::branch_prediction::LoopPredictor::squash ( ThreadID  tid,
BranchInfo bi 
)

◆ squashLoop()

void gem5::branch_prediction::LoopPredictor::squashLoop ( BranchInfo bi)

◆ unsignedCtrUpdate()

static void gem5::branch_prediction::LoopPredictor::unsignedCtrUpdate ( uint8_t &  ctr,
bool  up,
unsigned  nbits 
)
inlinestaticprotected

Updates an unsigned counter based on up/down parameter.

Parameters
ctrReference to counter to update.
upBoolean indicating if the counter is incremented/decremented If true it is incremented, if false it is decremented
nbitsCounter width.

Definition at line 106 of file loop_predictor.hh.

References gem5::ArmISA::up.

Referenced by loopUpdate().

◆ updateStats()

void gem5::branch_prediction::LoopPredictor::updateStats ( bool  taken,
BranchInfo bi 
)

Member Data Documentation

◆ confidenceThreshold

const uint8_t gem5::branch_prediction::LoopPredictor::confidenceThreshold
protected

Definition at line 58 of file loop_predictor.hh.

Referenced by calcConf().

◆ initialLoopAge

const unsigned gem5::branch_prediction::LoopPredictor::initialLoopAge
protected

Definition at line 89 of file loop_predictor.hh.

Referenced by LoopPredictor(), and loopUpdate().

◆ initialLoopIter

const unsigned gem5::branch_prediction::LoopPredictor::initialLoopIter
protected

Definition at line 88 of file loop_predictor.hh.

Referenced by loopUpdate().

◆ logLoopTableAssoc

const unsigned gem5::branch_prediction::LoopPredictor::logLoopTableAssoc
protected

Definition at line 57 of file loop_predictor.hh.

Referenced by finallindex(), getLoop(), init(), lindex(), and loopUpdate().

◆ logSizeLoopPred

const unsigned gem5::branch_prediction::LoopPredictor::logSizeLoopPred
protected

Definition at line 52 of file loop_predictor.hh.

Referenced by getLoop(), getSizeInBits(), and init().

◆ loopNumIterMask

const uint16_t gem5::branch_prediction::LoopPredictor::loopNumIterMask
protected

Definition at line 60 of file loop_predictor.hh.

Referenced by loopUpdate(), and specLoopUpdate().

◆ loopSetMask

const int gem5::branch_prediction::LoopPredictor::loopSetMask
protected

Definition at line 61 of file loop_predictor.hh.

Referenced by getLoop(), and lindex().

◆ loopTableAgeBits

const unsigned gem5::branch_prediction::LoopPredictor::loopTableAgeBits
protected

Definition at line 53 of file loop_predictor.hh.

Referenced by getSizeInBits(), LoopPredictor(), and loopUpdate().

◆ loopTableConfidenceBits

const unsigned gem5::branch_prediction::LoopPredictor::loopTableConfidenceBits
protected

Definition at line 54 of file loop_predictor.hh.

Referenced by getSizeInBits(), and loopUpdate().

◆ loopTableIterBits

const unsigned gem5::branch_prediction::LoopPredictor::loopTableIterBits
protected

Definition at line 56 of file loop_predictor.hh.

Referenced by getSizeInBits(), and init().

◆ loopTableTagBits

const unsigned gem5::branch_prediction::LoopPredictor::loopTableTagBits
protected

Definition at line 55 of file loop_predictor.hh.

Referenced by getLoop(), getSizeInBits(), and init().

◆ loopTagMask

const uint16_t gem5::branch_prediction::LoopPredictor::loopTagMask
protected

Definition at line 59 of file loop_predictor.hh.

Referenced by getLoop().

◆ loopUseCounter

int8_t gem5::branch_prediction::LoopPredictor::loopUseCounter
protected

Definition at line 81 of file loop_predictor.hh.

Referenced by condBranchUpdate(), getLoopUseCounter(), and loopPredict().

◆ ltable

LoopEntry* gem5::branch_prediction::LoopPredictor::ltable
protected

◆ optionalAgeReset

const bool gem5::branch_prediction::LoopPredictor::optionalAgeReset
protected

Definition at line 90 of file loop_predictor.hh.

Referenced by loopUpdate().

◆ restrictAllocation

const bool gem5::branch_prediction::LoopPredictor::restrictAllocation
protected

Definition at line 87 of file loop_predictor.hh.

Referenced by loopUpdate().

◆ stats

gem5::branch_prediction::LoopPredictor::LoopPredictorStats gem5::branch_prediction::LoopPredictor::stats
protected

Referenced by updateStats().

◆ useDirectionBit

const bool gem5::branch_prediction::LoopPredictor::useDirectionBit
protected

Definition at line 84 of file loop_predictor.hh.

Referenced by getLoop(), getSizeInBits(), and loopUpdate().

◆ useHashing

const bool gem5::branch_prediction::LoopPredictor::useHashing
protected

Definition at line 86 of file loop_predictor.hh.

Referenced by finallindex(), getLoop(), and lindex().

◆ useSpeculation

const bool gem5::branch_prediction::LoopPredictor::useSpeculation
protected

Definition at line 85 of file loop_predictor.hh.

Referenced by condBranchUpdate(), getSizeInBits(), and loopPredict().

◆ withLoopBits

unsigned gem5::branch_prediction::LoopPredictor::withLoopBits
protected

Definition at line 82 of file loop_predictor.hh.

Referenced by condBranchUpdate().


The documentation for this class was generated from the following files:

Generated on Wed Dec 21 2022 10:23:37 for gem5 by doxygen 1.9.1