Go to the documentation of this file.
66 cacheTracking(
p->min_tracked_cache_size, size, blkSize)
69 fatal(
"cache block size (in bytes) `%d' must be a power of two",
72 fatal(
"Cache Size must be power of 2 for now");
120 auto num_erased M5_VAR_USED =
124 assert(num_erased == 1);
156 if (in_caches_mask) {
157 *in_caches_mask =
mask;
174 auto iter =
tagHash.find(std::make_pair(tag, is_secure));
176 blk = (*iter).second;
180 assert(blk->
tag == tag);
181 assert(blk->
isSecure() == is_secure);
202 evict_blks.push_back(victim);
236 assert(blk->
next ==
nullptr);
263 assert(blk->
prev ==
nullptr);
283 FALRUParams::create()
285 return new FALRU(
this);
293 unsigned curr_size = 0;
303 if (curr_size == tracked_cache_size && blk !=
tail) {
306 tracked_cache_size <<= 1;
308 in_caches_mask &= ~(1U <<
j);
313 #endif // FALRU_DEBUG
321 unsigned curr_size = 0;
322 unsigned tracked_cache_size = minTrackedSize;
330 if (curr_size == tracked_cache_size && blk !=
tail) {
333 tracked_cache_size <<= 1;
335 in_caches_mask &= ~(1U <<
j);
350 for (
int i = 0;
i < numTrackedCaches;
i++) {
352 if (current_cache_mask & update_caches_mask) {
356 boundaries[
i]->inCachesMask &= ~current_cache_mask;
357 boundaries[
i] = boundaries[
i]->prev;
358 }
else if (boundaries[
i] == blk) {
361 boundaries[
i] = blk->
prev;
374 for (
int i = 0;
i < numTrackedCaches;
i++) {
376 if (current_cache_mask & update_caches_mask) {
380 boundaries[
i] = boundaries[
i]->next;
381 if (boundaries[
i] == blk) {
384 boundaries[
i] = blk->
next;
397 for (
int i = 0;
i < numTrackedCaches;
i++) {
407 hits[numTrackedCaches]++;
409 misses[numTrackedCaches]++;
418 static const char *SIZES[] = {
"B",
"kB",
"MB",
"GB",
"TB",
"ZB" };
420 while (
size >= 1024 && div < (
sizeof SIZES /
sizeof *SIZES)) {
424 stream <<
size << SIZES[div];
431 .init(numTrackedCaches + 1)
432 .name(
name +
".falru_hits")
433 .desc(
"The number of hits in each cache size.")
436 .init(numTrackedCaches + 1)
437 .name(
name +
".falru_misses")
438 .desc(
"The number of misses in each cache size.")
441 .name(
name +
".falru_accesses")
442 .desc(
"The number of accesses to the FA LRU cache.")
445 for (
unsigned i = 0;
i < numTrackedCaches + 1; ++
i) {
446 std::stringstream size_str;
448 hits.subname(
i, size_str.str());
449 hits.subdesc(
i,
"Hits in a " + size_str.str() +
" cache");
450 misses.subname(
i, size_str.str());
451 misses.subdesc(
i,
"Misses in a " + size_str.str() +
" cache");
#define fatal(...)
This implements a cprintf based fatal() function.
A replaceable entry is a basic entry in a 2d table-like structure that needs to have replacement func...
virtual void regStats()
Callback to set stat parameters.
CacheTracking cacheTracking
FALRUBlk * head
The MRU block.
FALRUBlk * next
The next block in LRU order.
std::string print() const override
Pretty-print inCachesMask and other CacheBlk information.
const unsigned minTrackedSize
The smallest cache we are tracking.
void recordAccess(FALRUBlk *blk)
Notify of a block access.
CachesMask inCachesMask
A bit mask of the caches that fit this block.
CacheBlk * accessBlock(Addr addr, bool is_secure, Cycles &lat, CachesMask *in_cache_mask)
Access block and update replacement data.
FALRUBlk * tail
The LRU block.
void regStats(std::string name)
Register the stats for this object.
void insertBlock(const PacketPtr pkt, CacheBlk *blk) override
Insert the new block into the cache and update replacement data.
CacheBlk * findBlock(Addr addr, bool is_secure) const override
Find the block in the cache, do not update the replacement data.
const unsigned blkSize
The size of the cache block.
void moveToTail(FALRUBlk *blk)
Move a cache block to the LRU position.
const CachesMask inAllCachesMask
A mask for all cache being tracked.
void moveBlockToHead(FALRUBlk *blk)
Update boundaries as a block will be moved to the MRU.
A fully associative cache block.
void tagsInit() override
Initialize blocks as FALRUBlk instances.
void printSize(std::ostream &stream, size_t size)
virtual void setPosition(const uint32_t set, const uint32_t way)
Set both the set and way.
FALRUBlk * prev
The previous block in LRU order.
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.
std::string print() const override
Pretty-print tag, set and way, and interpret state bits to readable form including mapping to a MOESI...
void check(const FALRUBlk *head, const FALRUBlk *tail) const
Check that the tracking mechanism is in consistent state.
void moveBlockToTail(FALRUBlk *blk)
Update boundaries as a block will be moved to the LRU.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
TagHash tagHash
The address hash table.
std::vector< FALRUBlk * > boundaries
Array of pointers to blocks at the cache boundaries.
void invalidate(CacheBlk *blk) override
Invalidate a cache block.
Addr tag
Data block tag value.
virtual const std::string name() const
void init(FALRUBlk *head, FALRUBlk *tail)
Initialiaze cache blocks and the tracking mechanism.
bool isValid() const
Checks that a block is valid.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
uint8_t * data
Contains a copy of the data in this block for easy access.
void moveToHead(FALRUBlk *blk)
Move a cache block to the MRU position.
void regStats() override
Register the stats for this object.
FALRUBlk * blks
The cache blocks.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Cycles is a wrapper class for representing cycle counts, i.e.
Addr extractTag(Addr addr) const override
Generate the tag from the addres.
A fully associative LRU cache.
FALRU(const Params *p)
Construct and initialize this cache tagstore.
bool isPowerOf2(const T &n)
std::string csprintf(const char *format, const Args &...args)
bool isSecure() const
Check if this block holds data from the secure memory space.
ReplaceableEntry * findBlockBySetAndWay(int set, int way) const override
Find a block given set and way.
Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17