From 2c7d4bed660edc97cd462806588058a3b16b68f7 Mon Sep 17 00:00:00 2001 From: Pranith Kumar Date: Sat, 6 Jan 2024 19:22:47 -0500 Subject: [PATCH] mem-cache: Implement VFT tables using cache library The frequency table is better built using the generic cache library instead of the AssociativeSet since the secure bit is not needed for this structure. Change-Id: Ie3b6442235daec7b350c608ad1380bed58f5ccf4 --- src/mem/cache/compressors/frequent_values.cc | 15 ++++++++------- src/mem/cache/compressors/frequent_values.hh | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/mem/cache/compressors/frequent_values.cc b/src/mem/cache/compressors/frequent_values.cc index b5eca3b096..6930feedd8 100644 --- a/src/mem/cache/compressors/frequent_values.cc +++ b/src/mem/cache/compressors/frequent_values.cc @@ -51,8 +51,9 @@ FrequentValues::FrequentValues(const Params &p) codeGenerationTicks(p.code_generation_ticks), checkSaturation(p.check_saturation), numVFTEntries(p.vft_entries), numSamples(p.num_samples), takenSamples(0), phase(SAMPLING), - VFT(p.vft_assoc, p.vft_entries, p.vft_indexing_policy, - p.vft_replacement_policy, VFTEntry(counterBits)), + VFT((name() + ".VFT").c_str(), + p.vft_entries, p.vft_assoc, p.vft_replacement_policy, + p.vft_indexing_policy, VFTEntry(counterBits)), codeGenerationEvent([this]{ phase = COMPRESSING; }, name()) { fatal_if((numVFTEntries - 1) > mask(chunkSizeBits), @@ -75,7 +76,7 @@ FrequentValues::compress(const std::vector& chunks, Cycles& comp_lat, encoder::Code code; int length = 0; if (phase == COMPRESSING) { - VFTEntry* entry = VFT.findEntry(chunk, false); + VFTEntry* entry = VFT.findEntry(chunk); // Theoretically, the code would be the index of the entry; // however, there is no practical need to do so, and we simply @@ -159,7 +160,7 @@ FrequentValues::decompress(const CompressionData* comp_data, uint64_t* data) // The value at the given VFT entry must match the one stored, // if it is not the uncompressed value assert((comp_chunk.code.code == uncompressedValue) || - VFT.findEntry(comp_chunk.value, false)); + VFT.findEntry(comp_chunk.value)); } } @@ -178,7 +179,7 @@ FrequentValues::sampleValues(const std::vector &data, { const std::vector chunks = toChunks(data.data()); for (const Chunk& chunk : chunks) { - VFTEntry* entry = VFT.findEntry(chunk, false); + VFTEntry* entry = VFT.findEntry(chunk); bool saturated = false; if (!is_invalidation) { // If a VFT hit, increase new value's counter; otherwise, insert @@ -187,7 +188,7 @@ FrequentValues::sampleValues(const std::vector &data, entry = VFT.findVictim(chunk); assert(entry != nullptr); entry->value = chunk; - VFT.insertEntry(chunk, false, entry); + VFT.insertEntry(chunk, entry); } else { VFT.accessEntry(entry); } @@ -234,7 +235,7 @@ FrequentValues::generateCodes() // representing uncompressed values assert(uncompressed_values.size() >= 1); uncompressedValue = *uncompressed_values.begin(); - assert(VFT.findEntry(uncompressedValue, false) == nullptr); + assert(VFT.findEntry(uncompressedValue) == nullptr); if (useHuffmanEncoding) { // Populate the queue, adding each entry as a tree with one node. diff --git a/src/mem/cache/compressors/frequent_values.hh b/src/mem/cache/compressors/frequent_values.hh index 41103ce594..a5a53c7c8f 100644 --- a/src/mem/cache/compressors/frequent_values.hh +++ b/src/mem/cache/compressors/frequent_values.hh @@ -34,13 +34,13 @@ #include #include +#include "base/cache/associative_cache.hh" #include "base/sat_counter.hh" #include "base/types.hh" #include "mem/cache/base.hh" #include "mem/cache/cache_probe_arg.hh" #include "mem/cache/compressors/base.hh" #include "mem/cache/compressors/encoders/huffman.hh" -#include "mem/cache/prefetch/associative_set.hh" #include "sim/eventq.hh" #include "sim/probe/probe.hh" @@ -112,7 +112,7 @@ class FrequentValues : public Base enum Phase {SAMPLING, CODE_GENERATION, COMPRESSING}; Phase phase; - class VFTEntry : public TaggedEntry + class VFTEntry : public CacheEntry { public: /** @@ -130,14 +130,14 @@ class FrequentValues : public Base SatCounter32 counter; VFTEntry(std::size_t num_bits) - : TaggedEntry(), value(0), counter(num_bits) + : CacheEntry(), value(0), counter(num_bits) { } void invalidate() override { - TaggedEntry::invalidate(); + CacheEntry::invalidate(); value = 0; counter.reset(); } @@ -147,7 +147,7 @@ class FrequentValues : public Base * The Value Frequency Table, a small cache that keeps track and estimates * the frequency distribution of values in the cache. */ - AssociativeSet VFT; + AssociativeCache VFT; /** * A pseudo value is used as the representation of uncompressed values.