gem5 v24.1.0.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Attributes | Private Member Functions | List of all members
gem5::AssociativeCache< Entry > Class Template Reference

#include <associative_cache.hh>

Inheritance diagram for gem5::AssociativeCache< Entry >:
gem5::Named

Public Types

using const_iterator = typename std::vector< Entry >::const_iterator
 Iterator types.
 
using iterator = typename std::vector< Entry >::iterator
 

Public Member Functions

 AssociativeCache (const char *name)
 Empty constructor - need to call init() later with all args.
 
 AssociativeCache (const char *name, const size_t num_entries, const size_t associativity_, BaseReplacementPolicy *repl_policy, IndexingPolicy *indexing_policy, Entry const &init_val=Entry())
 Public constructor.
 
 ~AssociativeCache ()=default
 Default destructor.
 
 AssociativeCache (const AssociativeCache &)=delete
 Disable copy and assignment.
 
AssociativeCacheoperator= (const AssociativeCache &)=delete
 
void clear ()
 Clear the entries in the cache.
 
void init (const size_t num_entries, const size_t associativity_, BaseReplacementPolicy *_repl_policy, IndexingPolicy *_indexing_policy, Entry const &init_val=Entry())
 
void setDebugFlag (const ::gem5::debug::SimpleFlag &flag)
 
virtual Entry * accessEntry (const KeyType &key)
 Do an access to the entry if it exists.
 
virtual void accessEntry (Entry *entry)
 Update the replacement information for an entry.
 
virtual Entry * findEntry (const KeyType &key) const
 Find an entry within the set.
 
virtual Entry * findVictim (const KeyType &key)
 Find a victim to be replaced.
 
virtual void invalidate (Entry *entry)
 Invalidate an entry and its respective replacement data.
 
virtual void insertEntry (const KeyType &key, Entry *entry)
 Indicate that an entry has just been inserted.
 
std::vector< Entry * > getPossibleEntries (const KeyType &key) const
 Find the set of entries that could be replaced given that we want to add a new entry with the provided key.
 
iterator begin ()
 Returns an iterator to the first entry of the dictionary.
 
iterator end ()
 Returns an iterator pointing to the end of the the dictionary (placeholder element, should not be accessed)
 
const_iterator begin () const
 Returns an iterator to the first entry of the dictionary.
 
const_iterator end () const
 Returns an iterator pointing to the end of the the dictionary (placeholder element, should not be accessed)
 
- Public Member Functions inherited from gem5::Named
 Named (const std::string &name_)
 
virtual ~Named ()=default
 
virtual std::string name () const
 

Protected Types

typedef replacement_policy::Base BaseReplacementPolicy
 
typedef Entry::IndexingPolicy IndexingPolicy
 
typedef Entry::KeyType KeyType
 

Protected Attributes

size_t associativity
 Associativity of the cache.
 
BaseReplacementPolicyreplPolicy
 The replacement policy of the cache.
 
IndexingPolicyindexingPolicy
 Indexing policy of the cache.
 
std::vector< Entry > entries
 The entries.
 
const ::gem5::debug::SimpleFlagdebugFlag = nullptr
 

Private Member Functions

void initParams (size_t _num_entries, size_t _assoc)
 

Detailed Description

template<typename Entry>
class gem5::AssociativeCache< Entry >

Definition at line 61 of file associative_cache.hh.

Member Typedef Documentation

◆ BaseReplacementPolicy

template<typename Entry >
typedef replacement_policy::Base gem5::AssociativeCache< Entry >::BaseReplacementPolicy
protected

Definition at line 68 of file associative_cache.hh.

◆ const_iterator

template<typename Entry >
using gem5::AssociativeCache< Entry >::const_iterator = typename std::vector<Entry>::const_iterator

Iterator types.

Definition at line 299 of file associative_cache.hh.

◆ IndexingPolicy

template<typename Entry >
typedef Entry::IndexingPolicy gem5::AssociativeCache< Entry >::IndexingPolicy
protected

Definition at line 69 of file associative_cache.hh.

◆ iterator

template<typename Entry >
using gem5::AssociativeCache< Entry >::iterator = typename std::vector<Entry>::iterator

Definition at line 300 of file associative_cache.hh.

◆ KeyType

template<typename Entry >
typedef Entry::KeyType gem5::AssociativeCache< Entry >::KeyType
protected

Definition at line 70 of file associative_cache.hh.

Constructor & Destructor Documentation

◆ AssociativeCache() [1/3]

template<typename Entry >
gem5::AssociativeCache< Entry >::AssociativeCache ( const char *  name)
inline

Empty constructor - need to call init() later with all args.

Definition at line 105 of file associative_cache.hh.

◆ AssociativeCache() [2/3]

template<typename Entry >
gem5::AssociativeCache< Entry >::AssociativeCache ( const char *  name,
const size_t  num_entries,
const size_t  associativity_,
BaseReplacementPolicy repl_policy,
IndexingPolicy indexing_policy,
Entry const &  init_val = Entry() 
)
inline

Public constructor.

Parameters
nameName of the cache
num_entriestotal number of entries of the container, the number of sets can be calculated dividing this balue by the 'assoc' value
associativitynumber of elements in each associative set
repl_policyreplacement policy
indexing_policyindexing policy

Definition at line 116 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::associativity, and gem5::AssociativeCache< Entry >::initParams().

◆ ~AssociativeCache()

template<typename Entry >
gem5::AssociativeCache< Entry >::~AssociativeCache ( )
default

Default destructor.

◆ AssociativeCache() [3/3]

template<typename Entry >
gem5::AssociativeCache< Entry >::AssociativeCache ( const AssociativeCache< Entry > &  )
delete

Disable copy and assignment.

Member Function Documentation

◆ accessEntry() [1/2]

template<typename Entry >
virtual Entry * gem5::AssociativeCache< Entry >::accessEntry ( const KeyType key)
inlinevirtual

Do an access to the entry if it exists.

This is required to update the replacement information data.

Parameters
keykey to the entry
Returns
The entry if it exists

Reimplemented in gem5::ArmISA::TLB::Table.

Definition at line 181 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::accessEntry(), and gem5::AssociativeCache< Entry >::findEntry().

Referenced by gem5::AssociativeCache< Entry >::accessEntry(), and gem5::prefetch::Stride::calculatePrefetch().

◆ accessEntry() [2/2]

template<typename Entry >
virtual void gem5::AssociativeCache< Entry >::accessEntry ( Entry *  entry)
inlinevirtual

Update the replacement information for an entry.

Parameters
Entryto access and upate

Definition at line 197 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::replPolicy, and gem5::replacement_policy::Base::touch().

◆ begin() [1/2]

template<typename Entry >
iterator gem5::AssociativeCache< Entry >::begin ( )
inline

Returns an iterator to the first entry of the dictionary.

Returns
iterator to the first element

Definition at line 307 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::entries.

◆ begin() [2/2]

template<typename Entry >
const_iterator gem5::AssociativeCache< Entry >::begin ( ) const
inline

Returns an iterator to the first entry of the dictionary.

Returns
iterator to the first element

Definition at line 328 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::entries.

◆ clear()

template<typename Entry >
void gem5::AssociativeCache< Entry >::clear ( )
inline

Clear the entries in the cache.

Definition at line 146 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::entries, and gem5::AssociativeCache< Entry >::invalidate().

◆ end() [1/2]

template<typename Entry >
iterator gem5::AssociativeCache< Entry >::end ( )
inline

Returns an iterator pointing to the end of the the dictionary (placeholder element, should not be accessed)

Returns
iterator to the end element

Definition at line 318 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::entries.

◆ end() [2/2]

template<typename Entry >
const_iterator gem5::AssociativeCache< Entry >::end ( ) const
inline

Returns an iterator pointing to the end of the the dictionary (placeholder element, should not be accessed)

Returns
iterator to the end element

Definition at line 339 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::entries.

◆ findEntry()

template<typename Entry >
virtual Entry * gem5::AssociativeCache< Entry >::findEntry ( const KeyType key) const
inlinevirtual

Find an entry within the set.

Parameters
keykey element
Returns
returns a pointer to the wanted entry or nullptr if it does not exist.

Reimplemented in gem5::ArmISA::TLB::Table.

Definition at line 209 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::indexingPolicy.

Referenced by gem5::AssociativeCache< Entry >::accessEntry(), and gem5::prefetch::Stride::calculatePrefetch().

◆ findVictim()

template<typename Entry >
virtual Entry * gem5::AssociativeCache< Entry >::findVictim ( const KeyType key)
inlinevirtual

◆ getPossibleEntries()

template<typename Entry >
std::vector< Entry * > gem5::AssociativeCache< Entry >::getPossibleEntries ( const KeyType key) const
inline

Find the set of entries that could be replaced given that we want to add a new entry with the provided key.

Parameters
addrkey to select the set of entries
Returns
vector of candidates matching with the provided key

Definition at line 283 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::entries, and gem5::AssociativeCache< Entry >::indexingPolicy.

◆ init()

template<typename Entry >
void gem5::AssociativeCache< Entry >::init ( const size_t  num_entries,
const size_t  associativity_,
BaseReplacementPolicy _repl_policy,
IndexingPolicy _indexing_policy,
Entry const &  init_val = Entry() 
)
inline

◆ initParams()

template<typename Entry >
void gem5::AssociativeCache< Entry >::initParams ( size_t  _num_entries,
size_t  _assoc 
)
inlineprivate

◆ insertEntry()

template<typename Entry >
virtual void gem5::AssociativeCache< Entry >::insertEntry ( const KeyType key,
Entry *  entry 
)
inlinevirtual

◆ invalidate()

template<typename Entry >
virtual void gem5::AssociativeCache< Entry >::invalidate ( Entry *  entry)
inlinevirtual

Invalidate an entry and its respective replacement data.

Parameters
entryEntry to be invalidated.

Definition at line 252 of file associative_cache.hh.

References gem5::replacement_policy::Base::invalidate(), and gem5::AssociativeCache< Entry >::replPolicy.

Referenced by gem5::AssociativeCache< Entry >::clear(), gem5::AssociativeCache< Entry >::findVictim(), gem5::ArmISA::TLB::flush(), and gem5::ArmISA::TLB::flushAll().

◆ operator=()

template<typename Entry >
AssociativeCache & gem5::AssociativeCache< Entry >::operator= ( const AssociativeCache< Entry > &  )
delete

◆ setDebugFlag()

template<typename Entry >
void gem5::AssociativeCache< Entry >::setDebugFlag ( const ::gem5::debug::SimpleFlag flag)
inline

Definition at line 169 of file associative_cache.hh.

References gem5::AssociativeCache< Entry >::debugFlag.

Referenced by gem5::ArmISA::TLB::TLB().

Member Data Documentation

◆ associativity

template<typename Entry >
size_t gem5::AssociativeCache< Entry >::associativity
protected

Associativity of the cache.

Definition at line 73 of file associative_cache.hh.

Referenced by gem5::AssociativeCache< Entry >::AssociativeCache(), and gem5::AssociativeCache< Entry >::init().

◆ debugFlag

template<typename Entry >
const ::gem5::debug::SimpleFlag* gem5::AssociativeCache< Entry >::debugFlag = nullptr
protected

◆ entries

template<typename Entry >
std::vector<Entry> gem5::AssociativeCache< Entry >::entries
protected

◆ indexingPolicy

template<typename Entry >
IndexingPolicy* gem5::AssociativeCache< Entry >::indexingPolicy
protected

◆ replPolicy

template<typename Entry >
BaseReplacementPolicy* gem5::AssociativeCache< Entry >::replPolicy
protected

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

Generated on Mon Jan 13 2025 04:28:48 for gem5 by doxygen 1.9.8