cxx_header = "mem/cache/compressors/base.hh"
block_size = Param.Int(Parent.cache_line_size, "Block size in bytes")
+ size_threshold = Param.Unsigned(Parent.cache_line_size, "Minimum size, "
+ "in bytes, in which a block must be compressed to. Otherwise it is "
+ "stored in its uncompressed state")
class BDI(BaseCacheCompressor):
type = 'BDI'
}
BaseCacheCompressor::BaseCacheCompressor(const Params *p)
- : SimObject(p), blkSize(p->block_size)
+ : SimObject(p), blkSize(p->block_size), sizeThreshold(p->size_threshold)
{
+ fatal_if(blkSize < sizeThreshold, "Compressed data must fit in a block");
}
void
"Decompressed line does not match original line.");
#endif
- // Get compression size
+ // Get compression size. If compressed size is greater than the size
+ // threshold, the compression is seen as unsuccessful
comp_size_bits = comp_data->getSizeBits();
+ if (comp_size_bits >= sizeThreshold * 8) {
+ comp_size_bits = blkSize * 8;
+ }
// Update stats
compressionSize[std::ceil(std::log2(comp_size_bits))]++;
{
SimObject::regStats();
- // We also store when compression is bigger than original block size
compressionSize
- .init(std::log2(blkSize*8) + 2)
+ .init(std::log2(blkSize*8) + 1)
.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) {
+ for (unsigned i = 0; i <= std::log2(blkSize*8); ++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");
*/
const std::size_t blkSize;
+ /**
+ * Size in bytes at which a compression is classified as bad and therefore
+ * the compressed block is restored to its uncompressed format.
+ */
+ const std::size_t sizeThreshold;
+
/**
* @defgroup CompressionStats Compression specific statistics.
* @{