gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpack.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-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  * Authors: Daniel Carvalho
29  */
30 
36 #ifndef __MEM_CACHE_COMPRESSORS_CPACK_HH__
37 #define __MEM_CACHE_COMPRESSORS_CPACK_HH__
38 
39 #include <cstdint>
40 #include <map>
41 #include <memory>
42 
43 #include "base/types.hh"
45 
46 struct CPackParams;
47 
48 class CPack : public DictionaryCompressor<uint32_t>
49 {
50  private:
52 
53  // Forward declaration of all possible patterns
54  class PatternZZZZ;
55  class PatternXXXX;
56  class PatternMMMM;
57  class PatternMMXX;
58  class PatternZZZX;
59  class PatternMMMX;
60 
67  typedef enum {
69  } PatternNumber;
70 
77 
78  uint64_t getNumPatterns() const override { return NUM_PATTERNS; }
79 
80  std::string
81  getName(int number) const override
82  {
83  static std::map<int, std::string> patternNames = {
84  {ZZZZ, "ZZZZ"}, {XXXX, "XXXX"}, {MMMM, "MMMM"},
85  {MMXX, "MMXX"}, {ZZZX, "ZZZX"}, {MMMX, "MMMX"}
86  };
87 
88  return patternNames[number];
89  };
90 
91  std::unique_ptr<Pattern> getPattern(
92  const DictionaryEntry& bytes,
93  const DictionaryEntry& dict_bytes,
94  const int match_location) const override
95  {
96  return PatternFactory::getPattern(bytes, dict_bytes, match_location);
97  }
98 
99  void addToDictionary(DictionaryEntry data) override;
100 
109  std::unique_ptr<BaseCacheCompressor::CompressionData> compress(
110  const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat) override;
111 
112  public:
114  typedef CPackParams Params;
115 
119  CPack(const Params *p);
120 
124  ~CPack() {};
125 };
126 
127 class CPack::PatternZZZZ : public MaskedValuePattern<0, 0xFFFFFFFF>
128 {
129  public:
130  PatternZZZZ(const DictionaryEntry bytes, const int match_location)
131  : MaskedValuePattern<0, 0xFFFFFFFF>(ZZZZ, 0x0, 2, match_location,
132  bytes)
133  {
134  }
135 };
136 
137 class CPack::PatternXXXX : public UncompressedPattern
138 {
139  public:
140  PatternXXXX(const DictionaryEntry bytes, const int match_location)
141  : UncompressedPattern(XXXX, 0x1, 2, match_location, bytes)
142  {
143  }
144 };
145 
146 class CPack::PatternMMMM : public MaskedPattern<0xFFFFFFFF>
147 {
148  public:
149  PatternMMMM(const DictionaryEntry bytes, const int match_location)
150  : MaskedPattern<0xFFFFFFFF>(MMMM, 0x2, 6, match_location, bytes, true)
151  {
152  }
153 };
154 
155 class CPack::PatternMMXX : public MaskedPattern<0xFFFF0000>
156 {
157  public:
158  PatternMMXX(const DictionaryEntry bytes, const int match_location)
159  : MaskedPattern<0xFFFF0000>(MMXX, 0xC, 8, match_location, bytes, true)
160  {
161  }
162 };
163 
164 class CPack::PatternZZZX : public MaskedValuePattern<0, 0xFFFFFF00>
165 {
166  public:
167  PatternZZZX(const DictionaryEntry bytes, const int match_location)
168  : MaskedValuePattern<0, 0xFFFFFF00>(ZZZX, 0xD, 4, match_location,
169  bytes)
170  {
171  }
172 };
173 
174 class CPack::PatternMMMX : public MaskedPattern<0xFFFFFF00>
175 {
176  public:
177  PatternMMMX(const DictionaryEntry bytes, const int match_location)
178  : MaskedPattern<0xFFFFFF00>(MMMX, 0xE, 8, match_location, bytes, true)
179  {
180  }
181 };
182 
183 #endif //__MEM_CACHE_COMPRESSORS_CPACK_HH__
CPack(const Params *p)
Default constructor.
Definition: cpack.cc:40
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
PatternMMMM(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:149
std::unique_ptr< Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const override
Definition: cpack.hh:91
CPackParams Params
Convenience typedef.
Definition: cpack.hh:114
PatternXXXX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:140
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition: cpack.hh:78
PatternZZZX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:167
Definition: cpack.hh:48
void addToDictionary(DictionaryEntry data) override
Definition: cpack.cc:46
PatternMMMX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:177
std::unique_ptr< BaseCacheCompressor::CompressionData > compress(const uint64_t *data, Cycles &comp_lat, Cycles &decomp_lat) override
Apply compression.
Definition: cpack.cc:53
PatternZZZZ(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:130
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: cpack.hh:81
Definition of a dictionary based cache compressor.
PatternMMXX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:158
PatternNumber
The patterns proposed in the paper.
Definition: cpack.hh:67
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition: cpack.hh:51
Factory< PatternZZZZ, PatternMMMM, PatternZZZX, PatternMMMX, PatternMMXX, PatternXXXX > PatternFactory
Convenience factory declaration.
Definition: cpack.hh:76
~CPack()
Default destructor.
Definition: cpack.hh:124
Bitfield< 0 > p
const char data[]
A template version of the dictionary compressor that allows to choose the dictionary size...

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13