1 # Copyright (c) 2018-2020 Inria
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met: redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer;
8 # redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution;
11 # neither the name of the copyright holders nor the names of its
12 # contributors may be used to endorse or promote products derived from
13 # this software without specific prior written permission.
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 from m5
.params
import *
28 from m5
.proxy
import *
29 from m5
.SimObject
import SimObject
31 class BaseCacheCompressor(SimObject
):
32 type = 'BaseCacheCompressor'
34 cxx_class
= 'Compressor::Base'
35 cxx_header
= "mem/cache/compressors/base.hh"
37 block_size
= Param
.Int(Parent
.cache_line_size
, "Block size in bytes")
38 chunk_size_bits
= Param
.Unsigned(32,
39 "Size of a parsing data chunk (in bits)")
40 size_threshold
= Param
.Unsigned(Parent
.cache_line_size
, "Minimum size, "
41 "in bytes, in which a block must be compressed to. Otherwise it is "
42 "stored in its uncompressed state")
44 class BaseDictionaryCompressor(BaseCacheCompressor
):
45 type = 'BaseDictionaryCompressor'
47 cxx_class
= 'Compressor::BaseDictionaryCompressor'
48 cxx_header
= "mem/cache/compressors/dictionary_compressor.hh"
50 dictionary_size
= Param
.Int(Parent
.cache_line_size
,
51 "Number of dictionary entries")
53 class Base64Delta8(BaseDictionaryCompressor
):
55 cxx_class
= 'Compressor::Base64Delta8'
56 cxx_header
= "mem/cache/compressors/base_delta.hh"
60 class Base64Delta16(BaseDictionaryCompressor
):
61 type = 'Base64Delta16'
62 cxx_class
= 'Compressor::Base64Delta16'
63 cxx_header
= "mem/cache/compressors/base_delta.hh"
67 class Base64Delta32(BaseDictionaryCompressor
):
68 type = 'Base64Delta32'
69 cxx_class
= 'Compressor::Base64Delta32'
70 cxx_header
= "mem/cache/compressors/base_delta.hh"
74 class Base32Delta8(BaseDictionaryCompressor
):
76 cxx_class
= 'Compressor::Base32Delta8'
77 cxx_header
= "mem/cache/compressors/base_delta.hh"
81 class Base32Delta16(BaseDictionaryCompressor
):
82 type = 'Base32Delta16'
83 cxx_class
= 'Compressor::Base32Delta16'
84 cxx_header
= "mem/cache/compressors/base_delta.hh"
88 class Base16Delta8(BaseDictionaryCompressor
):
90 cxx_class
= 'Compressor::Base16Delta8'
91 cxx_header
= "mem/cache/compressors/base_delta.hh"
95 class CPack(BaseDictionaryCompressor
):
97 cxx_class
= 'Compressor::CPack'
98 cxx_header
= "mem/cache/compressors/cpack.hh"
100 class FPCD(BaseDictionaryCompressor
):
102 cxx_class
= 'Compressor::FPCD'
103 cxx_header
= "mem/cache/compressors/fpcd.hh"
107 class MultiCompressor(BaseCacheCompressor
):
108 type = 'MultiCompressor'
109 cxx_class
= 'Compressor::Multi'
110 cxx_header
= "mem/cache/compressors/multi.hh"
112 # Dummy default compressor list. This might not be an optimal choice,
113 # since these compressors have many overlapping patterns
114 compressors
= VectorParam
.BaseCacheCompressor([CPack(), FPCD()],
115 "Array of compressors")
117 class PerfectCompressor(BaseCacheCompressor
):
118 type = 'PerfectCompressor'
119 cxx_class
= 'Compressor::Perfect'
120 cxx_header
= "mem/cache/compressors/perfect.hh"
123 max_compression_ratio
= Param
.Int(2,
124 "Maximum compression ratio allowed")
125 compression_latency
= Param
.Cycles(1,
126 "Number of cycles to perform data compression")
127 decompression_latency
= Param
.Cycles(1,
128 "Number of cycles to perform data decompression")
130 class RepeatedQwordsCompressor(BaseDictionaryCompressor
):
131 type = 'RepeatedQwordsCompressor'
132 cxx_class
= 'Compressor::RepeatedQwords'
133 cxx_header
= "mem/cache/compressors/repeated_qwords.hh"
137 class ZeroCompressor(BaseDictionaryCompressor
):
138 type = 'ZeroCompressor'
139 cxx_class
= 'Compressor::Zero'
140 cxx_header
= "mem/cache/compressors/zero.hh"
144 class BDI(MultiCompressor
):
145 compressors
= [ZeroCompressor(), RepeatedQwordsCompressor(),
146 Base64Delta8(), Base64Delta16(), Base64Delta32(), Base32Delta8(),
147 Base32Delta16(), Base16Delta8()]