gem5  v20.1.0.0
cpack.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-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 
34 #ifndef __MEM_CACHE_COMPRESSORS_CPACK_HH__
35 #define __MEM_CACHE_COMPRESSORS_CPACK_HH__
36 
37 #include <cstdint>
38 #include <map>
39 #include <memory>
40 
41 #include "base/types.hh"
43 
44 struct CPackParams;
45 
46 namespace Compressor {
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 
75  using PatternFactory = Factory<PatternZZZZ, PatternMMMM, PatternZZZX,
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 
101  std::unique_ptr<Base::CompressionData> compress(
102  const std::vector<Base::Chunk>& chunks,
103  Cycles& comp_lat, Cycles& decomp_lat) override;
104 
105  public:
107  typedef CPackParams Params;
108 
112  CPack(const Params *p);
113 
117  ~CPack() {};
118 };
119 
120 class CPack::PatternZZZZ : public MaskedValuePattern<0, 0xFFFFFFFF>
121 {
122  public:
123  PatternZZZZ(const DictionaryEntry bytes, const int match_location)
124  : MaskedValuePattern<0, 0xFFFFFFFF>(ZZZZ, 0x0, 2, match_location,
125  bytes)
126  {
127  }
128 };
129 
130 class CPack::PatternXXXX : public UncompressedPattern
131 {
132  public:
133  PatternXXXX(const DictionaryEntry bytes, const int match_location)
134  : UncompressedPattern(XXXX, 0x1, 2, match_location, bytes)
135  {
136  }
137 };
138 
139 class CPack::PatternMMMM : public MaskedPattern<0xFFFFFFFF>
140 {
141  public:
142  PatternMMMM(const DictionaryEntry bytes, const int match_location)
143  : MaskedPattern<0xFFFFFFFF>(MMMM, 0x2, 6, match_location, bytes, true)
144  {
145  }
146 };
147 
148 class CPack::PatternMMXX : public MaskedPattern<0xFFFF0000>
149 {
150  public:
151  PatternMMXX(const DictionaryEntry bytes, const int match_location)
152  : MaskedPattern<0xFFFF0000>(MMXX, 0xC, 8, match_location, bytes, true)
153  {
154  }
155 };
156 
157 class CPack::PatternZZZX : public MaskedValuePattern<0, 0xFFFFFF00>
158 {
159  public:
160  PatternZZZX(const DictionaryEntry bytes, const int match_location)
161  : MaskedValuePattern<0, 0xFFFFFF00>(ZZZX, 0xD, 4, match_location,
162  bytes)
163  {
164  }
165 };
166 
167 class CPack::PatternMMMX : public MaskedPattern<0xFFFFFF00>
168 {
169  public:
170  PatternMMMX(const DictionaryEntry bytes, const int match_location)
171  : MaskedPattern<0xFFFFFF00>(MMMX, 0xE, 8, match_location, bytes, true)
172  {
173  }
174 };
175 
176 } // namespace Compressor
177 
178 #endif //__MEM_CACHE_COMPRESSORS_CPACK_HH__
Compressor::CPack::getPattern
std::unique_ptr< Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const override
Definition: cpack.hh:91
Compressor::CPack::MMMX
@ MMMX
Definition: cpack.hh:68
data
const char data[]
Definition: circlebuf.test.cc:42
Compressor::CPack::PatternZZZZ::PatternZZZZ
PatternZZZZ(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:123
Compressor::CPack::CPack
CPack(const Params *p)
Default constructor.
Definition: cpack.cc:40
Compressor::CPack::PatternMMMM
Definition: cpack.hh:139
Compressor::CPack
Definition: cpack.hh:48
Compressor::CPack::PatternZZZZ
Definition: cpack.hh:120
Compressor::CPack::getName
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: cpack.hh:81
Compressor
Definition: base.cc:46
std::vector
STL vector class.
Definition: stl.hh:37
Compressor::CPack::compress
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.
Definition: cpack.cc:53
Compressor::CPack::PatternMMMX
Definition: cpack.hh:167
dictionary_compressor.hh
Compressor::CPack::addToDictionary
void addToDictionary(DictionaryEntry data) override
Definition: cpack.cc:46
Compressor::CPack::DictionaryEntry
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition: cpack.hh:51
Compressor::CPack::Params
CPackParams Params
Convenience typedef.
Definition: cpack.hh:107
Compressor::CPack::getNumPatterns
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition: cpack.hh:78
Compressor::DictionaryCompressor
A template version of the dictionary compressor that allows to choose the dictionary size.
Definition: dictionary_compressor.hh:112
Compressor::CPack::PatternXXXX::PatternXXXX
PatternXXXX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:133
Compressor::CPack::PatternXXXX
Definition: cpack.hh:130
Compressor::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:168
Compressor::CPack::PatternZZZX
Definition: cpack.hh:157
Compressor::CPack::ZZZZ
@ ZZZZ
Definition: cpack.hh:68
Compressor::CPack::NUM_PATTERNS
@ NUM_PATTERNS
Definition: cpack.hh:68
Compressor::CPack::PatternMMMM::PatternMMMM
PatternMMMM(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:142
Compressor::CPack::PatternMMXX::PatternMMXX
PatternMMXX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:151
Compressor::CPack::MMXX
@ MMXX
Definition: cpack.hh:68
Compressor::CPack::PatternMMMX::PatternMMMX
PatternMMMX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:170
types.hh
Compressor::CPack::~CPack
~CPack()
Default destructor.
Definition: cpack.hh:117
Compressor::CPack::PatternZZZX::PatternZZZX
PatternZZZX(const DictionaryEntry bytes, const int match_location)
Definition: cpack.hh:160
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Compressor::CPack::PatternMMXX
Definition: cpack.hh:148
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Compressor::CPack::PatternNumber
PatternNumber
The patterns proposed in the paper.
Definition: cpack.hh:67
Compressor::CPack::ZZZX
@ ZZZX
Definition: cpack.hh:68
Compressor::CPack::PatternFactory
Factory< PatternZZZZ, PatternMMMM, PatternZZZX, PatternMMMX, PatternMMXX, PatternXXXX > PatternFactory
Convenience factory declaration.
Definition: cpack.hh:76
Compressor::CPack::XXXX
@ XXXX
Definition: cpack.hh:68
Compressor::CPack::MMMM
@ MMMM
Definition: cpack.hh:68

Generated on Wed Sep 30 2020 14:02:12 for gem5 by doxygen 1.8.17