gem5  v22.0.0.1
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
gem5::compression::FPC::addToDictionary
void addToDictionary(const DictionaryEntry data) override
Definition: fpc.cc:87
fpc.hh
gem5::compression::DictionaryCompressor
A template version of the dictionary compressor that allows to choose the dictionary size.
Definition: dictionary_compressor.hh:118
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::compression::FPC::FPCCompData::addEntry
void addEntry(std::unique_ptr< Pattern > pattern) override
Definition: fpc.cc:47
gem5::compression::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:202
gem5::mask
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::compression::FPC::FPCCompData::FPCCompData
FPCCompData(int zeroRunSizeBits)
Definition: fpc.cc:41
gem5::compression::FPC::FPC
FPC(const Params &p)
Definition: fpc.cc:81
gem5::compression::FPC::zeroRunSizeBits
const int zeroRunSizeBits
Number of bits of the zero run size bitfield.
Definition: fpc.hh:95
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
dictionary_compressor_impl.hh
gem5::compression::FPC::ZERO_RUN
@ ZERO_RUN
Definition: fpc.hh:85
gem5::compression::FPC::FPCCompData
Definition: fpc.hh:138
gem5::compression::FPC::ZeroRun
Definition: fpc.hh:156
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::compression::FPC::instantiateDictionaryCompData
std::unique_ptr< DictionaryCompressor::CompData > instantiateDictionaryCompData() const override
Definition: fpc.cc:96
gem5::compression::FPC::DictionaryEntry
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition: fpc.hh:61

Generated on Sat Jun 18 2022 08:12:27 for gem5 by doxygen 1.8.17