gem5  v20.1.0.0
base.hh
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 
36 #ifndef __MEM_CACHE_COMPRESSORS_BASE_HH__
37 #define __MEM_CACHE_COMPRESSORS_BASE_HH__
38 
39 #include <cstdint>
40 
41 #include "base/statistics.hh"
42 #include "base/types.hh"
43 #include "sim/sim_object.hh"
44 
45 class CacheBlk;
46 struct BaseCacheCompressorParams;
47 
48 namespace Compressor {
49 
58 class Base : public SimObject
59 {
60  public:
66 
67  protected:
76  typedef uint64_t Chunk;
77 
82  friend class Multi;
83 
87  const std::size_t blkSize;
88 
90  const unsigned chunkSizeBits;
91 
96  const std::size_t sizeThreshold;
97 
98  struct BaseStats : public Stats::Group
99  {
100  const Base& compressor;
101 
103 
104  void regStats() override;
105 
108 
111 
114 
117 
120 
123  } stats;
124 
132  std::vector<Chunk> toChunks(const uint64_t* data) const;
133 
140  void fromChunks(const std::vector<Chunk>& chunks, uint64_t* data) const;
141 
154  virtual std::unique_ptr<CompressionData> compress(
155  const std::vector<Chunk>& chunks, Cycles& comp_lat,
156  Cycles& decomp_lat) = 0;
157 
164  virtual void decompress(const CompressionData* comp_data,
165  uint64_t* cache_line) = 0;
166 
167  public:
168  typedef BaseCacheCompressorParams Params;
169  Base(const Params *p);
170  virtual ~Base() = default;
171 
181  std::unique_ptr<CompressionData>
182  compress(const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat);
183 
191 
198  static void setDecompressionLatency(CacheBlk* blk, const Cycles lat);
199 
206  static void setSizeBits(CacheBlk* blk, const std::size_t size_bits);
207 };
208 
210 {
211  private:
215  std::size_t _size;
216 
217  public:
221  CompressionData();
222 
226  virtual ~CompressionData();
227 
233  void setSizeBits(std::size_t size);
234 
240  std::size_t getSizeBits() const;
241 
247  std::size_t getSize() const;
248 };
249 
250 } // namespace Compressor
251 
252 #endif //__MEM_CACHE_COMPRESSORS_BASE_HH__
Compressor::Base::sizeThreshold
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:96
Compressor::Base::CompressionData::_size
std::size_t _size
Compressed cache line size (in bits).
Definition: base.hh:215
Compressor::Base::CompressionData::CompressionData
CompressionData()
Default constructor.
Definition: base.cc:51
data
const char data[]
Definition: circlebuf.test.cc:42
Compressor::Base::chunkSizeBits
const unsigned chunkSizeBits
Chunk size, in number of bits.
Definition: base.hh:90
Compressor::Base::BaseStats::regStats
void regStats() override
Callback to set stat parameters.
Definition: base.cc:227
Compressor::Base::BaseStats::failedCompressions
Stats::Scalar failedCompressions
Number of failed compressions.
Definition: base.hh:110
Compressor::Base::blkSize
const std::size_t blkSize
Uncompressed cache line size (in bytes).
Definition: base.hh:87
Compressor
Definition: base.cc:46
Compressor::Base::BaseStats::avgCompressionSizeBits
Stats::Formula avgCompressionSizeBits
Average data size after compression, in number of bits.
Definition: base.hh:119
Compressor::Base::CompressionData::~CompressionData
virtual ~CompressionData()
Virtual destructor.
Definition: base.cc:56
Compressor::Base::CompressionData::getSizeBits
std::size_t getSizeBits() const
Get compression size (in bits).
Definition: base.cc:67
std::vector< Chunk >
Compressor::Base::fromChunks
void fromChunks(const std::vector< Chunk > &chunks, uint64_t *data) const
This function re-joins the chunks to recreate the original data.
Definition: base.cc:109
Compressor::Base
Base cache compressor interface.
Definition: base.hh:58
Compressor::Base::BaseStats
Definition: base.hh:98
Stats::Vector
A vector of scalar stats.
Definition: statistics.hh:2575
Compressor::Base::BaseStats::BaseStats
BaseStats(Base &compressor)
Definition: base.cc:209
Compressor::Base::compress
virtual std::unique_ptr< CompressionData > compress(const std::vector< Chunk > &chunks, Cycles &comp_lat, Cycles &decomp_lat)=0
Apply the compression process to the cache line.
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
Compressor::Base::BaseStats::compressionSize
Stats::Vector compressionSize
Number of blocks that were compressed to this power of two size.
Definition: base.hh:113
Compressor::Base::setDecompressionLatency
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
Definition: base.cc:190
Compressor::Multi
Definition: multi.hh:48
Compressor::Base::CompressionData
Definition: base.hh:209
sim_object.hh
Compressor::Base::decompress
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.
statistics.hh
Compressor::Base::getDecompressionLatency
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
Definition: base.cc:172
Compressor::Base::BaseStats::compressor
const Base & compressor
Definition: base.hh:100
Compressor::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:168
Compressor::Base::toChunks
std::vector< Chunk > toChunks(const uint64_t *data) const
This function splits the raw data into chunks, so that it can be parsed by the compressor.
Definition: base.cc:90
Compressor::Base::BaseStats::compressions
Stats::Scalar compressions
Number of compressions performed.
Definition: base.hh:107
Compressor::Base::BaseStats::compressionSizeBits
Stats::Scalar compressionSizeBits
Total compressed data size, in number of bits.
Definition: base.hh:116
CacheBlk
A Basic Cache block.
Definition: cache_blk.hh:84
types.hh
Compressor::Base::~Base
virtual ~Base()=default
Stats::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3037
Stats::Group
Statistics container.
Definition: group.hh:83
Compressor::Base::CompressionData::getSize
std::size_t getSize() const
Get compression size (in bytes).
Definition: base.cc:73
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Compressor::Base::stats
Compressor::Base::BaseStats stats
Compressor::Base::BaseStats::decompressions
Stats::Scalar decompressions
Number of decompressions performed.
Definition: base.hh:122
Compressor::Base::CompressionData::setSizeBits
void setSizeBits(std::size_t size)
Set compression size (in bits).
Definition: base.cc:61
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Compressor::Base::Chunk
uint64_t Chunk
A chunk is a basic lexical unit.
Definition: base.hh:65
Compressor::Base::setSizeBits
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
Definition: base.cc:200
Compressor::Base::Base
Base(const Params *p)
Definition: base.cc:78
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17