gem5  v22.1.0.0
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gem5::ruby::CacheMemory Class Reference

#include <CacheMemory.hh>

Inheritance diagram for gem5::ruby::CacheMemory:
gem5::SimObject gem5::EventManager gem5::Serializable gem5::Drainable gem5::statistics::Group gem5::Named

Classes

struct  CacheMemoryStats
 

Public Types

typedef RubyCacheParams Params
 
typedef std::shared_ptr< replacement_policy::ReplacementDataReplData
 
- Public Types inherited from gem5::SimObject
typedef SimObjectParams Params
 

Public Member Functions

 CacheMemory (const Params &p)
 
 ~CacheMemory ()
 
void init ()
 init() is called after all C++ SimObjects have been created and all ports are connected. More...
 
bool tryCacheAccess (Addr address, RubyRequestType type, DataBlock *&data_ptr)
 
bool testCacheAccess (Addr address, RubyRequestType type, DataBlock *&data_ptr)
 
bool isTagPresent (Addr address) const
 
bool cacheAvail (Addr address) const
 
AbstractCacheEntrygetNullEntry () const
 
AbstractCacheEntryallocate (Addr address, AbstractCacheEntry *new_entry)
 
void allocateVoid (Addr address, AbstractCacheEntry *new_entry)
 
void deallocate (Addr address)
 
Addr cacheProbe (Addr address) const
 
AbstractCacheEntrylookup (Addr address)
 
const AbstractCacheEntrylookup (Addr address) const
 
Cycles getTagLatency () const
 
Cycles getDataLatency () const
 
bool isBlockInvalid (int64_t cache_set, int64_t loc)
 
bool isBlockNotBusy (int64_t cache_set, int64_t loc)
 
void recordCacheContents (int cntrl, CacheRecorder *tr) const
 
void setMRU (Addr address)
 
void setMRU (Addr addr, int occupancy)
 
void setMRU (AbstractCacheEntry *entry)
 
int getReplacementWeight (int64_t set, int64_t loc)
 
void setLocked (Addr addr, int context)
 
void clearLocked (Addr addr)
 
void clearLockedAll (int context)
 
bool isLocked (Addr addr, int context)
 
void print (std::ostream &out) const
 
void printData (std::ostream &out) const
 
bool checkResourceAvailable (CacheResourceType res, Addr addr)
 
void recordRequestType (CacheRequestType requestType, Addr addr)
 
void htmAbortTransaction ()
 
void htmCommitTransaction ()
 
int getCacheSize () const
 
int getCacheAssoc () const
 
int getNumBlocks () const
 
Addr getAddressAtIdx (int idx) const
 
void profileDemandHit ()
 
void profileDemandMiss ()
 
void profilePrefetchHit ()
 
void profilePrefetchMiss ()
 
- 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
 

Private Member Functions

int64_t addressToCacheSet (Addr address) const
 
int findTagInSet (int64_t line, Addr tag) const
 
int findTagInSetIgnorePermissions (int64_t cacheSet, Addr tag) const
 
 CacheMemory (const CacheMemory &obj)
 
CacheMemoryoperator= (const CacheMemory &obj)
 

Private Attributes

bool m_is_instruction_only_cache
 
std::unordered_map< Addr, int > m_tag_index
 
std::vector< std::vector< AbstractCacheEntry * > > m_cache
 
replacement_policy::Basem_replacementPolicy_ptr
 We use the replacement policies from the Classic memory system. More...
 
BankedArray dataArray
 
BankedArray tagArray
 
int m_cache_size
 
int m_cache_num_sets
 
int m_cache_num_set_bits
 
int m_cache_assoc
 
int m_start_index_bit
 
bool m_resource_stalls
 
int m_block_size
 
std::vector< std::vector< ReplData > > replacement_data
 We store all the ReplacementData in a 2-dimensional array. More...
 
bool m_use_occupancy
 Set to true when using WeightedLRU replacement policy, otherwise, set to false. More...
 
gem5::ruby::CacheMemory::CacheMemoryStats cacheMemoryStats
 

Additional Inherited Members

- 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...
 
- 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...
 

Detailed Description

Definition at line 69 of file CacheMemory.hh.

Member Typedef Documentation

◆ Params

typedef RubyCacheParams gem5::ruby::CacheMemory::Params

Definition at line 72 of file CacheMemory.hh.

◆ ReplData

Definition at line 73 of file CacheMemory.hh.

Constructor & Destructor Documentation

◆ CacheMemory() [1/2]

gem5::ruby::CacheMemory::CacheMemory ( const Params p)

◆ ~CacheMemory()

gem5::ruby::CacheMemory::~CacheMemory ( )

◆ CacheMemory() [2/2]

gem5::ruby::CacheMemory::CacheMemory ( const CacheMemory obj)
private

Member Function Documentation

◆ addressToCacheSet()

int64_t gem5::ruby::CacheMemory::addressToCacheSet ( Addr  address) const
private

◆ allocate()

AbstractCacheEntry * gem5::ruby::CacheMemory::allocate ( Addr  address,
AbstractCacheEntry new_entry 
)

◆ allocateVoid()

void gem5::ruby::CacheMemory::allocateVoid ( Addr  address,
AbstractCacheEntry new_entry 
)
inline

Definition at line 105 of file CacheMemory.hh.

References allocate().

◆ cacheAvail()

bool gem5::ruby::CacheMemory::cacheAvail ( Addr  address) const

◆ cacheProbe()

Addr gem5::ruby::CacheMemory::cacheProbe ( Addr  address) const

◆ checkResourceAvailable()

bool gem5::ruby::CacheMemory::checkResourceAvailable ( CacheResourceType  res,
Addr  addr 
)

◆ clearLocked()

void gem5::ruby::CacheMemory::clearLocked ( Addr  addr)

Definition at line 488 of file CacheMemory.cc.

References gem5::ruby::AbstractCacheEntry::clearLocked(), DPRINTF, and lookup().

◆ clearLockedAll()

void gem5::ruby::CacheMemory::clearLockedAll ( int  context)

◆ deallocate()

void gem5::ruby::CacheMemory::deallocate ( Addr  address)

◆ findTagInSet()

int gem5::ruby::CacheMemory::findTagInSet ( int64_t  line,
Addr  tag 
) const
private

Definition at line 136 of file CacheMemory.cc.

References m_cache, m_tag_index, and gem5::ruby::makeLineAddress().

Referenced by lookup().

◆ findTagInSetIgnorePermissions()

int gem5::ruby::CacheMemory::findTagInSetIgnorePermissions ( int64_t  cacheSet,
Addr  tag 
) const
private

Definition at line 151 of file CacheMemory.cc.

References m_tag_index, and gem5::ruby::makeLineAddress().

◆ getAddressAtIdx()

Addr gem5::ruby::CacheMemory::getAddressAtIdx ( int  idx) const

◆ getCacheAssoc()

int gem5::ruby::CacheMemory::getCacheAssoc ( ) const
inline

Definition at line 158 of file CacheMemory.hh.

References m_cache_assoc.

◆ getCacheSize()

int gem5::ruby::CacheMemory::getCacheSize ( ) const
inline

Definition at line 157 of file CacheMemory.hh.

References m_cache_size.

◆ getDataLatency()

Cycles gem5::ruby::CacheMemory::getDataLatency ( ) const
inline

Definition at line 121 of file CacheMemory.hh.

References dataArray, and gem5::ruby::BankedArray::getLatency().

◆ getNullEntry()

AbstractCacheEntry* gem5::ruby::CacheMemory::getNullEntry ( ) const
inline

Definition at line 98 of file CacheMemory.hh.

◆ getNumBlocks()

int gem5::ruby::CacheMemory::getNumBlocks ( ) const
inline

Definition at line 159 of file CacheMemory.hh.

References m_cache_assoc, and m_cache_num_sets.

Referenced by gem5::ruby::VIPERCoalescer::invTCP().

◆ getReplacementWeight()

int gem5::ruby::CacheMemory::getReplacementWeight ( int64_t  set,
int64_t  loc 
)

Definition at line 401 of file CacheMemory.cc.

References m_cache, m_cache_assoc, m_cache_num_sets, and gem5::ArmISA::set.

◆ getTagLatency()

Cycles gem5::ruby::CacheMemory::getTagLatency ( ) const
inline

Definition at line 120 of file CacheMemory.hh.

References gem5::ruby::BankedArray::getLatency(), and tagArray.

◆ htmAbortTransaction()

void gem5::ruby::CacheMemory::htmAbortTransaction ( )

◆ htmCommitTransaction()

void gem5::ruby::CacheMemory::htmCommitTransaction ( )

◆ init()

void gem5::ruby::CacheMemory::init ( )
virtual

init() is called after all C++ SimObjects have been created and all ports are connected.

Initializations that are independent of unserialization but rely on a fully instantiated and connected SimObject graph should be done here.

Reimplemented from gem5::SimObject.

Definition at line 90 of file CacheMemory.cc.

References gem5::floorLog2(), gem5::ruby::RubySystem::getBlockSizeBytes(), gem5::ArmISA::i, gem5::replacement_policy::Base::instantiateEntry(), gem5::ArmISA::j, m_block_size, m_cache, m_cache_assoc, m_cache_num_set_bits, m_cache_num_sets, m_cache_size, m_replacementPolicy_ptr, and replacement_data.

◆ isBlockInvalid()

bool gem5::ruby::CacheMemory::isBlockInvalid ( int64_t  cache_set,
int64_t  loc 
)

Definition at line 673 of file CacheMemory.cc.

References m_cache.

◆ isBlockNotBusy()

bool gem5::ruby::CacheMemory::isBlockNotBusy ( int64_t  cache_set,
int64_t  loc 
)

Definition at line 679 of file CacheMemory.cc.

References m_cache.

◆ isLocked()

bool gem5::ruby::CacheMemory::isLocked ( Addr  addr,
int  context 
)

◆ isTagPresent()

bool gem5::ruby::CacheMemory::isTagPresent ( Addr  address) const

Definition at line 231 of file CacheMemory.cc.

References DPRINTF, and lookup().

Referenced by allocate().

◆ lookup() [1/2]

AbstractCacheEntry * gem5::ruby::CacheMemory::lookup ( Addr  address)

◆ lookup() [2/2]

const AbstractCacheEntry * gem5::ruby::CacheMemory::lookup ( Addr  address) const

◆ operator=()

CacheMemory& gem5::ruby::CacheMemory::operator= ( const CacheMemory obj)
private

◆ print()

void gem5::ruby::CacheMemory::print ( std::ostream &  out) const

◆ printData()

void gem5::ruby::CacheMemory::printData ( std::ostream &  out) const

Definition at line 473 of file CacheMemory.cc.

◆ profileDemandHit()

void gem5::ruby::CacheMemory::profileDemandHit ( )

◆ profileDemandMiss()

void gem5::ruby::CacheMemory::profileDemandMiss ( )

◆ profilePrefetchHit()

void gem5::ruby::CacheMemory::profilePrefetchHit ( )

◆ profilePrefetchMiss()

void gem5::ruby::CacheMemory::profilePrefetchMiss ( )

◆ recordCacheContents()

void gem5::ruby::CacheMemory::recordCacheContents ( int  cntrl,
CacheRecorder tr 
) const

◆ recordRequestType()

void gem5::ruby::CacheMemory::recordRequestType ( CacheRequestType  requestType,
Addr  addr 
)

◆ setLocked()

void gem5::ruby::CacheMemory::setLocked ( Addr  addr,
int  context 
)

Definition at line 479 of file CacheMemory.cc.

References DPRINTF, lookup(), and gem5::ruby::AbstractCacheEntry::setLocked().

◆ setMRU() [1/3]

void gem5::ruby::CacheMemory::setMRU ( AbstractCacheEntry entry)

◆ setMRU() [2/3]

void gem5::ruby::CacheMemory::setMRU ( Addr  addr,
int  occupancy 
)

◆ setMRU() [3/3]

void gem5::ruby::CacheMemory::setMRU ( Addr  address)

◆ testCacheAccess()

bool gem5::ruby::CacheMemory::testCacheAccess ( Addr  address,
RubyRequestType  type,
DataBlock *&  data_ptr 
)

◆ tryCacheAccess()

bool gem5::ruby::CacheMemory::tryCacheAccess ( Addr  address,
RubyRequestType  type,
DataBlock *&  data_ptr 
)

Member Data Documentation

◆ cacheMemoryStats

gem5::ruby::CacheMemory::CacheMemoryStats gem5::ruby::CacheMemory::cacheMemoryStats
private

◆ dataArray

BankedArray gem5::ruby::CacheMemory::dataArray
private

Definition at line 187 of file CacheMemory.hh.

Referenced by checkResourceAvailable(), getDataLatency(), and recordRequestType().

◆ m_block_size

int gem5::ruby::CacheMemory::m_block_size
private

Definition at line 196 of file CacheMemory.hh.

Referenced by CacheMemory(), and init().

◆ m_cache

std::vector<std::vector<AbstractCacheEntry*> > gem5::ruby::CacheMemory::m_cache
private

◆ m_cache_assoc

int gem5::ruby::CacheMemory::m_cache_assoc
private

◆ m_cache_num_set_bits

int gem5::ruby::CacheMemory::m_cache_num_set_bits
private

Definition at line 192 of file CacheMemory.hh.

Referenced by addressToCacheSet(), and init().

◆ m_cache_num_sets

int gem5::ruby::CacheMemory::m_cache_num_sets
private

◆ m_cache_size

int gem5::ruby::CacheMemory::m_cache_size
private

Definition at line 190 of file CacheMemory.hh.

Referenced by CacheMemory(), getCacheSize(), and init().

◆ m_is_instruction_only_cache

bool gem5::ruby::CacheMemory::m_is_instruction_only_cache
private

Definition at line 177 of file CacheMemory.hh.

Referenced by CacheMemory(), and recordCacheContents().

◆ m_replacementPolicy_ptr

replacement_policy::Base* gem5::ruby::CacheMemory::m_replacementPolicy_ptr
private

We use the replacement policies from the Classic memory system.

Definition at line 185 of file CacheMemory.hh.

Referenced by allocate(), CacheMemory(), cacheProbe(), deallocate(), init(), setMRU(), testCacheAccess(), tryCacheAccess(), and ~CacheMemory().

◆ m_resource_stalls

bool gem5::ruby::CacheMemory::m_resource_stalls
private

Definition at line 195 of file CacheMemory.hh.

Referenced by CacheMemory(), checkResourceAvailable(), and recordRequestType().

◆ m_start_index_bit

int gem5::ruby::CacheMemory::m_start_index_bit
private

Definition at line 194 of file CacheMemory.hh.

Referenced by addressToCacheSet(), and CacheMemory().

◆ m_tag_index

std::unordered_map<Addr, int> gem5::ruby::CacheMemory::m_tag_index
private

Definition at line 181 of file CacheMemory.hh.

Referenced by allocate(), deallocate(), findTagInSet(), and findTagInSetIgnorePermissions().

◆ m_use_occupancy

bool gem5::ruby::CacheMemory::m_use_occupancy
private

Set to true when using WeightedLRU replacement policy, otherwise, set to false.

Definition at line 212 of file CacheMemory.hh.

Referenced by CacheMemory(), and setMRU().

◆ replacement_data

std::vector<std::vector<ReplData> > gem5::ruby::CacheMemory::replacement_data
private

We store all the ReplacementData in a 2-dimensional array.

By doing this, we can use all replacement policies from Classic system. Ruby cache will deallocate cache entry every time we evict the cache block so we cannot store the ReplacementData inside the cache entry. Instantiate ReplacementData for multiple times will break replacement policy like TreePLRU.

Definition at line 206 of file CacheMemory.hh.

Referenced by allocate(), and init().

◆ tagArray

BankedArray gem5::ruby::CacheMemory::tagArray
private

Definition at line 188 of file CacheMemory.hh.

Referenced by checkResourceAvailable(), getTagLatency(), and recordRequestType().


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

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