40 #include "debug/CacheComp.hh" 41 #include "params/MultiCompressor.hh" 44 std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data)
69 std::unique_ptr<BaseCacheCompressor::CompressionData>
76 std::unique_ptr<BaseCacheCompressor::CompressionData> compData;
78 uint8_t compressionFactor;
80 Results(
unsigned index,
81 std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data,
82 Cycles decomp_lat, std::size_t blk_size)
83 :
index(index), compData(std::move(comp_data)),
86 const std::size_t size = compData->getSize();
90 compressionFactor = (size > blk_size) ? 1 :
94 struct ResultsComparator
97 operator()(
const std::shared_ptr<Results>& lhs,
98 const std::shared_ptr<Results>& rhs)
const 100 const std::size_t lhs_cf = lhs->compressionFactor;
101 const std::size_t rhs_cf = rhs->compressionFactor;
103 if (lhs_cf == rhs_cf) {
106 return lhs->decompLat > rhs->decompLat;
108 return lhs_cf < rhs_cf;
113 std::priority_queue<std::shared_ptr<Results>,
118 auto temp_comp_data =
119 compressors[
i]->compress(cache_line, comp_lat, temp_decomp_lat);
120 results.push(std::make_shared<Results>(
i, std::move(temp_comp_data),
122 max_comp_lat = std::max(max_comp_lat, comp_lat);
126 const unsigned best_index = results.top()->index;
127 std::unique_ptr<CompressionData> multi_comp_data =
128 std::unique_ptr<MultiCompData>(
129 new MultiCompData(best_index, std::move(results.top()->compData)));
130 DPRINTF(CacheComp,
"Best compressor: %d\n", best_index);
133 decomp_lat = results.top()->decompLat;
136 for (
int rank = 0; rank <
compressors.size(); rank++) {
143 comp_lat =
Cycles(max_comp_lat + 1);
145 return multi_comp_data;
150 uint64_t* cache_line)
155 casted_comp_data->
compData.get(), cache_line);
166 .desc(
"Number of times each compressor had the nth best compression.")
169 for (
int compressor = 0; compressor <
compressors.size(); compressor++) {
173 for (
unsigned rank = 0; rank <
compressors.size(); rank++) {
180 MultiCompressorParams::create()
uint64_t alignToPowerOfTwo(uint64_t val)
Align to the next highest power of two.
Definition of the a multi compressor that choses the best compression among multiple compressors...
Derived & init(size_type _x, size_type _y)
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation...
Cycles is a wrapper class for representing cycle counts, i.e.
void decompress(const CompressionData *comp_data, uint64_t *data) override
Apply the decompression process to the compressed data.
const uint8_t index
Index of the compressor that provided these compression results.
Derived & subdesc(off_type index, const std::string &desc)
Set the subfield description for the given index and marks this stat to print at the end of simulatio...
Overload hash function for BasicBlockRange type.
std::vector< BaseCacheCompressor * > compressors
List of sub-compressors.
std::unique_ptr< BaseCacheCompressor::CompressionData > compData
Compression data of the best compressor.
MultiCompData(unsigned index, std::unique_ptr< BaseCacheCompressor::CompressionData > comp_data)
Default constructor.
std::unique_ptr< BaseCacheCompressor::CompressionData > compress(const uint64_t *data, Cycles &comp_lat, Cycles &decomp_lat) override
Apply the compression process to the cache line.
Stats::Vector2d rankStats
Number of times each compressor provided the nth best compression.
const std::size_t blkSize
Uncompressed cache line size (in bytes).
MultiCompressor(const Params *p)
Default constructor.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
uint8_t getIndex() const
Get the index of the best compressor.
Base cache compressor interface.
virtual const std::string name() const
BaseCacheCompressorParams Params
Convenience typedef.
Derived & ysubname(off_type index, const std::string &subname)
void regStats() override
Callback to set stat parameters.
~MultiCompressor()
Default destructor.
virtual void regStats()
Callback to set stat parameters.
void setSizeBits(std::size_t size)
Set compression size (in bits).
const std::string to_string(sc_enc enc)