gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 namespace compression
38 {
39 
40 FPC::FPCCompData::FPCCompData(int zero_run_size_bits)
41  : CompData(), zeroRunSizeBits(zero_run_size_bits)
42 {
43 }
44 
45 void
46 FPC::FPCCompData::addEntry(std::unique_ptr<Pattern> pattern)
47 {
48  // If this is a zero match, check for zero runs
49  if (pattern->getPatternNumber() == ZERO_RUN) {
50  // If it is a new zero run, create it; otherwise, increase current
51  // run's length
52  if (!entries.size() ||
53  (entries.back()->getPatternNumber() != ZERO_RUN)) {
54  static_cast<ZeroRun*>(pattern.get())->setRealSize(zeroRunSizeBits);
55  } else {
56  // A zero run has a maximum length, given by the number of bits
57  // used to represent it. When this limit is reached, a new run
58  // must be created
59  const int run_length =
60  static_cast<ZeroRun*>(entries.back().get())->getRunLength();
61  if (run_length == mask(zeroRunSizeBits)) {
62  // The limit for this zero run has been reached, so a new
63  // run must be started, with a sized pattern
64  static_cast<ZeroRun*>(pattern.get())->setRealSize(
66  } else {
67  // Increase the current run's length.
68  // Since the first zero entry of the run contains the size,
69  // and all the following ones are created just to simplify
70  // decompression, this fake pattern will have a size of 0 bits
71  static_cast<ZeroRun*>(pattern.get())->setRunLength(
72  run_length + 1);
73  }
74  }
75  }
76 
77  CompData::addEntry(std::move(pattern));
78 }
79 
80 FPC::FPC(const Params &p)
81  : DictionaryCompressor<uint32_t>(p), zeroRunSizeBits(p.zero_run_bits)
82 {
83 }
84 
85 void
87 {
88  // There is no dictionary in FPC, so its size is zero, and no pattern
89  // causes an insertion in the dictionary. The only reason we do not
90  // assert it is that the UncompressedPattern implementation always
91  // inserts by default
92 }
93 
94 std::unique_ptr<DictionaryCompressor<uint32_t>::CompData>
96 {
97  return std::unique_ptr<DictionaryCompressor<uint32_t>::CompData>(
99 }
100 
101 } // namespace compression
102 } // namespace gem5
gem5::compression::FPC::addToDictionary
void addToDictionary(const DictionaryEntry data) override
Definition: fpc.cc:86
fpc.hh
gem5::compression::DictionaryCompressor
A template version of the dictionary compressor that allows to choose the dictionary size.
Definition: dictionary_compressor.hh:117
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:46
gem5::compression::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:201
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:40
gem5::compression::FPC::FPC
FPC(const Params &p)
Definition: fpc.cc:80
gem5::compression::FPC::zeroRunSizeBits
const int zeroRunSizeBits
Number of bits of the zero run size bitfield.
Definition: fpc.hh:94
dictionary_compressor_impl.hh
gem5::compression::FPC::ZERO_RUN
@ ZERO_RUN
Definition: fpc.hh:84
gem5::compression::FPC::FPCCompData
Definition: fpc.hh:137
gem5::compression::FPC::ZeroRun
Definition: fpc.hh:155
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:95
gem5::compression::FPC::DictionaryEntry
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition: fpc.hh:60

Generated on Sun Jul 30 2023 01:56:57 for gem5 by doxygen 1.8.17