42 #include "debug/CacheComp.hh"
43 #include "params/MultiCompressor.hh"
53 std::unique_ptr<Base::CompressionData> comp_data)
86 compressor->setCache(_cache);
90 std::unique_ptr<Base::CompressionData>
97 std::unique_ptr<Base::CompressionData> compData;
99 uint8_t compressionFactor;
101 Results(
unsigned index,
102 std::unique_ptr<Base::CompressionData> comp_data,
103 Cycles decomp_lat, std::size_t blk_size)
104 :
index(
index), compData(std::move(comp_data)),
105 decompLat(decomp_lat)
107 const std::size_t size = compData->getSize();
117 compressionFactor = (size > blk_size) ? 1 :
118 ((size == 0) ? blk_size :
122 struct ResultsComparator
125 operator()(
const std::shared_ptr<Results>& lhs,
126 const std::shared_ptr<Results>& rhs)
const
128 const std::size_t lhs_cf = lhs->compressionFactor;
129 const std::size_t rhs_cf = rhs->compressionFactor;
131 if (lhs_cf == rhs_cf) {
134 return lhs->decompLat > rhs->decompLat;
136 return lhs_cf < rhs_cf;
147 std::priority_queue<std::shared_ptr<Results>,
152 auto temp_comp_data =
154 temp_comp_data->setSizeBits(temp_comp_data->getSizeBits() +
156 results.push(std::make_shared<Results>(
i, std::move(temp_comp_data),
158 max_comp_lat = std::max(max_comp_lat, comp_lat);
162 const unsigned best_index = results.top()->index;
163 std::unique_ptr<CompressionData> multi_comp_data =
164 std::unique_ptr<MultiCompData>(
165 new MultiCompData(best_index, std::move(results.top()->compData)));
166 DPRINTF(CacheComp,
"Best compressor: %d\n", best_index);
172 for (
int rank = 0; rank <
compressors.size(); rank++) {
181 return multi_comp_data;
186 uint64_t* cache_line)
191 casted_comp_data->
compData.get(), cache_line);
195 : statistics::
Group(&base_group), compressor(_compressor),
197 "Number of times each compressor had the nth best compression")
206 const std::size_t num_compressors = compressor.compressors.size();
207 ranks.init(num_compressors, num_compressors);
208 for (
unsigned compressor = 0; compressor < num_compressors; compressor++) {
210 ranks.subdesc(compressor,
"Number of times compressor " +
212 for (
unsigned rank = 0; rank < num_compressors; rank++) {
Cycles is a wrapper class for representing cycle counts, i.e.
void setSizeBits(std::size_t size)
Set 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
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
friend class Multi
This compressor must be able to access the protected functions of its sub-compressors.
const std::size_t blkSize
Uncompressed cache line size (in bytes).
virtual void setCache(BaseCache *_cache)
The cache can only be set once.
uint8_t getIndex() const
Get the index of the best compressor.
MultiCompData(unsigned index, std::unique_ptr< Base::CompressionData > comp_data)
Default constructor.
std::unique_ptr< Base::CompressionData > compData
Compression data of the best compressor.
void setCache(BaseCache *_cache) override
The cache can only be set once.
const std::size_t numEncodingBits
An encoding is associated to each sub-compressor to inform which sub-compressor to use when decompres...
std::vector< Base * > compressors
List of sub-compressors.
std::unique_ptr< Base::CompressionData > compress(const std::vector< Base::Chunk > &chunks, Cycles &comp_lat, Cycles &decomp_lat) override
Apply the compression process to the cache line.
gem5::compression::Multi::MultiStats multiStats
void decompress(const CompressionData *comp_data, uint64_t *data) override
Apply the decompression process to the compressed data.
Definition of the a multi compressor that choses the best compression among multiple compressors.
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
constexpr uint64_t alignToPowerOfTwo(uint64_t val)
Align to the next highest power of two.
#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.
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)
Overload hash function for BasicBlockRange type.
void regStats() override
Callback to set stat parameters.
MultiStats(BaseStats &base_group, Multi &_compressor)
statistics::Vector2d ranks
Number of times each compressor provided the nth best compression.