gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 struct FrequentValuesCompressorParams;
47 
48 namespace Compressor {
49 
57 class FrequentValues : public Base
58 {
59  private:
60  class CompData;
61 
63 
64  class FrequentValuesListener : public ProbeListenerArgBase<DataUpdate>
65  {
66  protected:
68 
69  public:
71  const std::string &name)
72  : ProbeListenerArgBase(pm, name), parent(_parent)
73  {
74  }
75  void notify(const DataUpdate &data_update) override;
76  };
78 
80  const bool useHuffmanEncoding;
81 
84 
86  const int counterBits;
87 
90 
92  const bool checkSaturation;
93 
95  const unsigned numVFTEntries;
96 
98  const unsigned numSamples;
99 
101  unsigned takenSamples;
102 
109 
110  class VFTEntry : public TaggedEntry
111  {
112  public:
117  uint64_t value;
118 
126 
127  VFTEntry(std::size_t num_bits)
128  : TaggedEntry(), value(0), counter(num_bits)
129  {
130  }
131 
132  void
133  invalidate() override
134  {
136  value = 0;
137  counter.reset();
138  }
139  };
140 
146 
153 
156 
164  bool is_invalidation);
165 
167  void generateCodes();
168 
169  std::unique_ptr<Base::CompressionData> compress(
170  const std::vector<Chunk>& chunks, Cycles& comp_lat,
171  Cycles& decomp_lat) override;
172 
173  void decompress(const CompressionData* comp_data, uint64_t* data) override;
174 
175  public:
176  typedef FrequentValuesCompressorParams Params;
177  FrequentValues(const Params &p);
178  ~FrequentValues() = default;
179 
185  void probeNotify(const DataUpdate &data_update);
186 
187  void regProbeListeners() override;
188 };
189 
191 {
192  public:
198  {
201 
206  uint64_t value;
207 
208  CompressedValue(Encoder::Code _code, uint64_t _value)
209  : code(_code), value(_value)
210  {
211  }
212  };
213 
219 };
220 
221 } // namespace Compressor
222 
223 #endif //__MEM_CACHE_COMPRESSORS_FREQUENT_VALUES_HH__
Compressor::FrequentValues::decompress
void decompress(const CompressionData *comp_data, uint64_t *data) override
Apply the decompression process to the compressed data.
Definition: frequent_values.cc:131
Compressor::FrequentValues::FrequentValuesListener
Definition: frequent_values.hh:64
Compressor::FrequentValues::takenSamples
unsigned takenSamples
Number of samples taken so far.
Definition: frequent_values.hh:101
base.hh
data
const char data[]
Definition: circlebuf.test.cc:47
Compressor::FrequentValues::regProbeListeners
void regProbeListeners() override
Register probe listeners for this object.
Definition: frequent_values.cc:283
TaggedEntry
Copyright (c) 2020 Inria All rights reserved.
Definition: tagged_entry.hh:43
Compressor::FrequentValues::CompData::CompressedValue::code
Encoder::Code code
The codeword.
Definition: frequent_values.hh:200
AssociativeSet
Copyright (c) 2018 Metempsy Technology Consulting All rights reserved.
Definition: associative_set.hh:42
base.hh
Compressor
Definition: base.cc:47
Compressor::FrequentValues::Phase
Phase
The phase that the compressor is at.
Definition: frequent_values.hh:107
Compressor::FrequentValues::SAMPLING
@ SAMPLING
Definition: frequent_values.hh:107
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
Compressor::FrequentValues::listeners
std::vector< FrequentValuesListener * > listeners
Definition: frequent_values.hh:77
Compressor::FrequentValues::useHuffmanEncoding
const bool useHuffmanEncoding
Whether Huffman encoding is applied to the VFT indices.
Definition: frequent_values.hh:80
Compressor::FrequentValues::FrequentValuesListener::notify
void notify(const DataUpdate &data_update) override
Definition: frequent_values.cc:292
Compressor::FrequentValues::FrequentValuesListener::FrequentValuesListener
FrequentValuesListener(FrequentValues &_parent, ProbeManager *pm, const std::string &name)
Definition: frequent_values.hh:70
Compressor::FrequentValues::compress
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.
Definition: frequent_values.cc:58
std::vector
STL vector class.
Definition: stl.hh:37
Compressor::Base
Base cache compressor interface.
Definition: base.hh:59
sat_counter.hh
Compressor::FrequentValues
This compressor samples the cache for a while, trying to define the most frequently used values.
Definition: frequent_values.hh:57
Compressor::FrequentValues::generateCodes
void generateCodes()
End sampling phase and start the code generation.
Definition: frequent_values.cc:212
Compressor::FrequentValues::codeGenerationTicks
const Tick codeGenerationTicks
Ticks needed to perform the CODE_GENERATION phase.
Definition: frequent_values.hh:89
Compressor::FrequentValues::~FrequentValues
~FrequentValues()=default
EventFunctionWrapper
Definition: eventq.hh:1112
Compressor::Encoder::Huffman
This encoder builds a Huffman tree using the frequency of each value to be encoded.
Definition: huffman.hh:48
Compressor::FrequentValues::VFTEntry
Definition: frequent_values.hh:110
Compressor::Base::CompressionData
Definition: base.hh:240
Compressor::FrequentValues::encoder
Encoder::Huffman encoder
The encoder applied to the VFT indices.
Definition: frequent_values.hh:83
Compressor::FrequentValues::VFTEntry::invalidate
void invalidate() override
Invalidate the block.
Definition: frequent_values.hh:133
Compressor::Encoder::Code
Definition: base.hh:37
Compressor::FrequentValues::Params
FrequentValuesCompressorParams Params
Definition: frequent_values.hh:176
ProbeListener::name
const std::string name
Definition: probe.hh:129
Compressor::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:196
Compressor::FrequentValues::codeGenerationEvent
EventFunctionWrapper codeGenerationEvent
Event to handle finishing code generation and starting compression.
Definition: frequent_values.hh:155
Compressor::FrequentValues::numVFTEntries
const unsigned numVFTEntries
Maximum number of VFT entries, and thus of codewords too.
Definition: frequent_values.hh:95
Compressor::FrequentValues::VFTEntry::value
uint64_t value
The value is stored as a 64 bit entry to accomodate for the uncompressed value.
Definition: frequent_values.hh:117
Compressor::FrequentValues::CompData::CompressedValue::value
uint64_t value
Original value, stored both for when the codeword marks an uncompressed entry, and to verify correctn...
Definition: frequent_values.hh:206
Compressor::FrequentValues::probeNotify
void probeNotify(const DataUpdate &data_update)
Process a notification event from the ProbeListener.
Definition: frequent_values.cc:259
Compressor::FrequentValues::CompData::compressedValues
std::vector< CompressedValue > compressedValues
The values contained in the original data, after being compressed sequentially.
Definition: frequent_values.hh:218
Compressor::FrequentValues::FrequentValuesListener::parent
FrequentValues & parent
Definition: frequent_values.hh:67
Compressor::FrequentValues::VFTEntry::counter
SatCounter32 counter
The ideal counter width (in bits) is determined by the maximum number of times a given value appears ...
Definition: frequent_values.hh:125
Compressor::FrequentValues::CompData::CompressedValue::CompressedValue
CompressedValue(Encoder::Code _code, uint64_t _value)
Definition: frequent_values.hh:208
Compressor::FrequentValues::CODE_GENERATION
@ CODE_GENERATION
Definition: frequent_values.hh:107
Compressor::FrequentValues::VFT
AssociativeSet< VFTEntry > VFT
The Value Frequency Table, a small cache that keeps track and estimates the frequency distribution of...
Definition: frequent_values.hh:145
ProbeManager
ProbeManager is a conduit class that lives on each SimObject, and is used to match up probe listeners...
Definition: probe.hh:154
Compressor::FrequentValues::sampleValues
void sampleValues(const std::vector< uint64_t > &data, bool is_invalidation)
Sample values from a packet, adding them to the VFT.
Definition: frequent_values.cc:171
BaseCache::DataUpdate
A data contents update is composed of the updated block's address, the old contents,...
Definition: base.hh:116
GenericSatCounter< uint32_t >
Compressor::FrequentValues::CompData
Definition: frequent_values.hh:190
Compressor::FrequentValues::uncompressedValue
uint64_t uncompressedValue
A pseudo value is used as the representation of uncompressed values.
Definition: frequent_values.hh:152
TaggedEntry::invalidate
virtual void invalidate()
Invalidate the block.
Definition: tagged_entry.hh:100
types.hh
Compressor::FrequentValues::FrequentValues
FrequentValues(const Params &p)
Definition: frequent_values.cc:43
Compressor::FrequentValues::COMPRESSING
@ COMPRESSING
Definition: frequent_values.hh:107
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
huffman.hh
GenericSatCounter::reset
void reset()
Reset the counter to its initial value.
Definition: sat_counter.hh:289
Compressor::FrequentValues::counterBits
const int counterBits
Number of bits in the saturating counters.
Definition: frequent_values.hh:86
associative_set.hh
Compressor::FrequentValues::VFTEntry::VFTEntry
VFTEntry(std::size_t num_bits)
Definition: frequent_values.hh:127
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
probe.hh
Compressor::FrequentValues::phase
Phase phase
Definition: frequent_values.hh:108
Compressor::FrequentValues::CompData::CompressedValue
A compressed value contains its encoding, and the compressed data itself.
Definition: frequent_values.hh:197
Compressor::FrequentValues::numSamples
const unsigned numSamples
Number of samples in the sampling phase.
Definition: frequent_values.hh:98
Compressor::FrequentValues::checkSaturation
const bool checkSaturation
Whether an action must be performed when counters saturate.
Definition: frequent_values.hh:92
eventq.hh
ProbeListenerArgBase
ProbeListenerArgBase is used to define the base interface to a ProbeListenerArg (i....
Definition: probe.hh:202

Generated on Tue Mar 23 2021 19:41:27 for gem5 by doxygen 1.8.17