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

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17