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

Generated on Mon Jun 8 2020 15:45:11 for gem5 by doxygen 1.8.13