gem5  v20.1.0.0
zero.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 
34 #ifndef __MEM_CACHE_COMPRESSORS_ZERO_HH__
35 #define __MEM_CACHE_COMPRESSORS_ZERO_HH__
36 
37 #include <array>
38 #include <cstdint>
39 #include <map>
40 #include <memory>
41 
43 
44 struct ZeroCompressorParams;
45 
46 namespace Compressor {
47 
48 class Zero : public DictionaryCompressor<uint64_t>
49 {
50  protected:
52 
53  // Forward declaration of all possible patterns
54  class PatternX;
55  class PatternZ;
56 
63  typedef enum {
65  } PatternNumber;
66 
71  using PatternFactory = Factory<PatternZ, PatternX>;
72 
73  uint64_t getNumPatterns() const override { return NUM_PATTERNS; }
74 
75  std::string
76  getName(int number) const override
77  {
78  static std::map<int, std::string> pattern_names = {
79  {X, "X"}, {Z, "Z"}
80  };
81 
82  return pattern_names[number];
83  };
84 
85  std::unique_ptr<Pattern>
86  getPattern(const DictionaryEntry& bytes, const DictionaryEntry& dict_bytes,
87  const int match_location) const override
88  {
89  return PatternFactory::getPattern(bytes, dict_bytes, match_location);
90  }
91 
92  void addToDictionary(DictionaryEntry data) override;
93 
94  std::unique_ptr<Base::CompressionData> compress(
95  const std::vector<Base::Chunk>& chunks,
96  Cycles& comp_lat, Cycles& decomp_lat) override;
97 
98  public:
99  typedef ZeroCompressorParams Params;
100  Zero(const Params *p);
101  ~Zero() = default;
102 };
103 
106 {
107  public:
108  PatternX(const DictionaryEntry bytes, const int match_location)
109  : DictionaryCompressor::UncompressedPattern(X, 0, 0, match_location,
110  bytes)
111  {
112  }
113 };
114 
116  : public DictionaryCompressor::MaskedValuePattern<0, 0xFFFFFFFFFFFFFFFF>
117 {
118  public:
119  PatternZ(const DictionaryEntry bytes, const int match_location)
120  : DictionaryCompressor::MaskedValuePattern<0, 0xFFFFFFFFFFFFFFFF>(
121  Z, 1, 0, match_location, bytes)
122  {
123  }
124 };
125 
126 } // namespace Compressor
127 
128 #endif //__MEM_CACHE_COMPRESSORS_ZERO_HH__
Compressor::Zero::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: zero.cc:56
Compressor::Zero::PatternNumber
PatternNumber
The patterns proposed in the paper.
Definition: zero.hh:63
Compressor::Zero::PatternX
Definition: zero.hh:104
Compressor::Zero::getNumPatterns
uint64_t getNumPatterns() const override
Trick function to get the number of patterns.
Definition: zero.hh:73
data
const char data[]
Definition: circlebuf.test.cc:42
Compressor::Zero::PatternZ::PatternZ
PatternZ(const DictionaryEntry bytes, const int match_location)
Definition: zero.hh:119
Compressor::Zero::DictionaryEntry
DictionaryCompressor< uint64_t >::DictionaryEntry DictionaryEntry
Definition: zero.hh:51
Compressor::Zero
Definition: zero.hh:48
Compressor
Definition: base.cc:46
std::vector
STL vector class.
Definition: stl.hh:37
Compressor::Zero::Z
@ Z
Definition: zero.hh:64
Compressor::Zero::Params
ZeroCompressorParams Params
Definition: zero.hh:99
Compressor::Zero::PatternFactory
Factory< PatternZ, PatternX > PatternFactory
Convenience factory declaration.
Definition: zero.hh:71
Compressor::Zero::~Zero
~Zero()=default
dictionary_compressor.hh
Compressor::Zero::addToDictionary
void addToDictionary(DictionaryEntry data) override
Definition: zero.cc:49
Compressor::Zero::NUM_PATTERNS
@ NUM_PATTERNS
Definition: zero.hh:64
Compressor::DictionaryCompressor
A template version of the dictionary compressor that allows to choose the dictionary size.
Definition: dictionary_compressor.hh:112
Compressor::DictionaryCompressor::MaskedValuePattern< 0, 0xFFFFFFFFFFFFFFFF >::MaskedValuePattern
MaskedValuePattern(const int number, const uint64_t code, const uint64_t metadata_length, const int match_location, const DictionaryEntry bytes, const bool allocate=false)
Definition: dictionary_compressor.hh:527
Compressor::Zero::PatternZ
Definition: zero.hh:115
Compressor::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:168
Compressor::Zero::X
@ X
Definition: zero.hh:64
Compressor::DictionaryCompressor::MaskedValuePattern
A pattern that compares masked values to a masked portion of a fixed value.
Definition: dictionary_compressor.hh:130
Compressor::Zero::getName
std::string getName(int number) const override
Get meta-name assigned to the given pattern.
Definition: zero.hh:76
Compressor::DictionaryCompressor::UncompressedPattern::UncompressedPattern
UncompressedPattern(const int number, const uint64_t code, const uint64_t metadata_length, const int match_location, const DictionaryEntry bytes)
Definition: dictionary_compressor.hh:418
Compressor::Zero::Zero
Zero(const Params *p)
Definition: zero.cc:43
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Compressor::Zero::getPattern
std::unique_ptr< Pattern > getPattern(const DictionaryEntry &bytes, const DictionaryEntry &dict_bytes, const int match_location) const override
Definition: zero.hh:86
Compressor::Zero::PatternX::PatternX
PatternX(const DictionaryEntry bytes, const int match_location)
Definition: zero.hh:108
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Compressor::DictionaryCompressor::UncompressedPattern
A pattern containing the original uncompressed data.
Definition: dictionary_compressor.hh:410

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