gem5  v22.1.0.0
Classes | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
gem5::o3::MemDepUnit Class 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...
 
struct  MemDepUnitStats
 

Public Member Functions

 MemDepUnit ()
 Empty constructor. More...
 
 MemDepUnit (const BaseO3CPUParams &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 (const BaseO3CPUParams &params, ThreadID tid, CPU *cpu)
 Initializes the unit with parameters and a thread id. 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 *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 [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...
 
StoreSet 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...
 
InstructionQueueiqPtr
 Pointer to the IQ. More...
 
int id
 The thread id of this memory dependence unit. More...
 
gem5::o3::MemDepUnit::MemDepUnitStats stats
 

Detailed Description

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 90 of file mem_dep_unit.hh.

Member Typedef Documentation

◆ ListIt

Definition at line 172 of file mem_dep_unit.hh.

◆ MemDepEntryPtr

typedef std::shared_ptr<MemDepEntry> gem5::o3::MemDepUnit::MemDepEntryPtr
private

Definition at line 176 of file mem_dep_unit.hh.

◆ MemDepHash

typedef std::unordered_map<InstSeqNum, MemDepEntryPtr, SNHash> gem5::o3::MemDepUnit::MemDepHash
private

Definition at line 226 of file mem_dep_unit.hh.

◆ MemDepHashIt

typedef MemDepHash::iterator gem5::o3::MemDepUnit::MemDepHashIt
private

Definition at line 228 of file mem_dep_unit.hh.

Constructor & Destructor Documentation

◆ MemDepUnit() [1/2]

gem5::o3::MemDepUnit::MemDepUnit ( )

Empty constructor.

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

Definition at line 55 of file mem_dep_unit.cc.

◆ MemDepUnit() [2/2]

gem5::o3::MemDepUnit::MemDepUnit ( const BaseO3CPUParams &  params)

Constructs a MemDepUnit with given parameters.

Definition at line 57 of file mem_dep_unit.cc.

References DPRINTF.

◆ ~MemDepUnit()

gem5::o3::MemDepUnit::~MemDepUnit ( )

Frees up any memory allocated.

Definition at line 67 of file mem_dep_unit.cc.

References instList, gem5::o3::MaxThreads, and memDepHash.

Member Function Documentation

◆ completed()

void gem5::o3::MemDepUnit::completed ( const DynInstPtr inst)
private

Completes a memory instruction.

Definition at line 405 of file mem_dep_unit.cc.

References DPRINTF, instList, and memDepHash.

Referenced by completeInst().

◆ completeInst()

void gem5::o3::MemDepUnit::completeInst ( const DynInstPtr inst)

Notifies completion of an instruction.

Definition at line 428 of file mem_dep_unit.cc.

References completed(), DPRINTF, hasLoadBarrier(), hasStoreBarrier(), loadBarrierSNs, storeBarrierSNs, and wakeDependents().

Referenced by gem5::o3::InstructionQueue::wakeDependents().

◆ drainSanityCheck()

void gem5::o3::MemDepUnit::drainSanityCheck ( ) const

Perform sanity checks after a drain.

Definition at line 132 of file mem_dep_unit.cc.

References gem5::ArmISA::i, instList, instsToReplay, gem5::o3::MaxThreads, and memDepHash.

◆ dumpLists()

void gem5::o3::MemDepUnit::dumpLists ( )

Debugging function to dump the lists of instructions.

Definition at line 614 of file mem_dep_unit.cc.

References gem5::cprintf(), instList, gem5::o3::MaxThreads, and memDepHash.

◆ findInHash()

MemDepUnit::MemDepEntryPtr & gem5::o3::MemDepUnit::findInHash ( const DynInstConstPtr inst)
private

Finds the memory dependence entry in the hash map.

Definition at line 592 of file mem_dep_unit.cc.

References memDepHash.

Referenced by nonSpecInstReady(), regsReady(), replay(), and wakeDependents().

◆ hasLoadBarrier()

bool gem5::o3::MemDepUnit::hasLoadBarrier ( ) const
inlineprivate

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

Definition at line 253 of file mem_dep_unit.hh.

References loadBarrierSNs.

Referenced by completeInst(), and insert().

◆ hasStoreBarrier()

bool gem5::o3::MemDepUnit::hasStoreBarrier ( ) const
inlineprivate

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

Definition at line 256 of file mem_dep_unit.hh.

References storeBarrierSNs.

Referenced by completeInst(), and insert().

◆ init()

void gem5::o3::MemDepUnit::init ( const BaseO3CPUParams &  params,
ThreadID  tid,
CPU cpu 
)

Initializes the unit with parameters and a thread id.

Definition at line 92 of file mem_dep_unit.cc.

References _name, gem5::statistics::Group::addStatGroup(), gem5::csprintf(), depPred, DPRINTF, gem5::o3::StoreSet::init(), and stats.

Referenced by gem5::o3::InstructionQueue::InstructionQueue().

◆ insert()

void gem5::o3::MemDepUnit::insert ( const DynInstPtr inst)

◆ insertBarrier()

void gem5::o3::MemDepUnit::insertBarrier ( const DynInstPtr barr_inst)

Inserts a barrier instruction.

Definition at line 323 of file mem_dep_unit.cc.

References insertBarrierSN(), instList, and memDepHash.

Referenced by gem5::o3::InstructionQueue::insertBarrier(), and insertNonSpec().

◆ insertBarrierSN()

void gem5::o3::MemDepUnit::insertBarrierSN ( const DynInstPtr barr_inst)
private

Inserts the SN of a barrier inst.

to the list of tracked barriers

Definition at line 158 of file mem_dep_unit.cc.

References DPRINTF, loadBarrierSNs, and storeBarrierSNs.

Referenced by insert(), and insertBarrier().

◆ insertNonSpec()

void gem5::o3::MemDepUnit::insertNonSpec ( const DynInstPtr inst)

◆ isDrained()

bool gem5::o3::MemDepUnit::isDrained ( ) const

Determine if we are drained.

Definition at line 120 of file mem_dep_unit.cc.

References gem5::ArmISA::i, instList, instsToReplay, gem5::o3::MaxThreads, and memDepHash.

◆ issue()

void gem5::o3::MemDepUnit::issue ( const DynInstPtr inst)

Issues the given instruction.

Definition at line 583 of file mem_dep_unit.cc.

References depPred, DPRINTF, and gem5::o3::StoreSet::issued().

Referenced by gem5::o3::InstructionQueue::scheduleReadyInsts().

◆ moveToReady()

void gem5::o3::MemDepUnit::moveToReady ( MemDepEntryPtr ready_inst_entry)
private

Moves an entry to the ready list.

Definition at line 602 of file mem_dep_unit.cc.

References gem5::o3::InstructionQueue::addReadyMemInst(), DPRINTF, and iqPtr.

Referenced by insert(), nonSpecInstReady(), regsReady(), replay(), and wakeDependents().

◆ name()

std::string gem5::o3::MemDepUnit::name ( ) const
inline

Returns the name of the memory dependence unit.

Definition at line 106 of file mem_dep_unit.hh.

References _name.

◆ nonSpecInstReady()

void gem5::o3::MemDepUnit::nonSpecInstReady ( const DynInstPtr inst)

Indicate that a non-speculative instruction is ready.

Definition at line 367 of file mem_dep_unit.cc.

References DPRINTF, findInHash(), and moveToReady().

Referenced by gem5::o3::InstructionQueue::scheduleNonSpec().

◆ regsReady()

void gem5::o3::MemDepUnit::regsReady ( const DynInstPtr inst)

Indicate that an instruction has its registers ready.

Definition at line 345 of file mem_dep_unit.cc.

References DPRINTF, findInHash(), and moveToReady().

Referenced by gem5::o3::InstructionQueue::addIfReady().

◆ replay()

void gem5::o3::MemDepUnit::replay ( )

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

Definition at line 385 of file mem_dep_unit.cc.

References DPRINTF, findInHash(), instsToReplay, and moveToReady().

Referenced by gem5::o3::InstructionQueue::replayMemInst().

◆ reschedule()

void gem5::o3::MemDepUnit::reschedule ( const DynInstPtr inst)

Reschedules an instruction to be re-executed.

Definition at line 379 of file mem_dep_unit.cc.

References instsToReplay.

Referenced by gem5::o3::InstructionQueue::rescheduleMemInst().

◆ setIQ()

void gem5::o3::MemDepUnit::setIQ ( InstructionQueue iq_ptr)

Sets the pointer to the IQ.

Definition at line 152 of file mem_dep_unit.cc.

References iqPtr.

Referenced by gem5::o3::InstructionQueue::InstructionQueue().

◆ squash()

void gem5::o3::MemDepUnit::squash ( const InstSeqNum squashed_num,
ThreadID  tid 
)

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

Definition at line 521 of file mem_dep_unit.cc.

References depPred, DPRINTF, instList, instsToReplay, loadBarrierSNs, memDepHash, gem5::o3::StoreSet::squash(), and storeBarrierSNs.

Referenced by gem5::o3::InstructionQueue::squash().

◆ takeOverFrom()

void gem5::o3::MemDepUnit::takeOverFrom ( )

Takes over from another CPU's thread.

Definition at line 143 of file mem_dep_unit.cc.

References gem5::o3::StoreSet::clear(), depPred, loadBarrierSNs, and storeBarrierSNs.

◆ violation()

void gem5::o3::MemDepUnit::violation ( const DynInstPtr store_inst,
const DynInstPtr violating_load 
)

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

Definition at line 571 of file mem_dep_unit.cc.

References depPred, DPRINTF, and gem5::o3::StoreSet::violation().

Referenced by gem5::o3::InstructionQueue::violation().

◆ wakeDependents()

void gem5::o3::MemDepUnit::wakeDependents ( const DynInstPtr inst)
private

Wakes any dependents of a memory instruction.

Definition at line 459 of file mem_dep_unit.cc.

References DPRINTF, findInHash(), gem5::ArmISA::i, and moveToReady().

Referenced by completeInst().

Member Data Documentation

◆ _name

std::string gem5::o3::MemDepUnit::_name
protected

Definition at line 93 of file mem_dep_unit.hh.

Referenced by init(), and name().

◆ depPred

StoreSet gem5::o3::MemDepUnit::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 244 of file mem_dep_unit.hh.

Referenced by init(), insert(), insertNonSpec(), issue(), squash(), takeOverFrom(), and violation().

◆ id

int gem5::o3::MemDepUnit::id
private

The thread id of this memory dependence unit.

Definition at line 265 of file mem_dep_unit.hh.

◆ instList

std::list<DynInstPtr> gem5::o3::MemDepUnit::instList[MaxThreads]
private

A list of all instructions in the memory dependence unit.

Definition at line 234 of file mem_dep_unit.hh.

Referenced by completed(), drainSanityCheck(), dumpLists(), insert(), insertBarrier(), isDrained(), squash(), and ~MemDepUnit().

◆ instsToReplay

std::list<DynInstPtr> gem5::o3::MemDepUnit::instsToReplay
private

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

Definition at line 237 of file mem_dep_unit.hh.

Referenced by drainSanityCheck(), isDrained(), replay(), reschedule(), and squash().

◆ iqPtr

InstructionQueue* gem5::o3::MemDepUnit::iqPtr
private

Pointer to the IQ.

Definition at line 262 of file mem_dep_unit.hh.

Referenced by moveToReady(), and setIQ().

◆ loadBarrierSNs

std::unordered_set<InstSeqNum> gem5::o3::MemDepUnit::loadBarrierSNs
private

Sequence numbers of outstanding load barriers.

Definition at line 247 of file mem_dep_unit.hh.

Referenced by completeInst(), hasLoadBarrier(), insert(), insertBarrierSN(), squash(), and takeOverFrom().

◆ memDepHash

MemDepHash gem5::o3::MemDepUnit::memDepHash
private

A hash map of all memory dependence entries.

Definition at line 231 of file mem_dep_unit.hh.

Referenced by completed(), drainSanityCheck(), dumpLists(), findInHash(), insert(), insertBarrier(), isDrained(), squash(), and ~MemDepUnit().

◆ stats

gem5::o3::MemDepUnit::MemDepUnitStats gem5::o3::MemDepUnit::stats
private

Referenced by init(), insert(), and insertNonSpec().

◆ storeBarrierSNs

std::unordered_set<InstSeqNum> gem5::o3::MemDepUnit::storeBarrierSNs
private

Sequence numbers of outstanding store barriers.

Definition at line 250 of file mem_dep_unit.hh.

Referenced by completeInst(), hasStoreBarrier(), insert(), insertBarrierSN(), squash(), and takeOverFrom().


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

Generated on Wed Dec 21 2022 10:24:18 for gem5 by doxygen 1.9.1