From: Hoa Nguyen Date: Thu, 22 Oct 2020 10:26:21 +0000 (-0700) Subject: mem,stats: Update stats style for FALRU X-Git-Tag: develop-gem5-snapshot~435 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83ad47415d5faaaa050d08ffb0169488a51e28f7;p=gem5.git mem,stats: Update stats style for FALRU Change-Id: I67a202eb974a31851fbbce0f15b5377ba726bc1c Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36475 Reviewed-by: Daniel Carvalho Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/mem/cache/tags/fa_lru.cc b/src/mem/cache/tags/fa_lru.cc index 79019fc76..e61a28017 100644 --- a/src/mem/cache/tags/fa_lru.cc +++ b/src/mem/cache/tags/fa_lru.cc @@ -63,7 +63,7 @@ FALRUBlk::print() const 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", @@ -106,13 +106,6 @@ FALRU::tagsInit() cacheTracking.init(head, tail); } -void -FALRU::regStats() -{ - BaseTags::regStats(); - cacheTracking.regStats(name()); -} - void FALRU::invalidate(CacheBlk *blk) { @@ -285,6 +278,51 @@ FALRU::moveToTail(FALRUBlk *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 { @@ -412,42 +450,3 @@ FALRU::CacheTracking::recordAccess(FALRUBlk *blk) 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"); - } -} diff --git a/src/mem/cache/tags/fa_lru.hh b/src/mem/cache/tags/fa_lru.hh index f24ac0e8c..1d7e45abf 100644 --- a/src/mem/cache/tags/fa_lru.hh +++ b/src/mem/cache/tags/fa_lru.hh @@ -161,11 +161,6 @@ class FALRU : public BaseTags */ void tagsInit() override; - /** - * Register the stats for this object. - */ - void regStats() override; - /** * Invalidate a cache block. * @param blk The block to invalidate. @@ -278,23 +273,11 @@ class FALRU : public BaseTags * 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 @@ -352,11 +335,6 @@ class FALRU : public BaseTags */ 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;