Go to the documentation of this file.
70 cacheTracking(
p.min_tracked_cache_size, size, blkSize, this)
73 fatal(
"cache block size (in bytes) `%d' must be a power of two",
76 fatal(
"Cache Size must be power of 2 for now");
117 [[maybe_unused]]
auto num_erased =
121 assert(num_erased == 1);
154 if (in_caches_mask) {
155 *in_caches_mask =
mask;
172 auto iter =
tagHash.find(std::make_pair(tag, is_secure));
174 blk = (*iter).second;
178 assert(blk->
getTag() == tag);
179 assert(blk->
isSecure() == is_secure);
200 evict_blks.push_back(victim);
229 panic(
"Moving blocks in FALRU has not been implemented");
240 assert(blk->
next ==
nullptr);
267 assert(blk->
prev ==
nullptr);
289 static const char *SIZES[] = {
"B",
"kB",
"MB",
"GB",
"TB",
"ZB" };
291 while (size >= 1024 &&
div < (
sizeof SIZES /
sizeof *SIZES)) {
295 stream << size << SIZES[
div];
300 : statistics::
Group(parent),
302 minTrackedSize(min_size),
303 numTrackedCaches(max_size > min_size ?
305 inAllCachesMask(
mask(numTrackedCaches)),
306 boundaries(numTrackedCaches),
308 "The number of hits in each cache size."),
310 "The number of misses in each cache size."),
312 "The number of accesses to the FA LRU cache.")
315 "Not enough bits (%s) in type CachesMask type to keep "
325 std::stringstream size_str;
328 hits.
subdesc(
i,
"Hits in a " + size_str.str() +
" cache");
339 unsigned curr_size = 0;
340 unsigned tracked_cache_size = minTrackedSize;
349 if (curr_size == tracked_cache_size && blk !=
tail) {
350 panic_if(boundaries[
j] != blk,
"Unexpected boundary for the %d-th "
352 tracked_cache_size <<= 1;
354 in_caches_mask &= ~(1U <<
j);
359 #endif // FALRU_DEBUG
367 unsigned curr_size = 0;
368 unsigned tracked_cache_size = minTrackedSize;
376 if (curr_size == tracked_cache_size && blk !=
tail) {
379 tracked_cache_size <<= 1;
381 in_caches_mask &= ~(1U <<
j);
396 for (
int i = 0;
i < numTrackedCaches;
i++) {
398 if (current_cache_mask & update_caches_mask) {
402 boundaries[
i]->inCachesMask &= ~current_cache_mask;
403 boundaries[
i] = boundaries[
i]->prev;
404 }
else if (boundaries[
i] == blk) {
407 boundaries[
i] = blk->
prev;
420 for (
int i = 0;
i < numTrackedCaches;
i++) {
422 if (current_cache_mask & update_caches_mask) {
426 boundaries[
i] = boundaries[
i]->next;
427 if (boundaries[
i] == blk) {
430 boundaries[
i] = blk->
next;
443 for (
int i = 0;
i < numTrackedCaches;
i++) {
453 hits[numTrackedCaches]++;
455 misses[numTrackedCaches]++;
#define fatal(...)
This implements a cprintf based fatal() function.
statistics::Vector hits
Hits in each cache.
ReplaceableEntry * findBlockBySetAndWay(int set, int way) const override
Find a block given set and way.
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
const int numTrackedCaches
The number of different size caches being tracked.
static constexpr std::enable_if_t< std::is_integral_v< T >, int > floorLog2(T x)
void moveToHead(FALRUBlk *blk)
Move a cache block to the MRU position.
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation.
std::string print() const override
Pretty-print inCachesMask and other CacheBlk information.
FALRU(const Params &p)
Construct and initialize this cache tagstore.
virtual Addr getTag() const
Get tag associated to this block.
void invalidate(CacheBlk *blk) override
Invalidate a cache block.
std::string csprintf(const char *format, const Args &...args)
static constexpr bool isPowerOf2(const T &n)
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
const unsigned minTrackedSize
The smallest cache we are tracking.
Cycles is a wrapper class for representing cycle counts, i.e.
statistics::Vector misses
Misses in each cache.
FALRUBlk * blks
The cache blocks.
CacheBlk * findBlock(Addr addr, bool is_secure) const override
Find the block in the cache, do not update the replacement data.
void recordAccess(FALRUBlk *blk)
Notify of a block access.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Derived & subdesc(off_type index, const std::string &desc)
Set the subfield description for the given index and marks this stat to print at the end of simulatio...
void init(FALRUBlk *head, FALRUBlk *tail)
Initialiaze cache blocks and the tracking mechanism.
void moveBlockToHead(FALRUBlk *blk)
Update boundaries as a block will be moved to the MRU.
Addr extractTag(Addr addr) const override
Generate the tag from the addres.
std::string print() const override
Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI...
FALRUBlk * head
The MRU block.
CachesMask inCachesMask
A bit mask of the caches that fit this block.
CacheTracking cacheTracking
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void printSize(std::ostream &stream, size_t size)
FALRUBlk * next
The next block in LRU order.
uint8_t * data
Contains a copy of the data in this block for easy access.
CacheBlk * accessBlock(const PacketPtr pkt, Cycles &lat, CachesMask *in_cache_mask)
Access block and update replacement data.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
TagHash tagHash
The address hash table.
void moveBlock(CacheBlk *src_blk, CacheBlk *dest_blk) override
Move a block's metadata to another location decided by the replacement policy.
FALRUBlk * tail
The LRU block.
FALRUBlk * prev
The previous block in LRU order.
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
void moveBlockToTail(FALRUBlk *blk)
Update boundaries as a block will be moved to the LRU.
void insertBlock(const PacketPtr pkt, CacheBlk *blk) override
Insert the new block into the cache and update replacement data.
CacheBlk * findVictim(Addr addr, const bool is_secure, const std::size_t size, std::vector< CacheBlk * > &evict_blks) override
Find replacement victim based on address.
bool isSecure() const
Check if this block holds data from the secure memory space.
void moveToTail(FALRUBlk *blk)
Move a cache block to the LRU position.
CacheTracking(unsigned min_size, unsigned max_size, unsigned block_size, statistics::Group *parent)
void check(const FALRUBlk *head, const FALRUBlk *tail) const
Check that the tracking mechanism is in consistent state.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
void tagsInit() override
Initialize blocks as FALRUBlk instances.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Derived & init(size_type size)
Set this vector to have the given size.
A fully associative cache block.
virtual bool isValid() const
Checks if the entry is valid.
#define panic(...)
This implements a cprintf based panic() function.
Generated on Sun Jul 30 2023 01:56:57 for gem5 by doxygen 1.8.17