gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
44namespace gem5
45{
46
47struct BaseDictionaryCompressorParams;
48struct Base64Delta8Params;
49struct Base64Delta16Params;
50struct Base64Delta32Params;
51struct Base32Delta8Params;
52struct Base32Delta16Params;
53struct Base16Delta8Params;
54
55namespace compression
56{
57
68template <class BaseType, std::size_t DeltaSizeBits>
69class BaseDelta : public DictionaryCompressor<BaseType>
70{
71 protected:
72 static constexpr int DEFAULT_MAX_NUM_BASES = 2;
73
76
77 // Forward declaration of all possible patterns
78 class PatternX;
79 class PatternM;
80
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
133template <class BaseType, std::size_t DeltaSizeBits>
134class 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
148template <class BaseType, std::size_t DeltaSizeBits>
149class 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
163class Base64Delta8 : public BaseDelta<uint64_t, 8>
164{
165 public:
166 typedef Base64Delta8Params Params;
167 Base64Delta8(const Params &p);
168 ~Base64Delta8() = default;
169};
170
171class Base64Delta16 : public BaseDelta<uint64_t, 16>
172{
173 public:
174 typedef Base64Delta16Params Params;
175 Base64Delta16(const Params &p);
176 ~Base64Delta16() = default;
177};
178
179class Base64Delta32 : public BaseDelta<uint64_t, 32>
180{
181 public:
182 typedef Base64Delta32Params Params;
183 Base64Delta32(const Params &p);
184 ~Base64Delta32() = default;
185};
186
187class Base32Delta8 : public BaseDelta<uint32_t, 8>
188{
189 public:
190 typedef Base32Delta8Params Params;
191 Base32Delta8(const Params &p);
192 ~Base32Delta8() = default;
193};
194
195class Base32Delta16 : public BaseDelta<uint32_t, 16>
196{
197 public:
198 typedef Base32Delta16Params Params;
199 Base32Delta16(const Params &p);
200 ~Base32Delta16() = default;
201};
202
203class 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__
const char data[]
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
PatternM(const DictionaryEntry bytes, const int match_location)
PatternX(const DictionaryEntry bytes, const int match_location)
Base class for all base-delta-immediate compressors.
Definition base_delta.hh:70
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.
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
typename DictionaryCompressor< BaseType >::DictionaryEntry DictionaryEntry
Definition base_delta.hh:74
typename DictionaryCompressor< BaseType >::template Factory< PatternM, PatternX > PatternFactory
Convenience factory declaration.
Definition base_delta.hh:98
PatternNumber
The patterns proposed in the paper.
Definition base_delta.hh:88
static constexpr int DEFAULT_MAX_NUM_BASES
Definition base_delta.hh:72
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition base_delta.hh:92
std::unique_ptr< typename DictionaryCompressor< BaseType >::Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const override
BaseDictionaryCompressorParams Params
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.
STL vector class.
Definition stl.hh:37
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
Overload hash function for BasicBlockRange type.
Definition binary32.hh:81

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