46 :
SectorSubBlk(), _size(0), _decompressionLatency(0), _compressed(false)
64 if (other.isCompressed()) {
104 const uint8_t compression_factor =
111 const uint8_t num_valid = superblock->
getNumValid();
112 assert(num_valid >= 1);
113 if (num_valid == 1) {
114 if (compression_factor != 1) {
166 return csprintf(
"%s compressed: %d size: %llu decompression latency: %d",
172 :
SectorBlk(), blkSize(0), compressionFactor(1)
186 for (
const auto& blk :
blks) {
187 if (blk->isValid() && (blk != ignored_blk)) {
219 const std::size_t blk_size_bits = CHAR_BIT *
blkSize;
220 const std::size_t compression_factor = (size > blk_size_bits) ? 1 :
221 ((size == 0) ? blk_size_bits :
223 return std::min(compression_factor,
blks.size());
CacheBlk & operator=(const CacheBlk &)=delete
virtual void invalidate()
Invalidate the block.
A superblock is composed of sub-blocks, and each sub-block has information regarding its superblock a...
CompressionBlk & operator=(const CompressionBlk &)=delete
void setCompressed()
Set compression bit.
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
std::size_t getSizeBits() const
void setUncompressed()
Clear compression bit.
void setSizeBits(const std::size_t size)
Set size, in bits, of this compressed block's data.
bool isCompressed() const
Check if this block holds compressed data.
Cycles _decompressionLatency
Number of cycles needed to decompress this block.
std::size_t _size
Set size, in bits, of this compressed block's data.
void setDecompressionLatency(const Cycles lat)
Set number of cycles needed to decompress this block.
OverwriteType
When an overwrite happens, the data size may change an not fit in its current container any longer.
@ UNCHANGED
New and old contents are considered of similar sizes.
@ DATA_EXPANSION
New data contents are considered larger than previous contents.
@ DATA_CONTRACTION
New data contents are considered smaller than previous contents.
Cycles getDecompressionLatency() const
Get number of cycles needed to decompress this block.
OverwriteType checkExpansionContraction(const std::size_t size) const
Determines if changing the size of the block will cause a data expansion (new size is bigger) or cont...
void invalidate() override
Invalidate the block and clear all state.
bool _compressed
Compression bit.
Cycles is a wrapper class for representing cycle counts, i.e.
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
std::string print() const override
Print relevant information for this sector block and its sub-blocks.
uint8_t getNumValid() const
Get the number of sub-blocks that have been validated.
A sector is composed of sub-blocks, and each sub-block has information regarding its sector and a poi...
void invalidate() override
Invalidate the block and inform sector block.
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
SectorBlk * getSectorBlock() const
Get sector block associated to this block.
A basic compression superblock.
std::size_t blkSize
Block size, in bytes.
std::string print() const override
Print relevant information for this sector block and its sub-blocks.
void setCompressionFactor(const uint8_t compression_factor)
Set the compression factor of this superblock.
bool isCompressed(const CompressionBlk *ignored_blk=nullptr) const
Returns whether the superblock contains compressed blocks or not.
void setBlkSize(const std::size_t blk_size)
Set block size.
void invalidate() override
Invalidate the block.
bool canCoAllocate(const std::size_t compressed_size) const
Checks whether a superblock can co-allocate given compressed data block.
uint8_t compressionFactor
Superblock's compression factor.
uint8_t calculateCompressionFactor(const std::size_t size) const
Calculate the compression factor (cf) given a compressed size and the maximum compression ratio.
uint8_t getCompressionFactor() const
Get the compression factor of this superblock.
constexpr uint64_t alignToPowerOfTwo(uint64_t val)
Align to the next highest power of two.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::string csprintf(const char *format, const Args &...args)
Copyright (c) 2018 Inria All rights reserved.