#include <algorithm>
#include <cstdint>
+#include <string>
#include "debug/CacheComp.hh"
#include "mem/cache/tags/super_blk.hh"
// Get compression size
comp_size_bits = comp_data->getSizeBits();
+ // Update stats
+ compressionSize[std::ceil(std::log2(comp_size_bits))]++;
+
// Print debug information
DPRINTF(CacheComp, "Compressed cache line from %d to %d bits. " \
"Compression latency: %llu, decompression latency: %llu\n",
static_cast<CompressionBlk*>(blk)->setSizeBits(size_bits);
}
+void
+BaseCacheCompressor::regStats()
+{
+ SimObject::regStats();
+
+ // We also store when compression is bigger than original block size
+ compressionSize
+ .init(std::log2(blkSize*8) + 2)
+ .name(name() + ".compression_size")
+ .desc("Number of blocks that were compressed to this power of" \
+ "two size.")
+ ;
+
+ for (unsigned i = 0; i <= std::log2(blkSize*8) + 1; ++i) {
+ compressionSize.subname(i, std::to_string(1 << i));
+ compressionSize.subdesc(i, "Number of blocks that compressed to fit " \
+ "in " + std::to_string(1 << i) + " bits");
+ }
+}
+
#include <cstdint>
+#include "base/statistics.hh"
#include "base/types.hh"
#include "sim/sim_object.hh"
*/
const std::size_t blkSize;
+ /**
+ * @defgroup CompressionStats Compression specific statistics.
+ * @{
+ */
+
+ /** Number of blocks that were compressed to this power of two size. */
+ Stats::Vector compressionSize;
+
+ /**
+ * @}
+ */
+
/**
* Apply the compression process to the cache line.
* Returns the number of cycles used by the compressor, however it is
* @param size_bits The block size.
*/
static void setSizeBits(CacheBlk* blk, const std::size_t size_bits);
+
+ /**
+ * Register local statistics.
+ */
+ void regStats() override;
};
class BaseCacheCompressor::CompressionData {