Go to the documentation of this file.
42 #include "debug/CacheComp.hh"
44 #include "params/BaseCacheCompressor.hh"
75 return std::ceil(_size/8);
84 "64 must be a multiple of the chunk granularity.");
93 const unsigned num_chunks_per_64 =
98 for (
int i = 0;
i < chunks.size();
i++) {
99 const int index_64 = std::floor(
i / (
double)num_chunks_per_64);
100 const unsigned start =
i % num_chunks_per_64;
112 const unsigned num_chunks_per_64 =
117 for (
int i = 0;
i < chunks.size();
i++) {
118 const int index_64 = std::floor(
i / (
double)num_chunks_per_64);
119 const unsigned start =
i % num_chunks_per_64;
125 std::unique_ptr<Base::CompressionData>
129 std::unique_ptr<CompressionData> comp_data =
134 #ifdef DEBUG_COMPRESSION
135 uint64_t decomp_data[
blkSize/8];
142 "Decompressed line does not match original line.");
147 std::size_t comp_size_bits = comp_data->getSizeBits();
149 comp_size_bits =
blkSize * CHAR_BIT;
150 comp_data->setSizeBits(comp_size_bits);
157 if (comp_size_bits != 0) {
164 DPRINTF(CacheComp,
"Compressed cache line from %d to %d bits. " \
165 "Compression latency: %llu, decompression latency: %llu\n",
166 blkSize*8, comp_size_bits, comp_lat, decomp_lat);
179 DPRINTF(CacheComp,
"Decompressing block: %s (%d cycles)\n",
180 comp_blk->
print(), decomp_lat);
193 assert(blk !=
nullptr);
203 assert(blk !=
nullptr);
210 :
Stats::Group(&_compressor), compressor(_compressor),
211 compressions(this,
"compressions",
212 "Total number of compressions"),
213 failedCompressions(this,
"failed_compressions",
214 "Total number of failed compressions"),
215 compressionSize(this,
"compression_size",
216 "Number of blocks that were compressed to this power of two size"),
217 compressionSizeBits(this,
"compression_size_bits",
218 "Total compressed data size, in bits"),
219 avgCompressionSizeBits(this,
"avg_compression_size_bits",
220 "Average compression size, in bits"),
221 decompressions(this,
"total_decompressions",
222 "Total number of decompressions")
232 compressionSize.init(std::log2(compressor.blkSize*8) + 2);
233 compressionSize.subname(0,
"0");
234 compressionSize.subdesc(0,
235 "Number of blocks that compressed to fit in 0 bits");
236 for (
unsigned i = 0;
i <= std::log2(compressor.blkSize*8); ++
i) {
238 compressionSize.subname(1+
i, str_i);
239 compressionSize.subdesc(1+
i,
240 "Number of blocks that compressed to fit in " + str_i +
" bits");
244 avgCompressionSizeBits = compressionSizeBits / compressions;
const std::size_t sizeThreshold
Size in bytes at which a compression is classified as bad and therefore the compressed block is resto...
virtual void regStats()
Callback to set stat parameters.
void replaceBits(T &val, int first, int last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
CompressionData()
Default constructor.
const unsigned chunkSizeBits
Chunk size, in number of bits.
void regStats() override
Callback to set stat parameters.
Stats::Scalar failedCompressions
Number of failed compressions.
const std::size_t blkSize
Uncompressed cache line size (in bytes).
const std::string to_string(sc_enc enc)
virtual ~CompressionData()
Virtual destructor.
std::size_t getSizeBits() const
Get compression size (in bits).
void fromChunks(const std::vector< Chunk > &chunks, uint64_t *data) const
This function re-joins the chunks to recreate the original data.
Base cache compressor interface.
BaseStats(Base &compressor)
virtual std::unique_ptr< CompressionData > compress(const std::vector< Chunk > &chunks, Cycles &comp_lat, Cycles &decomp_lat)=0
Apply the compression process to the cache line.
Stats::Vector compressionSize
Number of blocks that were compressed to this power of two size.
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
BaseCacheCompressorParams Params
Cycles getDecompressionLatency() const
Get number of cycles needed to decompress this block.
bool isCompressed() const
Check if this block holds compressed data.
const FlagsType nozero
Don't print if this is zero.
Copyright (c) 2018 Inria All rights reserved.
std::vector< Chunk > toChunks(const uint64_t *data) const
This function splits the raw data into chunks, so that it can be parsed by the compressor.
Stats::Scalar compressions
Number of compressions performed.
Stats::Scalar compressionSizeBits
Total compressed data size, in number of bits.
std::size_t getSize() const
Get compression size (in bytes).
Cycles is a wrapper class for representing cycle counts, i.e.
Compressor::Base::BaseStats stats
Stats::Scalar decompressions
Number of decompressions performed.
void setSizeBits(std::size_t size)
Set compression size (in bits).
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
const FlagsType total
Print the total.
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
A superblock is composed of sub-blocks, and each sub-block has information regarding its superblock a...
const FlagsType nonan
Don't print if this is NAN.
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Abstract superclass for simulation objects.
Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17