gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 namespace compression
56 {
57 
68 template <class BaseType, std::size_t DeltaSizeBits>
69 class BaseDelta : public DictionaryCompressor<BaseType>
70 {
71  protected:
72  static constexpr int DEFAULT_MAX_NUM_BASES = 2;
73 
74  using DictionaryEntry =
76 
77  // Forward declaration of all possible patterns
78  class PatternX;
79  class PatternM;
80 
88  {
90  };
91 
92  uint64_t getNumPatterns() const override { return NUM_PATTERNS; }
93 
99  Factory<PatternM, PatternX>;
100 
101  std::unique_ptr<typename DictionaryCompressor<BaseType>::Pattern>
103  const DictionaryEntry& dict_bytes,
104  const int match_location) const override
105  {
106  return PatternFactory::getPattern(bytes, dict_bytes, match_location);
107  }
108 
109  std::string
110  getName(int number) const override
111  {
112  static std::map<int, std::string> pattern_names = {
113  {X, "X"}, {M, "M"}
114  };
115 
116  return pattern_names[number];
117  }
118 
119  void resetDictionary() override;
120 
121  void addToDictionary(DictionaryEntry data) override;
122 
123  std::unique_ptr<Base::CompressionData> compress(
124  const std::vector<Base::Chunk>& chunks,
125  Cycles& comp_lat, Cycles& decomp_lat) override;
126 
127  public:
128  typedef BaseDictionaryCompressorParams Params;
129  BaseDelta(const Params &p);
130  ~BaseDelta() = default;
131 };
132 
133 template <class BaseType, std::size_t DeltaSizeBits>
134 class BaseDelta<BaseType, DeltaSizeBits>::PatternX
135  : public DictionaryCompressor<BaseType>::UncompressedPattern
136 {
137  public:
138  // A delta entry containing the value 0 is added even if it is an entirely
139  // new base
140  PatternX(const DictionaryEntry bytes, const int match_location)
141  : DictionaryCompressor<BaseType>::UncompressedPattern(X, 0,
142  std::ceil(std::log2(DEFAULT_MAX_NUM_BASES)) + DeltaSizeBits,
143  match_location, bytes)
144  {
145  }
146 };
147 
148 template <class BaseType, std::size_t DeltaSizeBits>
149 class BaseDelta<BaseType, DeltaSizeBits>::PatternM : public
150  DictionaryCompressor<BaseType>::template DeltaPattern<DeltaSizeBits>
151 {
152  public:
153  // The number of bits reserved for the bitmask entry is proportional to
154  // the maximum number of bases
155  PatternM(const DictionaryEntry bytes, const int match_location)
156  : DictionaryCompressor<BaseType>::template DeltaPattern<DeltaSizeBits>(
157  M, 1, std::ceil(std::log2(DEFAULT_MAX_NUM_BASES)), match_location,
158  bytes)
159  {
160  }
161 };
162 
163 class Base64Delta8 : public BaseDelta<uint64_t, 8>
164 {
165  public:
166  typedef Base64Delta8Params Params;
167  Base64Delta8(const Params &p);
168  ~Base64Delta8() = default;
169 };
170 
171 class Base64Delta16 : public BaseDelta<uint64_t, 16>
172 {
173  public:
174  typedef Base64Delta16Params Params;
175  Base64Delta16(const Params &p);
176  ~Base64Delta16() = default;
177 };
178 
179 class Base64Delta32 : public BaseDelta<uint64_t, 32>
180 {
181  public:
182  typedef Base64Delta32Params Params;
183  Base64Delta32(const Params &p);
184  ~Base64Delta32() = default;
185 };
186 
187 class Base32Delta8 : public BaseDelta<uint32_t, 8>
188 {
189  public:
190  typedef Base32Delta8Params Params;
191  Base32Delta8(const Params &p);
192  ~Base32Delta8() = default;
193 };
194 
195 class Base32Delta16 : public BaseDelta<uint32_t, 16>
196 {
197  public:
198  typedef Base32Delta16Params Params;
199  Base32Delta16(const Params &p);
200  ~Base32Delta16() = default;
201 };
202 
203 class Base16Delta8 : public BaseDelta<uint16_t, 8>
204 {
205  public:
206  typedef Base16Delta8Params Params;
207  Base16Delta8(const Params &p);
208  ~Base16Delta8() = default;
209 };
210 
211 } // namespace compression
212 } // namespace gem5
213 
214 #endif //__MEM_CACHE_COMPRESSORS_BASE_DELTA_HH__
gem5::compression::Base64Delta16
Definition: base_delta.hh:171
gem5::compression::Base16Delta8::Base16Delta8
Base16Delta8(const Params &p)
Definition: base_delta.cc:73
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:74
gem5::compression::BaseDelta::PatternM::PatternM
PatternM(const DictionaryEntry bytes, const int match_location)
Definition: base_delta.hh:155
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:117
gem5::compression::BaseDelta::X
@ X
Definition: base_delta.hh:89
gem5::compression::BaseDelta::PatternFactory
typename DictionaryCompressor< BaseType >::template Factory< PatternM, PatternX > PatternFactory
Convenience factory declaration.
Definition: base_delta.hh:99
gem5::compression::BaseDelta
Base class for all base-delta-immediate compressors.
Definition: base_delta.hh:69
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:92
gem5::compression::Base32Delta8
Definition: base_delta.hh:187
gem5::compression::BaseDelta::getName
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: base_delta.hh:110
gem5::compression::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:201
std::vector
STL vector class.
Definition: stl.hh:37
gem5::compression::Base64Delta32::Params
Base64Delta32Params Params
Definition: base_delta.hh:182
gem5::compression::Base64Delta32::Base64Delta32
Base64Delta32(const Params &p)
Definition: base_delta.cc:58
gem5::compression::BaseDelta< uint64_t, 16 >::PatternNumber
PatternNumber
The patterns proposed in the paper.
Definition: base_delta.hh:87
gem5::compression::BaseDelta< uint64_t, 16 >::DictionaryEntry
typename DictionaryCompressor< uint64_t >::DictionaryEntry DictionaryEntry
Definition: base_delta.hh:75
gem5::compression::Base64Delta8
Definition: base_delta.hh:163
gem5::compression::Base16Delta8::Params
Base16Delta8Params Params
Definition: base_delta.hh:206
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:89
gem5::compression::Base32Delta8::Base32Delta8
Base32Delta8(const Params &p)
Definition: base_delta.cc:63
dictionary_compressor.hh
gem5::compression::BaseDelta::~BaseDelta
~BaseDelta()=default
gem5::compression::Base32Delta16::Base32Delta16
Base32Delta16(const Params &p)
Definition: base_delta.cc:68
bitfield.hh
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::compression::BaseDelta::PatternM
Definition: base_delta.hh:149
gem5::compression::Base64Delta8::~Base64Delta8
~Base64Delta8()=default
gem5::compression::Base32Delta8::Params
Base32Delta8Params Params
Definition: base_delta.hh:190
gem5::compression::Base64Delta16::Base64Delta16
Base64Delta16(const Params &p)
Definition: base_delta.cc:53
gem5::compression::Base64Delta32
Definition: base_delta.hh:179
gem5::compression::Base64Delta8::Params
Base64Delta8Params Params
Definition: base_delta.hh:166
gem5::compression::Base32Delta16
Definition: base_delta.hh:195
gem5::compression::Base32Delta8::~Base32Delta8
~Base32Delta8()=default
gem5::compression::Base64Delta16::Params
Base64Delta16Params Params
Definition: base_delta.hh:174
gem5::compression::Base64Delta8::Base64Delta8
Base64Delta8(const Params &p)
Definition: base_delta.cc:48
gem5::compression::BaseDelta::DEFAULT_MAX_NUM_BASES
static constexpr int DEFAULT_MAX_NUM_BASES
Definition: base_delta.hh:72
gem5::compression::Base32Delta16::Params
Base32Delta16Params Params
Definition: base_delta.hh:198
gem5::compression::BaseDelta::PatternX
Definition: base_delta.hh:134
gem5::compression::BaseDelta::Params
BaseDictionaryCompressorParams Params
Definition: base_delta.hh:128
std
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2909
gem5::compression::BaseDelta::resetDictionary
void resetDictionary() override
Clear all dictionary entries.
Definition: base_delta_impl.hh:54
gem5::compression::BaseDelta::PatternX::PatternX
PatternX(const DictionaryEntry bytes, const int match_location)
Definition: base_delta.hh:140
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:102
gem5::compression::Base64Delta32::~Base64Delta32
~Base64Delta32()=default
gem5::compression::BaseDelta::addToDictionary
void addToDictionary(DictionaryEntry data) override
Definition: base_delta_impl.hh:64
gem5::compression::BaseDelta::BaseDelta
BaseDelta(const Params &p)
Definition: base_delta_impl.hh:47
gem5::compression::Base16Delta8::~Base16Delta8
~Base16Delta8()=default
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::compression::Base16Delta8
Definition: base_delta.hh:203
gem5::compression::BaseDelta::M
@ M
Definition: base_delta.hh:89

Generated on Sun Jul 30 2023 01:56:57 for gem5 by doxygen 1.8.17