#include <queue>
#include "base/bitfield.hh"
+#include "base/logging.hh"
#include "base/trace.hh"
#include "debug/CacheComp.hh"
#include "params/MultiCompressor.hh"
}
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");
}
// 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();
}
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));
}
}
}
#include <cstdint>
#include <vector>
+#include "base/statistics.hh"
#include "base/types.hh"
#include "mem/cache/compressors/base.hh"
/** List of sub-compressors. */
std::vector<Base*> 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<Base::CompressionData> compress(
const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat) override;