gem5  v22.1.0.0
frequent_values.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __MEM_CACHE_COMPRESSORS_FREQUENT_VALUES_HH__
30 #define __MEM_CACHE_COMPRESSORS_FREQUENT_VALUES_HH__
31 
32 #include <climits>
33 #include <cstdint>
34 #include <memory>
35 #include <vector>
36 
37 #include "base/sat_counter.hh"
38 #include "base/types.hh"
39 #include "mem/cache/base.hh"
43 #include "sim/eventq.hh"
44 #include "sim/probe/probe.hh"
45 
46 namespace gem5
47 {
48 
49 struct FrequentValuesCompressorParams;
50 
51 GEM5_DEPRECATED_NAMESPACE(Compressor, compression);
52 namespace compression
53 {
54 
62 class FrequentValues : public Base
63 {
64  private:
65  class CompData;
66 
68 
69  class FrequentValuesListener : public ProbeListenerArgBase<DataUpdate>
70  {
71  protected:
73 
74  public:
76  const std::string &name)
77  : ProbeListenerArgBase(pm, name), parent(_parent)
78  {
79  }
80  void notify(const DataUpdate &data_update) override;
81  };
83 
85  const bool useHuffmanEncoding;
86 
89 
91  const int counterBits;
92 
95 
97  const bool checkSaturation;
98 
100  const unsigned numVFTEntries;
101 
103  const unsigned numSamples;
104 
106  unsigned takenSamples;
107 
114 
115  class VFTEntry : public TaggedEntry
116  {
117  public:
122  uint64_t value;
123 
131 
132  VFTEntry(std::size_t num_bits)
133  : TaggedEntry(), value(0), counter(num_bits)
134  {
135  }
136 
137  void
138  invalidate() override
139  {
141  value = 0;
142  counter.reset();
143  }
144  };
145 
151 
158 
161 
169  bool is_invalidation);
170 
172  void generateCodes();
173 
174  std::unique_ptr<Base::CompressionData> compress(
175  const std::vector<Chunk>& chunks, Cycles& comp_lat,
176  Cycles& decomp_lat) override;
177 
178  void decompress(const CompressionData* comp_data, uint64_t* data) override;
179 
180  public:
181  typedef FrequentValuesCompressorParams Params;
182  FrequentValues(const Params &p);
183  ~FrequentValues() = default;
184 
190  void probeNotify(const DataUpdate &data_update);
191 
192  void regProbeListeners() override;
193 };
194 
196 {
197  public:
203  {
206 
211  uint64_t value;
212 
213  CompressedValue(encoder::Code _code, uint64_t _value)
214  : code(_code), value(_value)
215  {
216  }
217  };
218 
224 };
225 
226 } // namespace compression
227 } // namespace gem5
228 
229 #endif //__MEM_CACHE_COMPRESSORS_FREQUENT_VALUES_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
const char data[]
Associative container based on the previosuly defined Entry type Each element is indexed by a key of ...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
ProbeListenerArgBase is used to define the base interface to a ProbeListenerArg (i....
Definition: probe.hh:212
const std::string name
Definition: probe.hh:138
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition: probe.hh:164
A tagged entry is an entry containing a tag.
Definition: tagged_entry.hh:47
virtual void invalidate()
Invalidate the block.
Base cache compressor interface.
Definition: base.hh:66
BaseCacheCompressorParams Params
Definition: base.hh:202
std::vector< CompressedValue > compressedValues
The values contained in the original data, after being compressed sequentially.
FrequentValuesListener(FrequentValues &_parent, ProbeManager *pm, const std::string &name)
void notify(const DataUpdate &data_update) override
SatCounter32 counter
The ideal counter width (in bits) is determined by the maximum number of times a given value appears ...
uint64_t value
The value is stored as a 64 bit entry to accomodate for the uncompressed value.
void invalidate() override
Invalidate the block.
This compressor samples the cache for a while, trying to define the most frequently used values.
std::vector< FrequentValuesListener * > listeners
FrequentValuesCompressorParams Params
const int counterBits
Number of bits in the saturating counters.
void decompress(const CompressionData *comp_data, uint64_t *data) override
Apply the decompression process to the compressed data.
void regProbeListeners() override
Register probe listeners for this object.
void sampleValues(const std::vector< uint64_t > &data, bool is_invalidation)
Sample values from a packet, adding them to the VFT.
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.
unsigned takenSamples
Number of samples taken so far.
Phase
The phase that the compressor is at.
void probeNotify(const DataUpdate &data_update)
Process a notification event from the ProbeListener.
const unsigned numVFTEntries
Maximum number of VFT entries, and thus of codewords too.
const Tick codeGenerationTicks
Ticks needed to perform the CODE_GENERATION phase.
const bool checkSaturation
Whether an action must be performed when counters saturate.
void generateCodes()
End sampling phase and start the code generation.
const unsigned numSamples
Number of samples in the sampling phase.
encoder::Huffman indexEncoder
The encoder applied to the VFT indices.
const bool useHuffmanEncoding
Whether Huffman encoding is applied to the VFT indices.
uint64_t uncompressedValue
A pseudo value is used as the representation of uncompressed values.
AssociativeSet< VFTEntry > VFT
The Value Frequency Table, a small cache that keeps track and estimates the frequency distribution of...
EventFunctionWrapper codeGenerationEvent
Event to handle finishing code generation and starting compression.
This encoder builds a Huffman tree using the frequency of each value to be encoded.
Definition: huffman.hh:57
STL vector class.
Definition: stl.hh:37
void reset()
Reset the counter to its initial value.
Definition: sat_counter.hh:292
Declares a basic cache interface BaseCache.
Definition of a basic cache compressor.
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Tick
Tick count type.
Definition: types.hh:58
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
A data contents update is composed of the updated block's address, the old contents,...
Definition: base.hh:125
A compressed value contains its encoding, and the compressed data itself.
uint64_t value
Original value, stored both for when the codeword marks an uncompressed entry, and to verify correctn...

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1