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 size_threshold
= Param
.Unsigned(Parent
.cache_line_size
, "Minimum size, "
39 "in bytes, in which a block must be compressed to. Otherwise it is "
40 "stored in its uncompressed state")
42 class BaseDictionaryCompressor(BaseCacheCompressor
):
43 type = 'BaseDictionaryCompressor'
45 cxx_class
= 'Compressor::BaseDictionaryCompressor'
46 cxx_header
= "mem/cache/compressors/dictionary_compressor.hh"
48 dictionary_size
= Param
.Int(Parent
.cache_line_size
,
49 "Number of dictionary entries")
51 class Base64Delta8(BaseDictionaryCompressor
):
53 cxx_class
= 'Compressor::Base64Delta8'
54 cxx_header
= "mem/cache/compressors/base_delta.hh"
56 class Base64Delta16(BaseDictionaryCompressor
):
57 type = 'Base64Delta16'
58 cxx_class
= 'Compressor::Base64Delta16'
59 cxx_header
= "mem/cache/compressors/base_delta.hh"
61 class Base64Delta32(BaseDictionaryCompressor
):
62 type = 'Base64Delta32'
63 cxx_class
= 'Compressor::Base64Delta32'
64 cxx_header
= "mem/cache/compressors/base_delta.hh"
66 class Base32Delta8(BaseDictionaryCompressor
):
68 cxx_class
= 'Compressor::Base32Delta8'
69 cxx_header
= "mem/cache/compressors/base_delta.hh"
71 class Base32Delta16(BaseDictionaryCompressor
):
72 type = 'Base32Delta16'
73 cxx_class
= 'Compressor::Base32Delta16'
74 cxx_header
= "mem/cache/compressors/base_delta.hh"
76 class Base16Delta8(BaseDictionaryCompressor
):
78 cxx_class
= 'Compressor::Base16Delta8'
79 cxx_header
= "mem/cache/compressors/base_delta.hh"
81 class CPack(BaseDictionaryCompressor
):
83 cxx_class
= 'Compressor::CPack'
84 cxx_header
= "mem/cache/compressors/cpack.hh"
86 class FPCD(BaseDictionaryCompressor
):
88 cxx_class
= 'Compressor::FPCD'
89 cxx_header
= "mem/cache/compressors/fpcd.hh"
93 class MultiCompressor(BaseCacheCompressor
):
94 type = 'MultiCompressor'
95 cxx_class
= 'Compressor::Multi'
96 cxx_header
= "mem/cache/compressors/multi.hh"
98 # Dummy default compressor list. This might not be an optimal choice,
99 # since these compressors have many overlapping patterns
100 compressors
= VectorParam
.BaseCacheCompressor([CPack(), FPCD()],
101 "Array of compressors")
103 class PerfectCompressor(BaseCacheCompressor
):
104 type = 'PerfectCompressor'
105 cxx_class
= 'Compressor::Perfect'
106 cxx_header
= "mem/cache/compressors/perfect.hh"
108 max_compression_ratio
= Param
.Int(2,
109 "Maximum compression ratio allowed")
110 compression_latency
= Param
.Cycles(1,
111 "Number of cycles to perform data compression")
112 decompression_latency
= Param
.Cycles(1,
113 "Number of cycles to perform data decompression")
115 class RepeatedQwordsCompressor(BaseDictionaryCompressor
):
116 type = 'RepeatedQwordsCompressor'
117 cxx_class
= 'Compressor::RepeatedQwords'
118 cxx_header
= "mem/cache/compressors/repeated_qwords.hh"
120 class ZeroCompressor(BaseDictionaryCompressor
):
121 type = 'ZeroCompressor'
122 cxx_class
= 'Compressor::Zero'
123 cxx_header
= "mem/cache/compressors/zero.hh"
125 class BDI(MultiCompressor
):
126 compressors
= [ZeroCompressor(), RepeatedQwordsCompressor(),
127 Base64Delta8(), Base64Delta16(), Base64Delta32(), Base32Delta8(),
128 Base32Delta16(), Base16Delta8()]