mem,stats: Update stats style for FALRU
Change-Id: I67a202eb974a31851fbbce0f15b5377ba726bc1c Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36475 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
93
src/mem/cache/tags/fa_lru.cc
vendored
93
src/mem/cache/tags/fa_lru.cc
vendored
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
26
src/mem/cache/tags/fa_lru.hh
vendored
26
src/mem/cache/tags/fa_lru.hh
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user