gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
34namespace gem5
35{
36
37namespace compression
38{
39
40FPC::FPCCompData::FPCCompData(int zero_run_size_bits)
41 : CompData(), zeroRunSizeBits(zero_run_size_bits)
42{
43}
44
45void
46FPC::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
81 : DictionaryCompressor<uint32_t>(p), zeroRunSizeBits(p.zero_run_bits)
82{
83}
84
85void
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
94std::unique_ptr<DictionaryCompressor<uint32_t>::CompData>
96{
97 return std::unique_ptr<DictionaryCompressor<uint32_t>::CompData>(
99}
100
101} // namespace compression
102} // namespace gem5
const char data[]
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:46
FPCCompData(int zeroRunSizeBits)
Definition fpc.cc:40
const int zeroRunSizeBits
Number of bits of the zero run size bitfield.
Definition fpc.hh:94
DictionaryCompressor< uint32_t >::DictionaryEntry DictionaryEntry
Definition fpc.hh:60
FPC(const Params &p)
Definition fpc.cc:80
std::unique_ptr< DictionaryCompressor::CompData > instantiateDictionaryCompData() const override
Instantiate a compression data of the sub-class compressor.
Definition fpc.cc:95
FPCParams Params
Definition fpc.hh:132
void addToDictionary(const DictionaryEntry data) override
Definition fpc.cc:86
Implementation of a dictionary based cache compressor.
Definition of the Frequent Pattern Compression cache compressor, as described in "Frequent Pattern Co...
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0