Go to the documentation of this file.
42 #include "debug/CacheComp.hh"
45 #include "params/BaseCacheCompressor.hh"
76 return std::ceil(_size/8);
89 "64 must be a multiple of the chunk granularity.");
92 "Compressor processes more chunks per cycle than the number of "
93 "chunks in the input");
95 "Decompressor processes more chunks per cycle than the number of "
96 "chunks in the input");
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;
131 const unsigned num_chunks_per_64 =
136 for (
int i = 0;
i < chunks.size();
i++) {
137 const int index_64 = std::floor(
i / (
double)num_chunks_per_64);
138 const unsigned start =
i % num_chunks_per_64;
144 std::unique_ptr<Base::CompressionData>
148 std::unique_ptr<CompressionData> comp_data =
153 #ifdef DEBUG_COMPRESSION
154 uint64_t decomp_data[
blkSize/8];
161 "Decompressed line does not match original line.");
166 std::size_t comp_size_bits = comp_data->getSizeBits();
168 comp_size_bits =
blkSize * CHAR_BIT;
169 comp_data->setSizeBits(comp_size_bits);
176 if (comp_size_bits != 0) {
183 DPRINTF(CacheComp,
"Compressed cache line from %d to %d bits. " \
184 "Compression latency: %llu, decompression latency: %llu\n",
185 blkSize*8, comp_size_bits, comp_lat, decomp_lat);
198 DPRINTF(CacheComp,
"Decompressing block: %s (%d cycles)\n",
199 comp_blk->
print(), decomp_lat);
212 assert(blk !=
nullptr);
222 assert(blk !=
nullptr);
229 :
Stats::Group(&_compressor), compressor(_compressor),
232 "Total number of failed compressions"),
234 "Number of blocks that were compressed to this power of two "
239 "Average compression size"),
250 compressionSize.init(std::log2(compressor.blkSize*8) + 2);
251 compressionSize.subname(0,
"0");
252 compressionSize.subdesc(0,
253 "Number of blocks that compressed to fit in 0 bits");
254 for (
unsigned i = 0;
i <= std::log2(compressor.blkSize*8); ++
i) {
256 compressionSize.subname(1+
i, str_i);
257 compressionSize.subdesc(1+
i,
258 "Number of blocks that compressed to fit in " + str_i +
" bits");
262 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.
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
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.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
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 Cycles compChunksPerCycle
Degree of parallelization of the compression process.
const FlagsType nozero
Don't print if this is zero.
#define UNIT_RATE(T1, T2)
Copyright (c) 2018 Inria All rights reserved.
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
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.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
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 Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
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...
virtual void setCache(BaseCache *_cache)
The cache can only be set once.
constexpr void replaceBits(T &val, unsigned first, unsigned last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
const FlagsType nonan
Don't print if this is NAN.
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
BaseCache * cache
Pointer to the parent cache.
Abstract superclass for simulation objects.
Generated on Tue Jun 22 2021 15:28:25 for gem5 by doxygen 1.8.17