gem5  v22.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 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 
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__
const char data[]
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
Base16Delta8(const Params &p)
Definition: base_delta.cc:74
Base32Delta16(const Params &p)
Definition: base_delta.cc:69
Base32Delta16Params Params
Definition: base_delta.hh:199
Base32Delta8(const Params &p)
Definition: base_delta.cc:64
Base64Delta16Params Params
Definition: base_delta.hh:175
Base64Delta16(const Params &p)
Definition: base_delta.cc:54
Base64Delta32(const Params &p)
Definition: base_delta.cc:59
Base64Delta32Params Params
Definition: base_delta.hh:183
Base64Delta8(const Params &p)
Definition: base_delta.cc:49
PatternM(const DictionaryEntry bytes, const int match_location)
Definition: base_delta.hh:156
PatternX(const DictionaryEntry bytes, const int match_location)
Definition: base_delta.hh:141
Base class for all base-delta-immediate compressors.
Definition: base_delta.hh:71
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
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.
void addToDictionary(DictionaryEntry data) override
void resetDictionary() override
Clear all dictionary entries.
typename DictionaryCompressor< BaseType >::DictionaryEntry DictionaryEntry
Definition: base_delta.hh:76
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: base_delta.hh:111
typename DictionaryCompressor< BaseType >::template Factory< PatternM, PatternX > PatternFactory
Convenience factory declaration.
Definition: base_delta.hh:100
PatternNumber
The patterns proposed in the paper.
Definition: base_delta.hh:89
static constexpr int DEFAULT_MAX_NUM_BASES
Definition: base_delta.hh:73
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition: base_delta.hh:93
BaseDictionaryCompressorParams Params
Definition: base_delta.hh:129
BaseCacheCompressorParams Params
Definition: base.hh:202
A template version of the dictionary compressor that allows to choose the dictionary size.
STL vector class.
Definition: stl.hh:37
Definition of a dictionary based cache compressor.
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2826

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