gem5  v21.2.0.0
base_delta.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 
33 #ifndef __MEM_CACHE_COMPRESSORS_BASE_DELTA_HH__
34 #define __MEM_CACHE_COMPRESSORS_BASE_DELTA_HH__
35 
36 #include <array>
37 #include <cstdint>
38 #include <map>
39 #include <memory>
40 
41 #include "base/bitfield.hh"
43 
44 namespace gem5
45 {
46 
47 struct BaseDictionaryCompressorParams;
48 struct Base64Delta8Params;
49 struct Base64Delta16Params;
50 struct Base64Delta32Params;
51 struct Base32Delta8Params;
52 struct Base32Delta16Params;
53 struct Base16Delta8Params;
54 
55 GEM5_DEPRECATED_NAMESPACE(Compressor, compression);
56 namespace compression
57 {
58 
69 template <class BaseType, std::size_t DeltaSizeBits>
70 class BaseDelta : public DictionaryCompressor<BaseType>
71 {
72  protected:
73  static constexpr int DEFAULT_MAX_NUM_BASES = 2;
74 
75  using DictionaryEntry =
77 
78  // Forward declaration of all possible patterns
79  class PatternX;
80  class PatternM;
81 
89  {
91  };
92 
93  uint64_t getNumPatterns() const override { return NUM_PATTERNS; }
94 
100  Factory<PatternM, PatternX>;
101 
102  std::unique_ptr<typename DictionaryCompressor<BaseType>::Pattern>
104  const DictionaryEntry& dict_bytes,
105  const int match_location) const override
106  {
107  return PatternFactory::getPattern(bytes, dict_bytes, match_location);
108  }
109 
110  std::string
111  getName(int number) const override
112  {
113  static std::map<int, std::string> pattern_names = {
114  {X, "X"}, {M, "M"}
115  };
116 
117  return pattern_names[number];
118  }
119 
120  void resetDictionary() override;
121 
122  void addToDictionary(DictionaryEntry data) override;
123 
124  std::unique_ptr<Base::CompressionData> compress(
125  const std::vector<Base::Chunk>& chunks,
126  Cycles& comp_lat, Cycles& decomp_lat) override;
127 
128  public:
129  typedef BaseDictionaryCompressorParams Params;
130  BaseDelta(const Params &p);
131  ~BaseDelta() = default;
132 };
133 
134 template <class BaseType, std::size_t DeltaSizeBits>
135 class BaseDelta<BaseType, DeltaSizeBits>::PatternX
136  : public DictionaryCompressor<BaseType>::UncompressedPattern
137 {
138  public:
139  // A delta entry containing the value 0 is added even if it is an entirely
140  // new base
141  PatternX(const DictionaryEntry bytes, const int match_location)
142  : DictionaryCompressor<BaseType>::UncompressedPattern(X, 0,
143  std::ceil(std::log2(DEFAULT_MAX_NUM_BASES)) + DeltaSizeBits,
144  match_location, bytes)
145  {
146  }
147 };
148 
149 template <class BaseType, std::size_t DeltaSizeBits>
150 class BaseDelta<BaseType, DeltaSizeBits>::PatternM : public
151  DictionaryCompressor<BaseType>::template DeltaPattern<DeltaSizeBits>
152 {
153  public:
154  // The number of bits reserved for the bitmask entry is proportional to
155  // the maximum number of bases
156  PatternM(const DictionaryEntry bytes, const int match_location)
157  : DictionaryCompressor<BaseType>::template DeltaPattern<DeltaSizeBits>(
158  M, 1, std::ceil(std::log2(DEFAULT_MAX_NUM_BASES)), match_location,
159  bytes)
160  {
161  }
162 };
163 
164 class Base64Delta8 : public BaseDelta<uint64_t, 8>
165 {
166  public:
167  typedef Base64Delta8Params Params;
168  Base64Delta8(const Params &p);
169  ~Base64Delta8() = default;
170 };
171 
172 class Base64Delta16 : public BaseDelta<uint64_t, 16>
173 {
174  public:
175  typedef Base64Delta16Params Params;
176  Base64Delta16(const Params &p);
177  ~Base64Delta16() = default;
178 };
179 
180 class Base64Delta32 : public BaseDelta<uint64_t, 32>
181 {
182  public:
183  typedef Base64Delta32Params Params;
184  Base64Delta32(const Params &p);
185  ~Base64Delta32() = default;
186 };
187 
188 class Base32Delta8 : public BaseDelta<uint32_t, 8>
189 {
190  public:
191  typedef Base32Delta8Params Params;
192  Base32Delta8(const Params &p);
193  ~Base32Delta8() = default;
194 };
195 
196 class Base32Delta16 : public BaseDelta<uint32_t, 16>
197 {
198  public:
199  typedef Base32Delta16Params Params;
200  Base32Delta16(const Params &p);
201  ~Base32Delta16() = default;
202 };
203 
204 class Base16Delta8 : public BaseDelta<uint16_t, 8>
205 {
206  public:
207  typedef Base16Delta8Params Params;
208  Base16Delta8(const Params &p);
209  ~Base16Delta8() = default;
210 };
211 
212 } // namespace compression
213 } // namespace gem5
214 
215 #endif //__MEM_CACHE_COMPRESSORS_BASE_DELTA_HH__
gem5::compression::Base64Delta16
Definition: base_delta.hh:172
gem5::compression::Base16Delta8::Base16Delta8
Base16Delta8(const Params &p)
Definition: base_delta.cc:74
gem5::compression::BaseDelta::compress
std::unique_ptr< Base::CompressionData > compress(const std::vector< Base::Chunk > &chunks, Cycles &comp_lat, Cycles &decomp_lat) override
Apply the compression process to the cache line.
Definition: base_delta_impl.hh:75
gem5::compression::BaseDelta::PatternM::PatternM
PatternM(const DictionaryEntry bytes, const int match_location)
Definition: base_delta.hh:156
gem5::compression::Base64Delta16::~Base64Delta16
~Base64Delta16()=default
gem5::compression::DictionaryCompressor
A template version of the dictionary compressor that allows to choose the dictionary size.
Definition: dictionary_compressor.hh:118
gem5::compression::BaseDelta::X
@ X
Definition: base_delta.hh:90
gem5::compression::BaseDelta::PatternFactory
typename DictionaryCompressor< BaseType >::template Factory< PatternM, PatternX > PatternFactory
Convenience factory declaration.
Definition: base_delta.hh:100
gem5::compression::BaseDelta
Base class for all base-delta-immediate compressors.
Definition: base_delta.hh:70
gem5::compression::Base32Delta16::~Base32Delta16
~Base32Delta16()=default
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::compression::BaseDelta::getNumPatterns
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition: base_delta.hh:93
gem5::compression::Base32Delta8
Definition: base_delta.hh:188
gem5::compression::BaseDelta::getName
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: base_delta.hh:111
gem5::compression::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:202
std::vector
STL vector class.
Definition: stl.hh:37
gem5::compression::Base64Delta32::Params
Base64Delta32Params Params
Definition: base_delta.hh:183
gem5::compression::Base64Delta32::Base64Delta32
Base64Delta32(const Params &p)
Definition: base_delta.cc:59
gem5::compression::BaseDelta< uint64_t, 16 >::PatternNumber
PatternNumber
The patterns proposed in the paper.
Definition: base_delta.hh:88
gem5::compression::BaseDelta< uint64_t, 16 >::DictionaryEntry
typename DictionaryCompressor< uint64_t >::DictionaryEntry DictionaryEntry
Definition: base_delta.hh:76
gem5::compression::Base64Delta8
Definition: base_delta.hh:164
gem5::compression::Base16Delta8::Params
Base16Delta8Params Params
Definition: base_delta.hh:207
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::compression::BaseDelta::NUM_PATTERNS
@ NUM_PATTERNS
Definition: base_delta.hh:90
gem5::compression::Base32Delta8::Base32Delta8
Base32Delta8(const Params &p)
Definition: base_delta.cc:64
dictionary_compressor.hh
gem5::compression::BaseDelta::~BaseDelta
~BaseDelta()=default
gem5::compression::Base32Delta16::Base32Delta16
Base32Delta16(const Params &p)
Definition: base_delta.cc:69
bitfield.hh
gem5::compression::BaseDelta::PatternM
Definition: base_delta.hh:150
gem5::compression::Base64Delta8::~Base64Delta8
~Base64Delta8()=default
gem5::compression::Base32Delta8::Params
Base32Delta8Params Params
Definition: base_delta.hh:191
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::compression::Base64Delta16::Base64Delta16
Base64Delta16(const Params &p)
Definition: base_delta.cc:54
gem5::compression::Base64Delta32
Definition: base_delta.hh:180
gem5::compression::Base64Delta8::Params
Base64Delta8Params Params
Definition: base_delta.hh:167
gem5::compression::Base32Delta16
Definition: base_delta.hh:196
gem5::compression::Base32Delta8::~Base32Delta8
~Base32Delta8()=default
gem5::compression::Base64Delta16::Params
Base64Delta16Params Params
Definition: base_delta.hh:175
gem5::compression::Base64Delta8::Base64Delta8
Base64Delta8(const Params &p)
Definition: base_delta.cc:49
gem5::compression::BaseDelta::DEFAULT_MAX_NUM_BASES
static constexpr int DEFAULT_MAX_NUM_BASES
Definition: base_delta.hh:73
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::compression::Base32Delta16::Params
Base32Delta16Params Params
Definition: base_delta.hh:199
gem5::compression::BaseDelta::PatternX
Definition: base_delta.hh:135
gem5::compression::BaseDelta::Params
BaseDictionaryCompressorParams Params
Definition: base_delta.hh:129
std
Overload hash function for BasicBlockRange type.
Definition: types.hh:111
gem5::compression::BaseDelta::resetDictionary
void resetDictionary() override
Clear all dictionary entries.
Definition: base_delta_impl.hh:55
gem5::compression::BaseDelta::PatternX::PatternX
PatternX(const DictionaryEntry bytes, const int match_location)
Definition: base_delta.hh:141
gem5::compression::BaseDelta::getPattern
std::unique_ptr< typename DictionaryCompressor< BaseType >::Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const override
Definition: base_delta.hh:103
gem5::compression::Base64Delta32::~Base64Delta32
~Base64Delta32()=default
gem5::compression::BaseDelta::addToDictionary
void addToDictionary(DictionaryEntry data) override
Definition: base_delta_impl.hh:65
gem5::compression::BaseDelta::BaseDelta
BaseDelta(const Params &p)
Definition: base_delta_impl.hh:48
gem5::compression::Base16Delta8::~Base16Delta8
~Base16Delta8()=default
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::compression::Base16Delta8
Definition: base_delta.hh:204
gem5::compression::BaseDelta::M
@ M
Definition: base_delta.hh:90

Generated on Tue Dec 21 2021 11:34:31 for gem5 by doxygen 1.8.17