33#ifndef __MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_IMPL_HH__
34#define __MEM_CACHE_COMPRESSORS_DICTIONARY_COMPRESSOR_IMPL_HH__
39#include "debug/CacheComp.hh"
41#include "params/BaseDictionaryCompressor.hh"
63 entries.push_back(std::move(pattern));
87std::unique_ptr<typename DictionaryCompressor<T>::CompData>
90 return std::unique_ptr<DictionaryCompressor<T>::CompData>(
new CompData());
94std::unique_ptr<typename DictionaryCompressor<T>::Pattern>
102 std::unique_ptr<Pattern> pattern =
108 std::unique_ptr<Pattern> temp_pattern =
112 if (temp_pattern->getSizeBits() < pattern->getSizeBits()) {
113 pattern = std::move(temp_pattern);
121 if (pattern->shouldAllocate()) {
129std::unique_ptr<Base::CompressionData>
132 std::unique_ptr<Base::CompressionData> comp_data =
140 for (
const auto& value : chunks) {
142 DPRINTF(CacheComp,
"Compressed %016x to %s\n", value,
144 comp_data_ptr->
addEntry(std::move(pattern));
152std::unique_ptr<Base::CompressionData>
197 for (
const auto& entry : casted_comp_data->
entries) {
199 decomp_values.push_back(value);
200 DPRINTF(CacheComp,
"Decompressed %s to %x\n", entry->print(), value);
206 const std::size_t values_per_entry =
sizeof(uint64_t)/
sizeof(T);
207 for (
int j = values_per_entry - 1; j >= 0; j--) {
209 static_cast<uint64_t
>(decomp_values[values_per_entry*
i+j]) <<
216typename DictionaryCompressor<T>::DictionaryEntry
220 for (
int i = 0;
i <
sizeof(T);
i++) {
221 entry[
i] = value & 0xFF;
232 for (
int i =
sizeof(T) - 1;
i >= 0;
i--) {
Cycles is a wrapper class for representing cycle counts, i.e.
const std::size_t dictionarySize
Dictionary size.
BaseDictionaryCompressor(const Params &p)
std::size_t numEntries
Number of valid entries in the dictionary.
gem5::compression::BaseDictionaryCompressor::DictionaryStats dictionaryStats
std::size_t getSizeBits() const
Get compression size (in bits).
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
const Cycles compChunksPerCycle
Degree of parallelization of the compression process.
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
const std::size_t blkSize
Uncompressed cache line size (in bytes).
const Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
virtual void addEntry(std::unique_ptr< Pattern >)
Add a pattern entry to the list of patterns.
std::vector< std::unique_ptr< Pattern > > entries
The patterns matched in the original line.
The compressed data is composed of multiple pattern entries.
virtual DictionaryEntry decompress(const DictionaryEntry dict_bytes) const =0
Decompress the pattern.
bool shouldAllocate() const
Determine if pattern allocates a dictionary entry.
uint8_t getMatchLocation() const
Get the index of the dictionary match location.
static T fromDictionaryEntry(const DictionaryEntry &entry)
Turn a dictionary entry into a value.
std::vector< DictionaryEntry > dictionary
The dictionary.
virtual void addToDictionary(const DictionaryEntry data)=0
Add an entry to the dictionary.
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...
BaseDictionaryCompressorParams Params
virtual void resetDictionary()
Clear all dictionary entries.
std::unique_ptr< Pattern > compressValue(const T data)
Compress data.
virtual std::unique_ptr< DictionaryCompressor::CompData > instantiateDictionaryCompData() const
Instantiate a compression data of the sub-class compressor.
std::array< uint8_t, sizeof(T)> DictionaryEntry
Convenience typedef for a dictionary entry.
T decompressValue(const Pattern *pattern)
Decompress a pattern into a value that fits in a dictionary entry.
void decompress(const CompressionData *comp_data, uint64_t *data) override
Apply the decompression process to the compressed data.
std::unique_ptr< Base::CompressionData > compress(const std::vector< Chunk > &chunks)
Apply compression.
DictionaryCompressor(const Params &p)
static DictionaryEntry toDictionaryEntry(T value)
Turn a value into a dictionary entry.
Definition of a dictionary based cache compressor.
Copyright (c) 2024 Arm Limited All rights reserved.