gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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 (std::string_view name)
 Empty constructor - need to call init() later with all args.
 
 AssociativeCache (std::string_view 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 (std::string_view 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 62 of file associative_cache.hh.

Member Typedef Documentation

◆ BaseReplacementPolicy

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

Definition at line 69 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 307 of file associative_cache.hh.

◆ IndexingPolicy

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

Definition at line 70 of file associative_cache.hh.

◆ iterator

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

Definition at line 308 of file associative_cache.hh.

◆ KeyType

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

Definition at line 71 of file associative_cache.hh.

Constructor & Destructor Documentation

◆ AssociativeCache() [1/3]

template<typename Entry>
gem5::AssociativeCache< Entry >::AssociativeCache ( std::string_view name)
inline

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

Definition at line 106 of file associative_cache.hh.

◆ AssociativeCache() [2/3]

template<typename Entry>
gem5::AssociativeCache< Entry >::AssociativeCache ( std::string_view 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 117 of file associative_cache.hh.

◆ ~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

Definition at line 182 of file associative_cache.hh.

Referenced by gem5::AssociativeCache< StrideEntry >::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 198 of file associative_cache.hh.

◆ 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 315 of file associative_cache.hh.

◆ 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 336 of file associative_cache.hh.

◆ clear()

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

Clear the entries in the cache.

Definition at line 147 of file associative_cache.hh.

◆ 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 326 of file associative_cache.hh.

◆ 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 347 of file associative_cache.hh.

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

Definition at line 217 of file associative_cache.hh.

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

◆ findVictim()

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

Find a victim to be replaced.

Parameters
keykey to select the possible victim
Returns
entry to be victimized

Definition at line 237 of file associative_cache.hh.

Referenced by gem5::prefetch::Stride::calculatePrefetch().

◆ 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 291 of file associative_cache.hh.

◆ 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

Definition at line 155 of file associative_cache.hh.

◆ 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

Indicate that an entry has just been inserted.

Parameters
keykey of the container
entrypointer to the container entry to be inserted

Definition at line 272 of file associative_cache.hh.

Referenced by gem5::prefetch::Stride::calculatePrefetch().

◆ 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 260 of file associative_cache.hh.

Referenced by gem5::AssociativeCache< StrideEntry >::clear(), and gem5::AssociativeCache< StrideEntry >::findVictim().

◆ 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 170 of file associative_cache.hh.

Member Data Documentation

◆ associativity

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

Associativity of the cache.

Definition at line 74 of file associative_cache.hh.

◆ debugFlag

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

Definition at line 85 of file associative_cache.hh.

◆ entries

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

The entries.

Definition at line 83 of file associative_cache.hh.

◆ indexingPolicy

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

Indexing policy of the cache.

Definition at line 80 of file associative_cache.hh.

◆ replPolicy

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

The replacement policy of the cache.

Definition at line 77 of file associative_cache.hh.


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

Generated on Mon May 26 2025 09:19:18 for gem5 by doxygen 1.13.2