43 #include "debug/CacheComp.hh"
46 #include "params/BaseCacheCompressor.hh"
82 return std::ceil(_size/8);
95 "64 must be a multiple of the chunk granularity.");
98 "Compressor processes more chunks per cycle than the number of "
99 "chunks in the input");
101 "Decompressor processes more chunks per cycle than the number of "
102 "chunks in the input");
118 const unsigned num_chunks_per_64 =
123 for (
int i = 0;
i < chunks.size();
i++) {
124 const int index_64 = std::floor(
i / (
double)num_chunks_per_64);
125 const unsigned start =
i % num_chunks_per_64;
137 const unsigned num_chunks_per_64 =
142 for (
int i = 0;
i < chunks.size();
i++) {
143 const int index_64 = std::floor(
i / (
double)num_chunks_per_64);
144 const unsigned start =
i % num_chunks_per_64;
150 std::unique_ptr<Base::CompressionData>
154 std::unique_ptr<CompressionData> comp_data =
159 #ifdef DEBUG_COMPRESSION
160 uint64_t decomp_data[
blkSize/8];
167 "Decompressed line does not match original line.");
172 std::size_t comp_size_bits = comp_data->getSizeBits();
174 comp_size_bits =
blkSize * CHAR_BIT;
175 comp_data->setSizeBits(comp_size_bits);
182 if (comp_size_bits != 0) {
189 DPRINTF(CacheComp,
"Compressed cache line from %d to %d bits. " \
190 "Compression latency: %llu, decompression latency: %llu\n",
191 blkSize*8, comp_size_bits, comp_lat, decomp_lat);
204 DPRINTF(CacheComp,
"Decompressing block: %s (%d cycles)\n",
205 comp_blk->
print(), decomp_lat);
218 assert(blk !=
nullptr);
228 assert(blk !=
nullptr);
235 : statistics::
Group(&_compressor), compressor(_compressor),
237 "Total number of compressions"),
238 ADD_STAT(failedCompressions, statistics::units::
Count::get(),
239 "Total number of failed compressions"),
241 "Number of blocks that were compressed to this power of two "
243 ADD_STAT(compressionSizeBits, statistics::units::Bit::get(),
244 "Total compressed data size"),
245 ADD_STAT(avgCompressionSizeBits, statistics::units::Rate<
246 statistics::units::Bit, statistics::units::
Count>::get(),
247 "Average compression size"),
249 "Total number of decompressions")
259 compressionSize.init(std::log2(compressor.blkSize*8) + 2);
260 compressionSize.subname(0,
"0");
261 compressionSize.subdesc(0,
262 "Number of blocks that compressed to fit in 0 bits");
263 for (
unsigned i = 0;
i <= std::log2(compressor.blkSize*8); ++
i) {
265 compressionSize.subname(1+
i, str_i);
266 compressionSize.subdesc(1+
i,
267 "Number of blocks that compressed to fit in " + str_i +
" bits");
272 avgCompressionSizeBits = compressionSizeBits / compressions;
A superblock is composed of sub-blocks, and each sub-block has information regarding its superblock a...
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
bool isCompressed() const
Check if this block holds compressed data.
Cycles getDecompressionLatency() const
Get number of cycles needed to decompress this block.
Cycles is a wrapper class for representing cycle counts, i.e.
Abstract superclass for simulation objects.
virtual ~CompressionData()
Virtual destructor.
CompressionData()
Default constructor.
std::size_t getSize() const
Get compression size (in bytes).
void setSizeBits(std::size_t size)
Set compression size (in bits).
std::size_t getSizeBits() const
Get compression size (in bits).
Base cache compressor interface.
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
BaseCacheCompressorParams Params
void fromChunks(const std::vector< Chunk > &chunks, uint64_t *data) const
This function re-joins the chunks to recreate the original data.
gem5::compression::Base::BaseStats stats
BaseCache * cache
Pointer to the parent cache.
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.
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
const Cycles compChunksPerCycle
Degree of parallelization of the compression process.
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.
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
const std::size_t blkSize
Uncompressed cache line size (in bytes).
virtual void setCache(BaseCache *_cache)
The cache can only be set once.
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.
const unsigned chunkSizeBits
Chunk size, in number of bits.
const std::size_t sizeThreshold
Size in bytes at which a compression is classified as bad and therefore the compressed block is resto...
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
const Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
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.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
virtual void regStats()
Callback to set stat parameters.
Declares a basic cache interface BaseCache.
Definition of a basic cache compressor.
const FlagsType nonan
Don't print if this is NAN.
const FlagsType nozero
Don't print if this is zero.
const FlagsType total
Print the total.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
const std::string to_string(sc_enc enc)
statistics::Scalar compressions
Number of compressions performed.
void regStats() override
Callback to set stat parameters.
BaseStats(Base &compressor)
statistics::Scalar decompressions
Number of decompressions performed.
statistics::Vector compressionSize
Number of blocks that were compressed to this power of two size.
statistics::Scalar failedCompressions
Number of failed compressions.
statistics::Scalar compressionSizeBits
Total compressed data size, in number of bits.
Copyright (c) 2018 Inria All rights reserved.