From: Daniel R. Carvalho Date: Thu, 7 Nov 2019 10:27:49 +0000 (+0100) Subject: mem-cache: Upgrade Compressor::Multi's stats X-Git-Tag: v20.1.0.0~189 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8bb0e3749b083e1d2a1e887cb37fb750d3aa62d6;p=gem5.git mem-cache: Upgrade Compressor::Multi's stats Use new style stats API for Compressor::Multi's stats. Change-Id: Ia0313704cae4e7bd6bc675c71ea75b42a8e542f2 Signed-off-by: Daniel R. Carvalho Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33377 Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris Tested-by: kokoro --- diff --git a/src/mem/cache/compressors/multi.cc b/src/mem/cache/compressors/multi.cc index f42602e82..229c3b98e 100644 --- a/src/mem/cache/compressors/multi.cc +++ b/src/mem/cache/compressors/multi.cc @@ -37,6 +37,7 @@ #include #include "base/bitfield.hh" +#include "base/logging.hh" #include "base/trace.hh" #include "debug/CacheComp.hh" #include "params/MultiCompressor.hh" @@ -57,7 +58,8 @@ Multi::MultiCompData::getIndex() const } Multi::Multi(const Params *p) - : Base(p), compressors(p->compressors) + : Base(p), compressors(p->compressors), + multiStats(stats, *this) { fatal_if(compressors.size() == 0, "There must be at least one compressor"); } @@ -137,7 +139,7 @@ Multi::compress(const uint64_t* cache_line, Cycles& comp_lat, // Update compressor ranking stats for (int rank = 0; rank < compressors.size(); rank++) { - rankStats[results.top()->index][rank]++; + multiStats.ranks[results.top()->index][rank]++; results.pop(); } @@ -158,23 +160,26 @@ Multi::decompress(const CompressionData* comp_data, casted_comp_data->compData.get(), cache_line); } -void -Multi::regStats() +Multi::MultiStats::MultiStats(BaseStats& base_group, Multi& _compressor) + : Stats::Group(&base_group), compressor(_compressor), + ranks(this, "ranks", + "Number of times each compressor had the nth best compression") { - Base::regStats(); +} - rankStats - .init(compressors.size(), compressors.size()) - .name(name() + ".rank") - .desc("Number of times each compressor had the nth best compression.") - ; +void +Multi::MultiStats::regStats() +{ + Stats::Group::regStats(); - for (int compressor = 0; compressor < compressors.size(); compressor++) { - rankStats.subname(compressor, std::to_string(compressor)); - rankStats.subdesc(compressor, "Number of times compressor " + + const std::size_t num_compressors = compressor.compressors.size(); + ranks.init(num_compressors, num_compressors); + for (unsigned compressor = 0; compressor < num_compressors; compressor++) { + ranks.subname(compressor, std::to_string(compressor)); + ranks.subdesc(compressor, "Number of times compressor " + std::to_string(compressor) + " had the nth best compression."); - for (unsigned rank = 0; rank < compressors.size(); rank++) { - rankStats.ysubname(rank, std::to_string(rank)); + for (unsigned rank = 0; rank < num_compressors; rank++) { + ranks.ysubname(rank, std::to_string(rank)); } } } diff --git a/src/mem/cache/compressors/multi.hh b/src/mem/cache/compressors/multi.hh index db4f3767c..06af9785f 100644 --- a/src/mem/cache/compressors/multi.hh +++ b/src/mem/cache/compressors/multi.hh @@ -37,6 +37,7 @@ #include #include +#include "base/statistics.hh" #include "base/types.hh" #include "mem/cache/compressors/base.hh" @@ -57,25 +58,25 @@ class Multi : public Base /** List of sub-compressors. */ std::vector compressors; - /** - * @defgroup CompressionStats Compression specific statistics. - * @{ - */ + struct MultiStats : public Stats::Group + { + const Multi& compressor; - /** Number of times each compressor provided the nth best compression. */ - Stats::Vector2d rankStats; + MultiStats(BaseStats &base_group, Multi& _compressor); - /** - * @} - */ + void regStats() override; + + /** + * Number of times each compressor provided the nth best compression. + */ + Stats::Vector2d ranks; + } multiStats; public: typedef MultiCompressorParams Params; Multi(const Params *p); ~Multi(); - void regStats() override; - std::unique_ptr compress( const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat) override;