Go to the documentation of this file.
37 #include "debug/CacheComp.hh"
39 #include "params/FrequentValuesCompressor.hh"
44 :
Base(
p), useHuffmanEncoding(
p.max_code_length != 0),
45 encoder(
p.max_code_length), counterBits(
p.counter_bits),
46 codeGenerationTicks(
p.code_generation_ticks),
47 checkSaturation(
p.check_saturation), numVFTEntries(
p.vft_entries),
48 numSamples(
p.num_samples), takenSamples(0), phase(SAMPLING),
49 VFT(
p.vft_assoc,
p.vft_entries,
p.vft_indexing_policy,
50 p.vft_replacement_policy,
VFTEntry(counterBits)),
54 "There are more VFT entries than possible values.");
57 std::unique_ptr<Base::CompressionData>
61 std::unique_ptr<CompData> comp_data =
62 std::unique_ptr<CompData>(
new CompData());
69 for (
const auto& chunk : chunks) {
79 const unsigned index = entry ? chunk : uncompressed_index;
85 if (
index == uncompressed_index) {
87 }
else if (code.
length > 64) {
97 code = {
index, code_size};
108 DPRINTF(CacheComp,
"Compressed %016x to %016x (Size = %d) "
109 "(Phase: %d)\n", chunk, code.
code, length,
phase);
111 comp_data->compressedValues.emplace_back(code, chunk);
117 comp_data->setSizeBits(size);
149 assert(((code.length <= 64) &&
150 (code.code == comp_chunk.code.code)) ||
151 (comp_chunk.code.code ==
157 VFT.findEntry(comp_chunk.value,
false));
161 decomp_chunks.push_back(comp_chunk.value);
162 DPRINTF(CacheComp,
"Decompressed %016x to %016x\n",
163 comp_chunk.code.code, comp_chunk.value);
172 bool is_invalidation)
175 for (
const Chunk& chunk : chunks) {
177 bool saturated =
false;
178 if (!is_invalidation) {
182 entry =
VFT.findVictim(chunk);
183 assert(entry !=
nullptr);
184 entry->
value = chunk;
185 VFT.insertEntry(chunk,
false, entry);
187 VFT.accessEntry(entry);
194 VFT.accessEntry(entry);
202 for (
auto& entry :
VFT) {
217 std::set<uint64_t> uncompressed_values;
219 uncompressed_values.insert(uncompressed_values.end(),
i);
222 for (
const auto& entry :
VFT) {
225 uncompressed_values.erase(entry.value);
230 assert(uncompressed_values.size() >= 1);
238 for (
const auto& entry :
VFT) {
265 if (data_update.
oldData.size() > 0) {
270 if (data_update.
newData.size() > 0) {
286 assert(
cache !=
nullptr);
std::vector< uint64_t > oldData
The stale data contents.
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
void decompress(const CompressionData *comp_data, uint64_t *data) override
Apply the decompression process to the compressed data.
unsigned takenSamples
Number of samples taken so far.
const unsigned chunkSizeBits
Chunk size, in number of bits.
void regProbeListeners() override
Register probe listeners for this object.
void generateCodeMaps()
Generation of the code maps.
uint64_t code
Only the LSB of the code are relevant.
std::vector< FrequentValuesListener * > listeners
const bool useHuffmanEncoding
Whether Huffman encoding is applied to the VFT indices.
void notify(const DataUpdate &data_update) override
void sample(uint64_t value, uint64_t frequency)
Inserts the value-frequency pair in the tree.
std::unique_ptr< Base::CompressionData > compress(const std::vector< Chunk > &chunks, Cycles &comp_lat, Cycles &decomp_lat) override
Apply the compression process to the cache line.
void fromChunks(const std::vector< Chunk > &chunks, uint64_t *data) const
This function re-joins the chunks to recreate the original data.
Base cache compressor interface.
std::vector< uint64_t > newData
The new data contents.
void generateCodes()
End sampling phase and start the code generation.
const Tick codeGenerationTicks
Ticks needed to perform the CODE_GENERATION phase.
void schedule(Event &event, Tick when)
Encoder::Huffman encoder
The encoder applied to the VFT indices.
BaseCacheCompressorParams Params
EventFunctionWrapper codeGenerationEvent
Event to handle finishing code generation and starting compression.
const unsigned numVFTEntries
Maximum number of VFT entries, and thus of codewords too.
uint64_t value
The value is stored as a 64 bit entry to accomodate for the uncompressed value.
void probeNotify(const DataUpdate &data_update)
Process a notification event from the ProbeListener.
std::vector< CompressedValue > compressedValues
The values contained in the original data, after being compressed sequentially.
const Cycles compChunksPerCycle
Degree of parallelization of the compression process.
const std::string & name()
ProbeManager * getProbeManager()
Get the probe manager for this object.
SatCounter32 counter
The ideal counter width (in bits) is determined by the maximum number of times a given value appears ...
AssociativeSet< VFTEntry > VFT
The Value Frequency Table, a small cache that keeps track and estimates the frequency distribution of...
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
std::vector< Chunk > toChunks(const uint64_t *data) const
This function splits the raw data into chunks, so that it can be parsed by the compressor.
void sampleValues(const std::vector< uint64_t > &data, bool is_invalidation)
Sample values from a packet, adding them to the VFT.
A data contents update is composed of the updated block's address, the old contents,...
uint64_t uncompressedValue
A pseudo value is used as the representation of uncompressed values.
unsigned length
Number of bits in the code.
FrequentValues(const Params &p)
Cycles is a wrapper class for representing cycle counts, i.e.
Tick curTick()
The universal simulation clock.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
const Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
uint64_t Chunk
A chunk is a basic lexical unit.
Code encode(const uint64_t val) const override
The function responsible for the generation of the alternative value.
const unsigned numSamples
Number of samples in the sampling phase.
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
const bool checkSaturation
Whether an action must be performed when counters saturate.
BaseCache * cache
Pointer to the parent cache.
Generated on Tue Mar 23 2021 19:41:27 for gem5 by doxygen 1.8.17