gem5  v22.1.0.0
fpcd.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 
39 #ifndef __MEM_CACHE_COMPRESSORS_FPCD_HH__
40 #define __MEM_CACHE_COMPRESSORS_FPCD_HH__
41 
42 #include <cstdint>
43 #include <map>
44 #include <memory>
45 #include <string>
46 
47 #include "base/types.hh"
49 
50 namespace gem5
51 {
52 
53 struct FPCDParams;
54 
55 GEM5_DEPRECATED_NAMESPACE(Compressor, compression);
56 namespace compression
57 {
58 
59 class FPCD : public DictionaryCompressor<uint32_t>
60 {
61  private:
63 
65  static constexpr int prefixSize = 4;
66 
68  static constexpr int previousIndex = 1;
69 
71  static constexpr int penultimateIndex = 0;
72 
73  // Declaration of all possible patterns, from lowest to highest sizes.
74  // Penultimate is prioritized over previous to reduce the ripple effect
75  // of propagating values during decompression
76  class PatternZZZZ;
77  class PatternFFFF;
79  class PatternMMMMPrevious;
80  class PatternZZZX;
81  class PatternXZZZ;
82  class PatternRRRR;
84  class PatternMMMXPrevious;
85  class PatternZZXX;
86  class PatternZXZX;
87  class PatternFFXX;
88  class PatternXXZZ;
90  class PatternMMXXPrevious;
91  class PatternXXXX;
92 
101  {
105  };
106 
117 
118  uint64_t getNumPatterns() const override { return NUM_PATTERNS; }
119 
120  std::string
121  getName(int number) const override
122  {
123  static std::map<PatternNumber, std::string> pattern_names = {
124  {ZZZZ, "ZZZZ"}, {FFFF, "FFFF"},
125  {MMMMPenultimate, "MMMMPenultimate"},
126  {MMMMPrevious, "MMMMPrevious"}, {ZZZX, "ZZZX"},
127  {XZZZ, "XZZZ"}, {RRRR, "RRRR"},
128  {MMMXPenultimate, "MMMXPenultimate"},
129  {MMMXPrevious, "MMMXPrevious"},
130  {ZZXX, "ZZXX"},
131  {ZXZX, "ZXZX"}, {FFXX, "FFXX"}, {XXZZ, "XXZZ"},
132  {MMXXPenultimate, "MMXXPenultimate"},
133  {MMXXPrevious, "MMXXPrevious"}, {XXXX, "XXXX"}
134  };
135 
136  return pattern_names[(PatternNumber)number];
137  };
138 
139  std::unique_ptr<Pattern>
140  getPattern(const DictionaryEntry& bytes, const DictionaryEntry& dict_bytes,
141  const int match_location) const override
142  {
143  return PatternFactory::getPattern(bytes, dict_bytes, match_location);
144  }
145 
146  void addToDictionary(DictionaryEntry data) override;
147 
148  public:
149  typedef FPCDParams Params;
150  FPCD(const Params &p);
151  ~FPCD() = default;
152 };
153 
154 class FPCD::PatternZZZZ : public MaskedValuePattern<0, 0xFFFFFFFF>
155 {
156  public:
157  PatternZZZZ(const DictionaryEntry bytes, const int match_location)
158  : MaskedValuePattern<0, 0xFFFFFFFF>(ZZZZ, 0x0, prefixSize,
159  match_location, bytes, true)
160  {
161  }
162 };
163 
164 class FPCD::PatternFFFF : public MaskedValuePattern<0xFFFFFFFF, 0xFFFFFFFF>
165 {
166  public:
167  PatternFFFF(const DictionaryEntry bytes, const int match_location)
168  : MaskedValuePattern<0xFFFFFFFF, 0xFFFFFFFF>(FFFF, 0x1,
169  prefixSize, match_location, bytes, true)
170  {
171  }
172 };
173 
175  : public LocatedMaskedPattern<0xFFFFFFFF, previousIndex>
176 {
177  public:
179  const int match_location)
180  : LocatedMaskedPattern<0xFFFFFFFF, previousIndex>(MMMMPrevious,
181  0x2, prefixSize, match_location, bytes)
182  {
183  }
184 };
185 
187  : public LocatedMaskedPattern<0xFFFFFFFF, penultimateIndex>
188 {
189  public:
191  const int match_location)
192  : LocatedMaskedPattern<0xFFFFFFFF, penultimateIndex>(
193  MMMMPenultimate, 0x3, prefixSize, match_location, bytes)
194  {
195  }
196 };
197 
198 class FPCD::PatternZZZX : public MaskedValuePattern<0, 0xFFFFFF00>
199 {
200  public:
201  PatternZZZX(const DictionaryEntry bytes, const int match_location)
202  : MaskedValuePattern<0, 0xFFFFFF00>(ZZZX, 0x4, prefixSize,
203  match_location, bytes, true)
204  {
205  }
206 };
207 
208 class FPCD::PatternXZZZ : public MaskedValuePattern<0, 0x00FFFFFF>
209 {
210  public:
211  PatternXZZZ(const DictionaryEntry bytes, const int match_location)
212  : MaskedValuePattern<0, 0x00FFFFFF>(XZZZ, 0x5, prefixSize,
213  match_location, bytes, true)
214  {
215  }
216 };
217 
218 class FPCD::PatternRRRR : public RepeatedValuePattern<uint8_t>
219 {
220  public:
221  PatternRRRR(const DictionaryEntry bytes, const int match_location)
222  : RepeatedValuePattern<uint8_t>(RRRR, 0x6, prefixSize,
223  match_location, bytes, true)
224  {
225  }
226 };
227 
229  : public LocatedMaskedPattern<0xFFFFFF00, previousIndex>
230 {
231  public:
233  const int match_location)
234  : LocatedMaskedPattern<0xFFFFFF00, previousIndex>(MMMXPrevious,
235  0x7, prefixSize, match_location, bytes)
236  {
237  }
238 };
239 
241  : public LocatedMaskedPattern<0xFFFFFF00, penultimateIndex>
242 {
243  public:
245  const int match_location)
246  : LocatedMaskedPattern<0xFFFFFF00, penultimateIndex>(
247  MMMXPenultimate, 0x8, prefixSize, match_location, bytes)
248  {
249  }
250 };
251 
252 class FPCD::PatternZZXX : public MaskedValuePattern<0, 0xFFFF0000>
253 {
254  public:
255  PatternZZXX(const DictionaryEntry bytes, const int match_location)
256  : MaskedValuePattern<0, 0xFFFF0000>(ZZXX, 0x9, prefixSize,
257  match_location, bytes, true)
258  {
259  }
260 };
261 
262 class FPCD::PatternZXZX : public MaskedValuePattern<0, 0xFF00FF00>
263 {
264  public:
265  PatternZXZX(const DictionaryEntry bytes, const int match_location)
266  : MaskedValuePattern<0, 0xFF00FF00>(ZXZX, 0xA, prefixSize,
267  match_location, bytes, true)
268  {
269  }
270 };
271 
272 class FPCD::PatternFFXX : public MaskedValuePattern<0xFFFFFFFF, 0xFFFF0000>
273 {
274  public:
275  PatternFFXX(const DictionaryEntry bytes, const int match_location)
276  : MaskedValuePattern<0xFFFFFFFF, 0xFFFF0000>(FFXX, 0xB,
277  prefixSize, match_location, bytes, true)
278  {
279  }
280 };
281 
282 class FPCD::PatternXXZZ : public MaskedValuePattern<0, 0x0000FFFF>
283 {
284  public:
285  PatternXXZZ(const DictionaryEntry bytes, const int match_location)
286  : MaskedValuePattern<0, 0x0000FFFF>(XXZZ, 0xC, prefixSize,
287  match_location, bytes, true)
288  {
289  }
290 };
291 
293  : public LocatedMaskedPattern<0xFFFF0000, previousIndex>
294 {
295  public:
297  const int match_location)
298  : LocatedMaskedPattern<0xFFFF0000, previousIndex>(MMXXPrevious,
299  0xD, prefixSize, match_location, bytes)
300  {
301  }
302 };
303 
305  : public LocatedMaskedPattern<0xFFFF0000, penultimateIndex>
306 {
307  public:
309  const int match_location)
310  : LocatedMaskedPattern<0xFFFF0000, penultimateIndex>(
311  MMXXPenultimate, 0xE, prefixSize, match_location, bytes)
312  {
313  }
314 };
315 
316 class FPCD::PatternXXXX : public UncompressedPattern
317 {
318  public:
319  PatternXXXX(const DictionaryEntry bytes, const int match_location)
320  : UncompressedPattern(XXXX, 0xF, prefixSize, match_location,
321  bytes)
322  {
323  }
324 };
325 
326 } // namespace compression
327 } // namespace gem5
328 
329 #endif //__MEM_CACHE_COMPRESSORS_FPCD_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
const char data[]
BaseCacheCompressorParams Params
Definition: base.hh:202
A template version of the dictionary compressor that allows to choose the dictionary size.
PatternFFFF(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:167
PatternFFXX(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:275
PatternMMMMPenultimate(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:190
PatternMMMMPrevious(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:178
PatternMMMXPenultimate(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:244
PatternMMMXPrevious(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:232
PatternMMXXPenultimate(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:308
PatternMMXXPrevious(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:296
PatternRRRR(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:221
PatternXXXX(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:319
PatternXXZZ(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:285
PatternXZZZ(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:211
PatternZXZX(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:265
PatternZZXX(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:255
PatternZZZX(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:201
PatternZZZZ(const DictionaryEntry bytes, const int match_location)
Definition: fpcd.hh:157
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: fpcd.hh:121
FPCD(const Params &p)
Definition: fpcd.cc:45
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition: fpcd.hh:118
Factory< PatternZZZZ, PatternFFFF, PatternMMMMPrevious, PatternMMMMPenultimate, PatternZZZX, PatternXZZZ, PatternRRRR, PatternMMMXPrevious, PatternMMMXPenultimate, PatternZZXX, PatternZXZX, PatternFFXX, PatternXXZZ, PatternMMXXPrevious, PatternMMXXPenultimate, PatternXXXX > PatternFactory
Convenience factory declaration.
Definition: fpcd.hh:116
static constexpr int penultimateIndex
Index of the penultimate dictionary entry.
Definition: fpcd.hh:71
std::unique_ptr< Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const override
Definition: fpcd.hh:140
static constexpr int prefixSize
Number of bits in a FPCD pattern prefix.
Definition: fpcd.hh:65
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition: fpcd.hh:62
FPCDParams Params
Definition: fpcd.hh:149
static constexpr int previousIndex
Index of the previous dictionary entry.
Definition: fpcd.hh:68
PatternNumber
The patterns proposed in the paper.
Definition: fpcd.hh:101
void addToDictionary(DictionaryEntry data) override
Definition: fpcd.cc:51
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)

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