From c85c793499f18b59e2af25c6d838bcd4490c3af9 Mon Sep 17 00:00:00 2001 From: "Daniel R. Carvalho" Date: Thu, 7 Nov 2019 11:04:14 +0100 Subject: [PATCH] mem-cache: Upgrade BaseDictionaryCompressor's stats Upgrade this compressor's stats to match current stats API. Change-Id: I1cb69230f8deca053bc860cedafc9e6e78446df7 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33376 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- .../compressors/base_dictionary_compressor.cc | 31 +++++++++++-------- .../compressors/dictionary_compressor.hh | 22 ++++++------- .../compressors/dictionary_compressor_impl.hh | 2 +- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/mem/cache/compressors/base_dictionary_compressor.cc b/src/mem/cache/compressors/base_dictionary_compressor.cc index d6af8ee77..ebbfc1c6f 100644 --- a/src/mem/cache/compressors/base_dictionary_compressor.cc +++ b/src/mem/cache/compressors/base_dictionary_compressor.cc @@ -37,26 +37,31 @@ namespace Compressor { BaseDictionaryCompressor::BaseDictionaryCompressor(const Params *p) - : Base(p), dictionarySize(p->dictionary_size), numEntries(0) + : Base(p), dictionarySize(p->dictionary_size), + numEntries(0), dictionaryStats(stats, *this) +{ +} + +BaseDictionaryCompressor::DictionaryStats::DictionaryStats( + BaseStats& base_group, BaseDictionaryCompressor& _compressor) + : Stats::Group(&base_group), compressor(_compressor), + patterns(this, "pattern", + "Number of data entries that were compressed to this pattern") { } void -BaseDictionaryCompressor::regStats() +BaseDictionaryCompressor::DictionaryStats::regStats() { - Base::regStats(); + Stats::Group::regStats(); // We store the frequency of each pattern - patternStats - .init(getNumPatterns()) - .name(name() + ".pattern") - .desc("Number of data entries that were compressed to this pattern.") - ; - - for (unsigned i = 0; i < getNumPatterns(); ++i) { - patternStats.subname(i, getName(i)); - patternStats.subdesc(i, "Number of data entries that match pattern " + - getName(i)); + patterns.init(compressor.getNumPatterns()); + for (unsigned i = 0; i < compressor.getNumPatterns(); ++i) { + const std::string name = compressor.getName(i); + patterns.subname(i, name); + patterns.subdesc(i, "Number of data entries that match pattern " + + name); } } diff --git a/src/mem/cache/compressors/dictionary_compressor.hh b/src/mem/cache/compressors/dictionary_compressor.hh index b9c68a1d6..b5e9e673e 100644 --- a/src/mem/cache/compressors/dictionary_compressor.hh +++ b/src/mem/cache/compressors/dictionary_compressor.hh @@ -51,6 +51,7 @@ #include #include +#include "base/statistics.hh" #include "base/types.hh" #include "mem/cache/compressors/base.hh" @@ -67,17 +68,18 @@ class BaseDictionaryCompressor : public Base /** Number of valid entries in the dictionary. */ std::size_t numEntries; - /** - * @defgroup CompressionStats Compression specific statistics. - * @{ - */ + struct DictionaryStats : public Stats::Group + { + const BaseDictionaryCompressor& compressor; - /** Number of data entries that were compressed to each pattern. */ - Stats::Vector patternStats; + DictionaryStats(BaseStats &base_group, + BaseDictionaryCompressor& _compressor); - /** - * @} - */ + void regStats() override; + + /** Number of data entries that were compressed to each pattern. */ + Stats::Vector patterns; + } dictionaryStats; /** * Trick function to get the number of patterns. @@ -98,8 +100,6 @@ class BaseDictionaryCompressor : public Base typedef BaseDictionaryCompressorParams Params; BaseDictionaryCompressor(const Params *p); ~BaseDictionaryCompressor() = default; - - void regStats() override; }; /** diff --git a/src/mem/cache/compressors/dictionary_compressor_impl.hh b/src/mem/cache/compressors/dictionary_compressor_impl.hh index 0b486e3f8..6b6e5fbc6 100644 --- a/src/mem/cache/compressors/dictionary_compressor_impl.hh +++ b/src/mem/cache/compressors/dictionary_compressor_impl.hh @@ -104,7 +104,7 @@ DictionaryCompressor::compressValue(const T data) } // Update stats - patternStats[pattern->getPatternNumber()]++; + dictionaryStats.patterns[pattern->getPatternNumber()]++; // Push into dictionary if (pattern->shouldAllocate()) { -- 2.30.2