42 #include "debug/CacheComp.hh"
43 #include "params/MultiCompressor.hh"
48 std::unique_ptr<Base::CompressionData> comp_data)
77 std::unique_ptr<Base::CompressionData>
84 std::unique_ptr<Base::CompressionData> compData;
86 uint8_t compressionFactor;
88 Results(
unsigned index,
89 std::unique_ptr<Base::CompressionData> comp_data,
90 Cycles decomp_lat, std::size_t blk_size)
91 :
index(
index), compData(std::move(comp_data)),
94 const std::size_t size = compData->getSize();
104 compressionFactor = (size > blk_size) ? 1 :
105 ((size == 0) ? blk_size :
109 struct ResultsComparator
112 operator()(
const std::shared_ptr<Results>& lhs,
113 const std::shared_ptr<Results>& rhs)
const
115 const std::size_t lhs_cf = lhs->compressionFactor;
116 const std::size_t rhs_cf = rhs->compressionFactor;
118 if (lhs_cf == rhs_cf) {
121 return lhs->decompLat > rhs->decompLat;
123 return lhs_cf < rhs_cf;
134 std::priority_queue<std::shared_ptr<Results>,
139 auto temp_comp_data =
141 temp_comp_data->setSizeBits(temp_comp_data->getSizeBits() +
143 results.push(std::make_shared<Results>(
i, std::move(temp_comp_data),
145 max_comp_lat = std::max(max_comp_lat, comp_lat);
149 const unsigned best_index = results.top()->index;
150 std::unique_ptr<CompressionData> multi_comp_data =
151 std::unique_ptr<MultiCompData>(
152 new MultiCompData(best_index, std::move(results.top()->compData)));
153 DPRINTF(CacheComp,
"Best compressor: %d\n", best_index);
159 for (
int rank = 0; rank <
compressors.size(); rank++) {
166 comp_lat =
Cycles(max_comp_lat + 1);
168 return multi_comp_data;
173 uint64_t* cache_line)
178 casted_comp_data->
compData.get(), cache_line);
182 :
Stats::Group(&base_group), compressor(_compressor),
184 "Number of times each compressor had the nth best compression")
193 const std::size_t num_compressors = compressor.compressors.size();
194 ranks.init(num_compressors, num_compressors);
195 for (
unsigned compressor = 0; compressor < num_compressors; compressor++) {
197 ranks.subdesc(compressor,
"Number of times compressor " +
199 for (
unsigned rank = 0; rank < num_compressors; rank++) {
208 MultiCompressorParams::create()