gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::AssociativeCache< Entry > Class Template Reference

#include <associative_cache.hh>

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

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, BaseIndexingPolicy *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, BaseIndexingPolicy *_indexing_policy, Entry const &init_val=Entry())
 
virtual Addr getTag (const Addr addr) const
 Get the tag for the addr.
 
virtual Entry * accessEntryByAddr (const Addr addr)
 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 Addr addr) const
 Find an entry within the set.
 
virtual Entry * findVictim (const Addr addr)
 Find a victim to be replaced.
 
virtual void invalidate (Entry *entry)
 Invalidate an entry and its respective replacement data.
 
virtual void insertEntry (const Addr addr, Entry *entry)
 Indicate that an entry has just been inserted.
 
std::vector< Entry * > getPossibleEntries (const Addr addr) 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 Attributes

size_t associativity
 Associativity of the cache.
 
BaseReplacementPolicyreplPolicy
 The replacement policy of the cache.
 
BaseIndexingPolicyindexingPolicy
 Indexing policy of the cache.
 
std::vector< Entry > entries
 The entries.
 

Private Types

typedef replacement_policy::Base BaseReplacementPolicy
 

Private Member Functions

void initParams (size_t _num_entries, size_t _assoc)
 

Detailed Description

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

Definition at line 49 of file associative_cache.hh.

Member Typedef Documentation

◆ BaseReplacementPolicy

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

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

◆ iterator

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

Definition at line 278 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 89 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,
BaseIndexingPolicy * 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 100 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()

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

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

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

◆ accessEntryByAddr()

template<typename Entry >
virtual Entry * gem5::AssociativeCache< Entry >::accessEntryByAddr ( const Addr addr)
inlinevirtual

Do an access to the entry if it exists.

This is required to update the replacement information data.

Parameters
addrkey to the entry
Returns
The entry if it exists

Definition at line 169 of file associative_cache.hh.

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

◆ 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 285 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 306 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 129 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 296 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 317 of file associative_cache.hh.

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

◆ findEntry()

template<typename Entry >
virtual Entry * gem5::AssociativeCache< Entry >::findEntry ( const Addr addr) const
inlinevirtual

Find an entry within the set.

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

Definition at line 197 of file associative_cache.hh.

References gem5::X86ISA::addr, gem5::BaseIndexingPolicy::getPossibleEntries(), gem5::AssociativeCache< Entry >::getTag(), and gem5::AssociativeCache< Entry >::indexingPolicy.

Referenced by gem5::AssociativeCache< Entry >::accessEntryByAddr().

◆ findVictim()

template<typename Entry >
virtual Entry * gem5::AssociativeCache< Entry >::findVictim ( const Addr addr)
inlinevirtual

◆ getPossibleEntries()

template<typename Entry >
std::vector< Entry * > gem5::AssociativeCache< Entry >::getPossibleEntries ( const Addr addr) 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 261 of file associative_cache.hh.

References gem5::X86ISA::addr, gem5::AssociativeCache< Entry >::entries, gem5::BaseIndexingPolicy::getPossibleEntries(), and gem5::AssociativeCache< Entry >::indexingPolicy.

◆ getTag()

template<typename Entry >
virtual Addr gem5::AssociativeCache< Entry >::getTag ( const Addr addr) const
inlinevirtual

Get the tag for the addr.

Parameters
addrAddr to get the tag for
Returns
Tag for the address

Definition at line 157 of file associative_cache.hh.

References gem5::X86ISA::addr, gem5::BaseIndexingPolicy::extractTag(), and gem5::AssociativeCache< Entry >::indexingPolicy.

Referenced by gem5::AssociativeCache< Entry >::findEntry().

◆ init()

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

◆ initParams()

◆ insertEntry()

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

Indicate that an entry has just been inserted.

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

Definition at line 248 of file associative_cache.hh.

References gem5::X86ISA::addr, gem5::BaseIndexingPolicy::extractTag(), gem5::AssociativeCache< Entry >::indexingPolicy, gem5::AssociativeCache< Entry >::replPolicy, and gem5::replacement_policy::Base::reset().

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

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

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

◆ operator=()

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

Member Data Documentation

◆ associativity

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

Associativity of the cache.

Definition at line 59 of file associative_cache.hh.

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

◆ entries

◆ indexingPolicy

◆ replPolicy


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

Generated on Tue Jun 18 2024 16:24:09 for gem5 by doxygen 1.11.0