FALRU::FALRU(const Params &p)
: BaseTags(p),
- cacheTracking(p.min_tracked_cache_size, size, blkSize)
+ cacheTracking(p.min_tracked_cache_size, size, blkSize, this)
{
if (!isPowerOf2(blkSize))
fatal("cache block size (in bytes) `%d' must be a power of two",
cacheTracking.init(head, tail);
}
-void
-FALRU::regStats()
-{
- BaseTags::regStats();
- cacheTracking.regStats(name());
-}
-
void
FALRU::invalidate(CacheBlk *blk)
{
}
}
+void
+printSize(std::ostream &stream, size_t size)
+{
+ static const char *SIZES[] = { "B", "kB", "MB", "GB", "TB", "ZB" };
+ int div = 0;
+ while (size >= 1024 && div < (sizeof SIZES / sizeof *SIZES)) {
+ div++;
+ size >>= 10;
+ }
+ stream << size << SIZES[div];
+}
+
+FALRU::CacheTracking::CacheTracking(unsigned min_size, unsigned max_size,
+ unsigned block_size, Stats::Group *parent)
+ : Stats::Group(parent),
+ blkSize(block_size),
+ minTrackedSize(min_size),
+ numTrackedCaches(max_size > min_size ?
+ floorLog2(max_size) - floorLog2(min_size) : 0),
+ inAllCachesMask(mask(numTrackedCaches)),
+ boundaries(numTrackedCaches),
+ ADD_STAT(hits, "The number of hits in each cache size."),
+ ADD_STAT(misses, "The number of misses in each cache size."),
+ ADD_STAT(accesses, "The number of accesses to the FA LRU cache.")
+{
+ fatal_if(numTrackedCaches > sizeof(CachesMask) * 8,
+ "Not enough bits (%s) in type CachesMask type to keep "
+ "track of %d caches\n", sizeof(CachesMask),
+ numTrackedCaches);
+
+ hits
+ .init(numTrackedCaches + 1);
+ misses
+ .init(numTrackedCaches + 1);
+
+ for (unsigned i = 0; i < numTrackedCaches + 1; ++i) {
+ std::stringstream size_str;
+ printSize(size_str, minTrackedSize << i);
+ hits.subname(i, size_str.str());
+ hits.subdesc(i, "Hits in a " + size_str.str() + " cache");
+ misses.subname(i, size_str.str());
+ misses.subdesc(i, "Misses in a " + size_str.str() + " cache");
+ }
+}
+
void
FALRU::CacheTracking::check(const FALRUBlk *head, const FALRUBlk *tail) const
{
accesses++;
}
-void
-printSize(std::ostream &stream, size_t size)
-{
- static const char *SIZES[] = { "B", "kB", "MB", "GB", "TB", "ZB" };
- int div = 0;
- while (size >= 1024 && div < (sizeof SIZES / sizeof *SIZES)) {
- div++;
- size >>= 10;
- }
- stream << size << SIZES[div];
-}
-
-void
-FALRU::CacheTracking::regStats(std::string name)
-{
- hits
- .init(numTrackedCaches + 1)
- .name(name + ".falru_hits")
- .desc("The number of hits in each cache size.")
- ;
- misses
- .init(numTrackedCaches + 1)
- .name(name + ".falru_misses")
- .desc("The number of misses in each cache size.")
- ;
- accesses
- .name(name + ".falru_accesses")
- .desc("The number of accesses to the FA LRU cache.")
- ;
-
- for (unsigned i = 0; i < numTrackedCaches + 1; ++i) {
- std::stringstream size_str;
- printSize(size_str, minTrackedSize << i);
- hits.subname(i, size_str.str());
- hits.subdesc(i, "Hits in a " + size_str.str() + " cache");
- misses.subname(i, size_str.str());
- misses.subdesc(i, "Misses in a " + size_str.str() + " cache");
- }
-}
*/
void tagsInit() override;
- /**
- * Register the stats for this object.
- */
- void regStats() override;
-
/**
* Invalidate a cache block.
* @param blk The block to invalidate.
* caches from a set minimum size of interest up to the actual
* cache size.
*/
- class CacheTracking
+ class CacheTracking : public Stats::Group
{
public:
CacheTracking(unsigned min_size, unsigned max_size,
- unsigned block_size)
- : blkSize(block_size),
- minTrackedSize(min_size),
- numTrackedCaches(max_size > min_size ?
- floorLog2(max_size) - floorLog2(min_size) : 0),
- inAllCachesMask(mask(numTrackedCaches)),
- boundaries(numTrackedCaches)
- {
- fatal_if(numTrackedCaches > sizeof(CachesMask) * 8,
- "Not enough bits (%s) in type CachesMask type to keep "
- "track of %d caches\n", sizeof(CachesMask),
- numTrackedCaches);
- }
+ unsigned block_size, Stats::Group *parent);
/**
* Initialiaze cache blocks and the tracking mechanism
*/
void check(const FALRUBlk *head, const FALRUBlk *tail) const;
- /**
- * Register the stats for this object.
- */
- void regStats(std::string name);
-
private:
/** The size of the cache block */
const unsigned blkSize;