gem5  v20.1.0.0
Classes | Public Types | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
MemDepUnit< MemDepPred, Impl > Class Template Reference

Memory dependency unit class. More...

#include <mem_dep_unit.hh>

Classes

class  MemDepEntry
 Memory dependence entries that track memory operations, marking when the instruction is ready to execute and what instructions depend upon it. More...
 

Public Types

typedef Impl::DynInstPtr DynInstPtr
 
typedef Impl::DynInstConstPtr DynInstConstPtr
 

Public Member Functions

 MemDepUnit ()
 Empty constructor. More...
 
 MemDepUnit (DerivO3CPUParams *params)
 Constructs a MemDepUnit with given parameters. More...
 
 ~MemDepUnit ()
 Frees up any memory allocated. More...
 
std::string name () const
 Returns the name of the memory dependence unit. More...
 
void init (DerivO3CPUParams *params, ThreadID tid)
 Initializes the unit with parameters and a thread id. More...
 
void regStats ()
 Registers statistics. More...
 
bool isDrained () const
 Determine if we are drained. More...
 
void drainSanityCheck () const
 Perform sanity checks after a drain. More...
 
void takeOverFrom ()
 Takes over from another CPU's thread. More...
 
void setIQ (InstructionQueue< Impl > *iq_ptr)
 Sets the pointer to the IQ. More...
 
void insert (const DynInstPtr &inst)
 Inserts a memory instruction. More...
 
void insertNonSpec (const DynInstPtr &inst)
 Inserts a non-speculative memory instruction. More...
 
void insertBarrier (const DynInstPtr &barr_inst)
 Inserts a barrier instruction. More...
 
void regsReady (const DynInstPtr &inst)
 Indicate that an instruction has its registers ready. More...
 
void nonSpecInstReady (const DynInstPtr &inst)
 Indicate that a non-speculative instruction is ready. More...
 
void reschedule (const DynInstPtr &inst)
 Reschedules an instruction to be re-executed. More...
 
void replay ()
 Replays all instructions that have been rescheduled by moving them to the ready list. More...
 
void completeInst (const DynInstPtr &inst)
 Notifies completion of an instruction. More...
 
void squash (const InstSeqNum &squashed_num, ThreadID tid)
 Squashes all instructions up until a given sequence number for a specific thread. More...
 
void violation (const DynInstPtr &store_inst, const DynInstPtr &violating_load)
 Indicates an ordering violation between a store and a younger load. More...
 
void issue (const DynInstPtr &inst)
 Issues the given instruction. More...
 
void dumpLists ()
 Debugging function to dump the lists of instructions. More...
 

Protected Attributes

std::string _name
 

Private Types

typedef std::list< DynInstPtr >::iterator ListIt
 
typedef std::shared_ptr< MemDepEntryMemDepEntryPtr
 
typedef std::unordered_map< InstSeqNum, MemDepEntryPtr, SNHashMemDepHash
 
typedef MemDepHash::iterator MemDepHashIt
 

Private Member Functions

void completed (const DynInstPtr &inst)
 Completes a memory instruction. More...
 
void wakeDependents (const DynInstPtr &inst)
 Wakes any dependents of a memory instruction. More...
 
MemDepEntryPtrfindInHash (const DynInstConstPtr &inst)
 Finds the memory dependence entry in the hash map. More...
 
void moveToReady (MemDepEntryPtr &ready_inst_entry)
 Moves an entry to the ready list. More...
 
bool hasLoadBarrier () const
 Is there an outstanding load barrier that loads must wait on. More...
 
bool hasStoreBarrier () const
 Is there an outstanding store barrier that loads must wait on. More...
 
void insertBarrierSN (const DynInstPtr &barr_inst)
 Inserts the SN of a barrier inst. More...
 

Private Attributes

MemDepHash memDepHash
 A hash map of all memory dependence entries. More...
 
std::list< DynInstPtrinstList [Impl::MaxThreads]
 A list of all instructions in the memory dependence unit. More...
 
std::list< DynInstPtrinstsToReplay
 A list of all instructions that are going to be replayed. More...
 
MemDepPred depPred
 The memory dependence predictor. More...
 
std::unordered_set< InstSeqNumloadBarrierSNs
 Sequence numbers of outstanding load barriers. More...
 
std::unordered_set< InstSeqNumstoreBarrierSNs
 Sequence numbers of outstanding store barriers. More...
 
InstructionQueue< Impl > * iqPtr
 Pointer to the IQ. More...
 
int id
 The thread id of this memory dependence unit. More...
 
Stats::Scalar insertedLoads
 Stat for number of inserted loads. More...
 
Stats::Scalar insertedStores
 Stat for number of inserted stores. More...
 
Stats::Scalar conflictingLoads
 Stat for number of conflicting loads that had to wait for a store. More...
 
Stats::Scalar conflictingStores
 Stat for number of conflicting stores that had to wait for a store. More...
 

Detailed Description

template<class MemDepPred, class Impl>
class MemDepUnit< MemDepPred, Impl >

Memory dependency unit class.

This holds the memory dependence predictor. As memory operations are issued to the IQ, they are also issued to this unit, which then looks up the prediction as to what they are dependent upon. This unit must be checked prior to a memory operation being able to issue. Although this is templated, it's somewhat hard to make a generic memory dependence unit. This one is mostly for store sets; it will be quite limited in what other memory dependence predictions it can also utilize. Thus this class should be most likely be rewritten for other dependence prediction schemes.

Definition at line 80 of file mem_dep_unit.hh.

Member Typedef Documentation

◆ DynInstConstPtr

template<class MemDepPred , class Impl >
typedef Impl::DynInstConstPtr MemDepUnit< MemDepPred, Impl >::DynInstConstPtr

Definition at line 87 of file mem_dep_unit.hh.

◆ DynInstPtr

template<class MemDepPred , class Impl >
typedef Impl::DynInstPtr MemDepUnit< MemDepPred, Impl >::DynInstPtr

Definition at line 86 of file mem_dep_unit.hh.

◆ ListIt

template<class MemDepPred , class Impl >
typedef std::list<DynInstPtr>::iterator MemDepUnit< MemDepPred, Impl >::ListIt
private

Definition at line 168 of file mem_dep_unit.hh.

◆ MemDepEntryPtr

template<class MemDepPred , class Impl >
typedef std::shared_ptr<MemDepEntry> MemDepUnit< MemDepPred, Impl >::MemDepEntryPtr
private

Definition at line 170 of file mem_dep_unit.hh.

◆ MemDepHash

template<class MemDepPred , class Impl >
typedef std::unordered_map<InstSeqNum, MemDepEntryPtr, SNHash> MemDepUnit< MemDepPred, Impl >::MemDepHash
private

Definition at line 242 of file mem_dep_unit.hh.

◆ MemDepHashIt

template<class MemDepPred , class Impl >
typedef MemDepHash::iterator MemDepUnit< MemDepPred, Impl >::MemDepHashIt
private

Definition at line 244 of file mem_dep_unit.hh.

Constructor & Destructor Documentation

◆ MemDepUnit() [1/2]

template<class MemDepPred , class Impl >
MemDepUnit< MemDepPred, Impl >::MemDepUnit

Empty constructor.

Must call init() prior to using in this case.

Definition at line 53 of file mem_dep_unit_impl.hh.

◆ MemDepUnit() [2/2]

template<class MemDepPred , class Impl >
MemDepUnit< MemDepPred, Impl >::MemDepUnit ( DerivO3CPUParams *  params)

Constructs a MemDepUnit with given parameters.

Definition at line 59 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ ~MemDepUnit()

template<class MemDepPred , class Impl >
MemDepUnit< MemDepPred, Impl >::~MemDepUnit

Frees up any memory allocated.

Definition at line 69 of file mem_dep_unit_impl.hh.

Member Function Documentation

◆ completed()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::completed ( const DynInstPtr inst)
private

Completes a memory instruction.

Definition at line 417 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ completeInst()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::completeInst ( const DynInstPtr inst)

Notifies completion of an instruction.

Definition at line 441 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ drainSanityCheck()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::drainSanityCheck

Perform sanity checks after a drain.

Definition at line 142 of file mem_dep_unit_impl.hh.

References ArmISA::i.

◆ dumpLists()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::dumpLists

Debugging function to dump the lists of instructions.

Definition at line 600 of file mem_dep_unit_impl.hh.

References cprintf().

◆ findInHash()

template<class MemDepPred , class Impl >
MemDepUnit< MemDepPred, Impl >::MemDepEntryPtr & MemDepUnit< MemDepPred, Impl >::findInHash ( const DynInstConstPtr inst)
inlineprivate

Finds the memory dependence entry in the hash map.

Definition at line 576 of file mem_dep_unit_impl.hh.

◆ hasLoadBarrier()

template<class MemDepPred , class Impl >
bool MemDepUnit< MemDepPred, Impl >::hasLoadBarrier ( ) const
inlineprivate

Is there an outstanding load barrier that loads must wait on.

Definition at line 269 of file mem_dep_unit.hh.

References MemDepUnit< MemDepPred, Impl >::loadBarrierSNs.

◆ hasStoreBarrier()

template<class MemDepPred , class Impl >
bool MemDepUnit< MemDepPred, Impl >::hasStoreBarrier ( ) const
inlineprivate

Is there an outstanding store barrier that loads must wait on.

Definition at line 272 of file mem_dep_unit.hh.

References MemDepUnit< MemDepPred, Impl >::storeBarrierSNs.

◆ init()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::init ( DerivO3CPUParams *  params,
ThreadID  tid 
)

Initializes the unit with parameters and a thread id.

Definition at line 95 of file mem_dep_unit_impl.hh.

References csprintf(), and DPRINTF.

Referenced by InstructionQueue< Impl >::InstructionQueue().

◆ insert()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::insert ( const DynInstPtr inst)

Inserts a memory instruction.

Definition at line 197 of file mem_dep_unit_impl.hh.

References DPRINTF, and panic.

◆ insertBarrier()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::insertBarrier ( const DynInstPtr barr_inst)

Inserts a barrier instruction.

Definition at line 330 of file mem_dep_unit_impl.hh.

◆ insertBarrierSN()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::insertBarrierSN ( const DynInstPtr barr_inst)
private

Inserts the SN of a barrier inst.

to the list of tracked barriers

Definition at line 171 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ insertNonSpec()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::insertNonSpec ( const DynInstPtr inst)

Inserts a non-speculative memory instruction.

Definition at line 308 of file mem_dep_unit_impl.hh.

References DPRINTF, and panic.

◆ isDrained()

template<class MemDepPred , class Impl >
bool MemDepUnit< MemDepPred, Impl >::isDrained

Determine if we are drained.

Definition at line 129 of file mem_dep_unit_impl.hh.

References ArmISA::i.

◆ issue()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::issue ( const DynInstPtr inst)

Issues the given instruction.

Definition at line 566 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ moveToReady()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::moveToReady ( MemDepEntryPtr ready_inst_entry)
inlineprivate

Moves an entry to the ready list.

Definition at line 587 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ name()

template<class MemDepPred , class Impl >
std::string MemDepUnit< MemDepPred, Impl >::name ( ) const
inline

Returns the name of the memory dependence unit.

Definition at line 99 of file mem_dep_unit.hh.

References MemDepUnit< MemDepPred, Impl >::_name.

◆ nonSpecInstReady()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::nonSpecInstReady ( const DynInstPtr inst)

Indicate that a non-speculative instruction is ready.

Definition at line 376 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ regsReady()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::regsReady ( const DynInstPtr inst)

Indicate that an instruction has its registers ready.

Definition at line 353 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ regStats()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::regStats

Registers statistics.

Definition at line 108 of file mem_dep_unit_impl.hh.

References name().

◆ replay()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::replay

Replays all instructions that have been rescheduled by moving them to the ready list.

Definition at line 396 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ reschedule()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::reschedule ( const DynInstPtr inst)

Reschedules an instruction to be re-executed.

Definition at line 389 of file mem_dep_unit_impl.hh.

◆ setIQ()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::setIQ ( InstructionQueue< Impl > *  iq_ptr)

Sets the pointer to the IQ.

Definition at line 164 of file mem_dep_unit_impl.hh.

Referenced by InstructionQueue< Impl >::InstructionQueue().

◆ squash()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::squash ( const InstSeqNum squashed_num,
ThreadID  tid 
)

Squashes all instructions up until a given sequence number for a specific thread.

Definition at line 502 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ takeOverFrom()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::takeOverFrom

Takes over from another CPU's thread.

Definition at line 154 of file mem_dep_unit_impl.hh.

◆ violation()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::violation ( const DynInstPtr store_inst,
const DynInstPtr violating_load 
)

Indicates an ordering violation between a store and a younger load.

Definition at line 554 of file mem_dep_unit_impl.hh.

References DPRINTF.

◆ wakeDependents()

template<class MemDepPred , class Impl >
void MemDepUnit< MemDepPred, Impl >::wakeDependents ( const DynInstPtr inst)
private

Wakes any dependents of a memory instruction.

Definition at line 464 of file mem_dep_unit_impl.hh.

References DPRINTF, and ArmISA::i.

Member Data Documentation

◆ _name

template<class MemDepPred , class Impl >
std::string MemDepUnit< MemDepPred, Impl >::_name
protected

Definition at line 83 of file mem_dep_unit.hh.

Referenced by MemDepUnit< MemDepPred, Impl >::name().

◆ conflictingLoads

template<class MemDepPred , class Impl >
Stats::Scalar MemDepUnit< MemDepPred, Impl >::conflictingLoads
private

Stat for number of conflicting loads that had to wait for a store.

Definition at line 288 of file mem_dep_unit.hh.

◆ conflictingStores

template<class MemDepPred , class Impl >
Stats::Scalar MemDepUnit< MemDepPred, Impl >::conflictingStores
private

Stat for number of conflicting stores that had to wait for a store.

Definition at line 290 of file mem_dep_unit.hh.

◆ depPred

template<class MemDepPred , class Impl >
MemDepPred MemDepUnit< MemDepPred, Impl >::depPred
private

The memory dependence predictor.

It is accessed upon new instructions being added to the IQ, and responds by telling this unit what instruction the newly added instruction is dependent upon.

Definition at line 260 of file mem_dep_unit.hh.

◆ id

template<class MemDepPred , class Impl >
int MemDepUnit< MemDepPred, Impl >::id
private

The thread id of this memory dependence unit.

Definition at line 281 of file mem_dep_unit.hh.

◆ insertedLoads

template<class MemDepPred , class Impl >
Stats::Scalar MemDepUnit< MemDepPred, Impl >::insertedLoads
private

Stat for number of inserted loads.

Definition at line 284 of file mem_dep_unit.hh.

◆ insertedStores

template<class MemDepPred , class Impl >
Stats::Scalar MemDepUnit< MemDepPred, Impl >::insertedStores
private

Stat for number of inserted stores.

Definition at line 286 of file mem_dep_unit.hh.

◆ instList

template<class MemDepPred , class Impl >
std::list<DynInstPtr> MemDepUnit< MemDepPred, Impl >::instList[Impl::MaxThreads]
private

A list of all instructions in the memory dependence unit.

Definition at line 250 of file mem_dep_unit.hh.

◆ instsToReplay

template<class MemDepPred , class Impl >
std::list<DynInstPtr> MemDepUnit< MemDepPred, Impl >::instsToReplay
private

A list of all instructions that are going to be replayed.

Definition at line 253 of file mem_dep_unit.hh.

◆ iqPtr

template<class MemDepPred , class Impl >
InstructionQueue<Impl>* MemDepUnit< MemDepPred, Impl >::iqPtr
private

Pointer to the IQ.

Definition at line 278 of file mem_dep_unit.hh.

◆ loadBarrierSNs

template<class MemDepPred , class Impl >
std::unordered_set<InstSeqNum> MemDepUnit< MemDepPred, Impl >::loadBarrierSNs
private

Sequence numbers of outstanding load barriers.

Definition at line 263 of file mem_dep_unit.hh.

Referenced by MemDepUnit< MemDepPred, Impl >::hasLoadBarrier().

◆ memDepHash

template<class MemDepPred , class Impl >
MemDepHash MemDepUnit< MemDepPred, Impl >::memDepHash
private

A hash map of all memory dependence entries.

Definition at line 247 of file mem_dep_unit.hh.

◆ storeBarrierSNs

template<class MemDepPred , class Impl >
std::unordered_set<InstSeqNum> MemDepUnit< MemDepPred, Impl >::storeBarrierSNs
private

Sequence numbers of outstanding store barriers.

Definition at line 266 of file mem_dep_unit.hh.

Referenced by MemDepUnit< MemDepPred, Impl >::hasStoreBarrier().


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

Generated on Wed Sep 30 2020 14:02:27 for gem5 by doxygen 1.8.17