35 #ifndef __MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_IMPL_HH__ 36 #define __MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_IMPL_HH__ 40 #include "debug/CacheComp.hh" 42 #include "params/BaseDictionaryCompressor.hh" 55 setSizeBits(getSizeBits() + pattern->getSizeBits());
58 entries.push_back(std::move(pattern));
82 std::unique_ptr<typename DictionaryCompressor<T>::Pattern>
90 std::unique_ptr<Pattern> pattern =
96 std::unique_ptr<Pattern> temp_pattern =
100 if (temp_pattern->getSizeBits() < pattern->getSizeBits()) {
101 pattern = std::move(temp_pattern);
109 if (pattern->shouldAllocate()) {
117 std::unique_ptr<BaseCacheCompressor::CompressionData>
120 std::unique_ptr<BaseCacheCompressor::CompressionData> comp_data =
121 std::unique_ptr<CompData>(
new CompData());
127 CompData*
const comp_data_ptr =
static_cast<CompData*
>(comp_data.get());
129 for (
const auto& value : values) {
131 DPRINTF(CacheComp,
"Compressed %016x to %s\n", value,
133 comp_data_ptr->addEntry(std::move(pattern));
146 std::advance(entry_it, pattern->getMatchLocation());
151 if (pattern->shouldAllocate()) {
164 const CompData* casted_comp_data =
static_cast<const CompData*
>(comp_data);
171 for (
const auto& entry : casted_comp_data->entries) {
173 decomp_values.push_back(value);
174 DPRINTF(CacheComp,
"Decompressed %s to %x\n", entry->print(), value);
180 const std::size_t values_per_entry =
sizeof(uint64_t)/
sizeof(T);
181 for (
int j = values_per_entry - 1;
j >= 0;
j--) {
183 static_cast<uint64_t
>(decomp_values[values_per_entry*
i+
j]) <<
194 for (
int i = 0;
i <
sizeof(T);
i++) {
195 entry[
i] = value & 0xFF;
206 for (
int i =
sizeof(T) - 1;
i >= 0;
i--) {
213 #endif //__MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_IMPL_HH__
static DictionaryEntry toDictionaryEntry(T value)
Turn a value into a dictionary entry.
std::unique_ptr< Pattern > compressValue(const T data)
Compress data.
std::size_t numEntries
Number of valid entries in the dictionary.
void decompress(const CompressionData *comp_data, uint64_t *data) override
Decompress data.
const std::size_t dictionarySize
Dictionary size.
virtual void resetDictionary()
Clear all dictionary entries.
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
DictionaryCompressor(const Params *p)
T decompressValue(const Pattern *pattern)
Decompress a pattern into a value that fits in a dictionary entry.
const std::size_t blkSize
Uncompressed cache line size (in bytes).
std::vector< std::unique_ptr< Pattern > > entries
The patterns matched in the original line.
static T fromDictionaryEntry(const DictionaryEntry &entry)
Turn a dictionary entry into a value.
virtual std::unique_ptr< Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const =0
Since the factory cannot be instantiated here, classes that inherit from this base class have to impl...
std::array< uint8_t, sizeof(uint64_t)> DictionaryEntry
Convenience typedef for a dictionary entry.
std::vector< DictionaryEntry > dictionary
The dictionary.
Stats::Vector patternStats
Number of data entries that were compressed to each pattern.
Definition of a dictionary based cache compressor.
BaseCacheCompressorParams Params
Convenience typedef.
std::unique_ptr< BaseCacheCompressor::CompressionData > compress(const uint64_t *data)
Apply compression.
virtual void addToDictionary(const DictionaryEntry data)=0
Add an entry to the dictionary.
virtual void addEntry(std::unique_ptr< Pattern >)
Add a pattern entry to the list of patterns.