gem5  v22.1.0.0
fpc.cc
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 
30 
32 #include "params/FPC.hh"
33 
34 namespace gem5
35 {
36 
37 GEM5_DEPRECATED_NAMESPACE(Compressor, compression);
38 namespace compression
39 {
40 
41 FPC::FPCCompData::FPCCompData(int zero_run_size_bits)
42  : CompData(), zeroRunSizeBits(zero_run_size_bits)
43 {
44 }
45 
46 void
47 FPC::FPCCompData::addEntry(std::unique_ptr<Pattern> pattern)
48 {
49  // If this is a zero match, check for zero runs
50  if (pattern->getPatternNumber() == ZERO_RUN) {
51  // If it is a new zero run, create it; otherwise, increase current
52  // run's length
53  if (!entries.size() ||
54  (entries.back()->getPatternNumber() != ZERO_RUN)) {
55  static_cast<ZeroRun*>(pattern.get())->setRealSize(zeroRunSizeBits);
56  } else {
57  // A zero run has a maximum length, given by the number of bits
58  // used to represent it. When this limit is reached, a new run
59  // must be created
60  const int run_length =
61  static_cast<ZeroRun*>(entries.back().get())->getRunLength();
62  if (run_length == mask(zeroRunSizeBits)) {
63  // The limit for this zero run has been reached, so a new
64  // run must be started, with a sized pattern
65  static_cast<ZeroRun*>(pattern.get())->setRealSize(
67  } else {
68  // Increase the current run's length.
69  // Since the first zero entry of the run contains the size,
70  // and all the following ones are created just to simplify
71  // decompression, this fake pattern will have a size of 0 bits
72  static_cast<ZeroRun*>(pattern.get())->setRunLength(
73  run_length + 1);
74  }
75  }
76  }
77 
78  CompData::addEntry(std::move(pattern));
79 }
80 
81 FPC::FPC(const Params &p)
82  : DictionaryCompressor<uint32_t>(p), zeroRunSizeBits(p.zero_run_bits)
83 {
84 }
85 
86 void
88 {
89  // There is no dictionary in FPC, so its size is zero, and no pattern
90  // causes an insertion in the dictionary. The only reason we do not
91  // assert it is that the UncompressedPattern implementation always
92  // inserts by default
93 }
94 
95 std::unique_ptr<DictionaryCompressor<uint32_t>::CompData>
97 {
98  return std::unique_ptr<DictionaryCompressor<uint32_t>::CompData>(
100 }
101 
102 } // namespace compression
103 } // namespace gem5
const char data[]
BaseCacheCompressorParams Params
Definition: base.hh:202
A template version of the dictionary compressor that allows to choose the dictionary size.
void addEntry(std::unique_ptr< Pattern > pattern) override
Definition: fpc.cc:47
FPCCompData(int zeroRunSizeBits)
Definition: fpc.cc:41
const int zeroRunSizeBits
Number of bits of the zero run size bitfield.
Definition: fpc.hh:95
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition: fpc.hh:61
FPC(const Params &p)
Definition: fpc.cc:81
std::unique_ptr< DictionaryCompressor::CompData > instantiateDictionaryCompData() const override
Instantiate a compression data of the sub-class compressor.
Definition: fpc.cc:96
void addToDictionary(const DictionaryEntry data) override
Definition: fpc.cc:87
Implementation of a dictionary based cache compressor.
Definition of the Frequent Pattern Compression cache compressor, as described in "Frequent Pattern Co...
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)

Generated on Wed Dec 21 2022 10:22:36 for gem5 by doxygen 1.9.1