42 #include "debug/CacheComp.hh" 44 #include "params/BaseCacheCompressor.hh" 73 return std::ceil(
_size/8);
85 Cycles& decomp_lat, std::size_t& comp_size_bits)
88 std::unique_ptr<CompressionData> comp_data =
89 compress(data, comp_lat, decomp_lat);
93 #ifdef DEBUG_COMPRESSION 94 uint64_t decomp_data[
blkSize/8];
101 "Decompressed line does not match original line.");
106 comp_size_bits = comp_data->getSizeBits();
117 DPRINTF(CacheComp,
"Compressed cache line from %d to %d bits. " \
118 "Compression latency: %llu, decompression latency: %llu\n",
119 blkSize*8, comp_size_bits, comp_lat, decomp_lat);
130 DPRINTF(CacheComp,
"Decompressing block: %s (%d cycles)\n",
131 comp_blk->
print(), decomp_lat);
144 assert(blk !=
nullptr);
154 assert(blk !=
nullptr);
162 :
Stats::
Group(&_compressor), compressor(_compressor),
163 compressions(this,
"compressions",
164 "Total number of compressions"),
165 compressionSize(this,
"compression_size",
166 "Number of blocks that were compressed to this power of two size"),
167 compressionSizeBits(this,
"compression_size_bits",
168 "Total compressed data size, in bits"),
169 avgCompressionSizeBits(this,
"avg_compression_size_bits",
170 "Average compression size, in bits"),
171 decompressions(this,
"total_decompressions",
172 "Total number of decompressions")
186 "Number of blocks that compressed to fit in " + str_i +
" bits");
virtual std::unique_ptr< CompressionData > compress(const uint64_t *cache_line, Cycles &comp_lat, Cycles &decomp_lat)=0
Apply the compression process to the cache line.
CompressionData()
Default constructor.
BaseCacheCompressor(const Params *p)
Default constructor.
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
Cycles is a wrapper class for representing cycle counts, i.e.
Stats::Scalar decompressions
Number of decompressions performed.
const std::size_t sizeThreshold
Size in bytes at which a compression is classified as bad and therefore the compressed block is resto...
const FlagsType nonan
Don't print if this is NAN.
Cycles getDecompressionLatency() const
Get number of cycles needed to decompress this block.
virtual void regStats()
Callback to set stat parameters.
Derived & subdesc(off_type index, const std::string &desc)
Set the subfield description for the given index and marks this stat to print at the end of simulatio...
Definition of a basic cache compressor.
Derived & flags(Flags _flags)
Set the flags and marks this stat to print at the end of simulation.
Stats::Scalar compressionSizeBits
Total compressed data size, in number of bits.
std::size_t getSizeBits() const
Get compression size (in bits).
Derived & init(size_type size)
Set this vector to have the given size.
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
Copyright (c) 2018 Inria All rights reserved.
const BaseCacheCompressor & compressor
const std::size_t blkSize
Uncompressed cache line size (in bytes).
A superblock is composed of sub-blocks, and each sub-block has information regarding its superblock a...
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
BaseCacheCompressor::BaseCacheCompressorStats stats
Base cache compressor interface.
const FlagsType total
Print the total.
Stats::Scalar compressions
Number of compressions performed.
Stats::Formula avgCompressionSizeBits
Average data size after compression, in number of bits.
bool isCompressed() const
Check if this block holds compressed data.
std::size_t _size
Compressed cache line size (in bits).
BaseCacheCompressorParams Params
Convenience typedef.
BaseCacheCompressorStats(BaseCacheCompressor &compressor)
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
void regStats() override
Callback to set stat parameters.
Stats::Vector compressionSize
Number of blocks that were compressed to this power of two size.
std::size_t getSize() const
Get compression size (in bytes).
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
void setSizeBits(std::size_t size)
Set compression size (in bits).
const FlagsType nozero
Don't print if this is zero.
Abstract superclass for simulation objects.
const std::string to_string(sc_enc enc)
virtual ~CompressionData()
Virtual destructor.
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.