gem5  v19.0.0.0
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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  * Authors: Daniel Carvalho
29  */
30 
38 #ifndef __MEM_CACHE_COMPRESSORS_BASE_HH__
39 #define __MEM_CACHE_COMPRESSORS_BASE_HH__
40 
41 #include <cstdint>
42 
43 #include "base/statistics.hh"
44 #include "base/types.hh"
45 #include "sim/sim_object.hh"
46 
47 class CacheBlk;
48 struct BaseCacheCompressorParams;
49 
55 {
56  protected:
61  friend class MultiCompressor;
62 
68 
72  const std::size_t blkSize;
73 
78  const std::size_t sizeThreshold;
79 
81  {
83 
85 
86  void regStats() override;
87 
90 
93 
96 
99 
102  } stats;
103 
116  virtual std::unique_ptr<CompressionData> compress(
117  const uint64_t* cache_line, Cycles& comp_lat, Cycles& decomp_lat) = 0;
118 
125  virtual void decompress(const CompressionData* comp_data,
126  uint64_t* cache_line) = 0;
127 
128  public:
130  typedef BaseCacheCompressorParams Params;
131 
135  BaseCacheCompressor(const Params *p);
136 
140  virtual ~BaseCacheCompressor() {};
141 
151  void compress(const uint64_t* data, Cycles& comp_lat,
152  Cycles& decomp_lat, std::size_t& comp_size_bits);
153 
161 
168  static void setDecompressionLatency(CacheBlk* blk, const Cycles lat);
169 
176  static void setSizeBits(CacheBlk* blk, const std::size_t size_bits);
177 };
178 
180  private:
184  std::size_t _size;
185 
186  public:
190  CompressionData();
191 
195  virtual ~CompressionData();
196 
202  void setSizeBits(std::size_t size);
203 
209  std::size_t getSizeBits() const;
210 
216  std::size_t getSize() const;
217 };
218 
219 #endif //__MEM_CACHE_COMPRESSORS_BASE_HH__
virtual std::unique_ptr< CompressionData > compress(const uint64_t *cache_line, Cycles &comp_lat, Cycles &decomp_lat)=0
Apply the compression process to the cache line.
virtual ~BaseCacheCompressor()
Default destructor.
Definition: base.hh:140
BaseCacheCompressor(const Params *p)
Default constructor.
Definition: base.cc:76
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Stats::Scalar decompressions
Number of decompressions performed.
Definition: base.hh:101
const std::size_t sizeThreshold
Size in bytes at which a compression is classified as bad and therefore the compressed block is resto...
Definition: base.hh:78
A vector of scalar stats.
Definition: statistics.hh:2550
Stats::Scalar compressionSizeBits
Total compressed data size, in number of bits.
Definition: base.hh:95
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
Definition: base.cc:151
A Basic Cache block.
Definition: cache_blk.hh:87
const BaseCacheCompressor & compressor
Definition: base.hh:82
const std::size_t blkSize
Uncompressed cache line size (in bytes).
Definition: base.hh:67
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
Base cache compressor interface.
Definition: base.hh:54
Statistics container.
Definition: group.hh:85
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
Stats::Scalar compressions
Number of compressions performed.
Definition: base.hh:89
Stats::Formula avgCompressionSizeBits
Average data size after compression, in number of bits.
Definition: base.hh:98
std::size_t _size
Compressed cache line size (in bits).
Definition: base.hh:184
BaseCacheCompressorParams Params
Convenience typedef.
Definition: base.hh:130
BaseCacheCompressorStats(BaseCacheCompressor &compressor)
Definition: base.cc:160
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
Definition: base.cc:123
void regStats() override
Callback to set stat parameters.
Definition: base.cc:177
Stats::Vector compressionSize
Number of blocks that were compressed to this power of two size.
Definition: base.hh:92
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
Definition: base.cc:141
Bitfield< 0 > p
std::vector< Info * > stats
Definition: group.hh:177
const char data[]
Abstract superclass for simulation objects.
Definition: sim_object.hh:96
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13