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

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0