gem5  v21.1.0.2
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/compiler.hh"
42 #include "base/statistics.hh"
43 #include "base/types.hh"
44 #include "sim/sim_object.hh"
45 
46 namespace gem5
47 {
48 
49 class BaseCache;
50 class CacheBlk;
51 struct BaseCacheCompressorParams;
52 
53 GEM5_DEPRECATED_NAMESPACE(Compressor, compression);
54 namespace compression
55 {
56 
65 class Base : public SimObject
66 {
67  public:
73 
74  protected:
83  typedef uint64_t Chunk;
84 
89  friend class Multi;
90 
94  const std::size_t blkSize;
95 
97  const unsigned chunkSizeBits;
98 
103  const std::size_t sizeThreshold;
104 
110 
116 
122 
128 
131 
132  struct BaseStats : public statistics::Group
133  {
134  const Base& compressor;
135 
137 
138  void regStats() override;
139 
142 
145 
148 
151 
154 
157  } stats;
158 
166  std::vector<Chunk> toChunks(const uint64_t* data) const;
167 
174  void fromChunks(const std::vector<Chunk>& chunks, uint64_t* data) const;
175 
188  virtual std::unique_ptr<CompressionData> compress(
189  const std::vector<Chunk>& chunks, Cycles& comp_lat,
190  Cycles& decomp_lat) = 0;
191 
198  virtual void decompress(const CompressionData* comp_data,
199  uint64_t* cache_line) = 0;
200 
201  public:
202  typedef BaseCacheCompressorParams Params;
203  Base(const Params &p);
204  virtual ~Base() = default;
205 
207  virtual void setCache(BaseCache *_cache);
208 
218  std::unique_ptr<CompressionData>
219  compress(const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat);
220 
228 
235  static void setDecompressionLatency(CacheBlk* blk, const Cycles lat);
236 
243  static void setSizeBits(CacheBlk* blk, const std::size_t size_bits);
244 };
245 
247 {
248  private:
252  std::size_t _size;
253 
254  public:
258  CompressionData();
259 
263  virtual ~CompressionData();
264 
270  void setSizeBits(std::size_t size);
271 
277  std::size_t getSizeBits() const;
278 
284  std::size_t getSize() const;
285 };
286 
287 } // namespace compression
288 } // namespace gem5
289 
290 #endif //__MEM_CACHE_COMPRESSORS_BASE_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::compression::Base::CompressionData
Definition: base.hh:246
gem5::compression::Base::BaseStats::avgCompressionSizeBits
statistics::Formula avgCompressionSizeBits
Average data size after compression, in number of bits.
Definition: base.hh:153
gem5::compression::Base::chunkSizeBits
const unsigned chunkSizeBits
Chunk size, in number of bits.
Definition: base.hh:97
gem5::compression::Base::decompress
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::compression::Base::decompChunksPerCycle
const Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
Definition: base.hh:121
gem5::compression::Base::BaseStats::compressionSize
statistics::Vector compressionSize
Number of blocks that were compressed to this power of two size.
Definition: base.hh:147
gem5::compression::Base::getDecompressionLatency
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
Definition: base.cc:197
gem5::compression::Base::BaseStats::failedCompressions
statistics::Scalar failedCompressions
Number of failed compressions.
Definition: base.hh:144
gem5::compression::Base::Chunk
uint64_t Chunk
A chunk is a basic lexical unit.
Definition: base.hh:72
gem5::compression::Base::~Base
virtual ~Base()=default
gem5::compression::Base::Params
BaseCacheCompressorParams Params
Definition: base.hh:202
gem5::statistics::Vector
A vector of scalar stats.
Definition: statistics.hh:2003
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2536
std::vector< Chunk >
gem5::compression::Base::blkSize
const std::size_t blkSize
Uncompressed cache line size (in bytes).
Definition: base.hh:94
gem5::compression::Base::compExtraLatency
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
Definition: base.hh:115
gem5::compression::Base::BaseStats::BaseStats
BaseStats(Base &compressor)
Definition: base.cc:234
gem5::compression::Base::BaseStats::decompressions
statistics::Scalar decompressions
Number of decompressions performed.
Definition: base.hh:156
gem5::CacheBlk
A Basic Cache block.
Definition: cache_blk.hh:70
gem5::compression::Base::setCache
virtual void setCache(BaseCache *_cache)
The cache can only be set once.
Definition: base.cc:108
gem5::compression::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:134
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::compression::Base::CompressionData::_size
std::size_t _size
Compressed cache line size (in bits).
Definition: base.hh:252
gem5::compression::Base::decompExtraLatency
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
Definition: base.hh:127
gem5::compression::Base::CompressionData::getSize
std::size_t getSize() const
Get compression size (in bytes).
Definition: base.cc:80
gem5::compression::Base::cache
BaseCache * cache
Pointer to the parent cache.
Definition: base.hh:130
gem5::compression::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:115
sim_object.hh
gem5::BaseCache
A basic cache interface.
Definition: base.hh:95
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
statistics.hh
gem5::compression::Base::CompressionData::~CompressionData
virtual ~CompressionData()
Virtual destructor.
Definition: base.cc:63
gem5::compression::Base
Base cache compressor interface.
Definition: base.hh:65
gem5::compression::Base::BaseStats::compressor
const Base & compressor
Definition: base.hh:134
gem5::compression::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:225
gem5::compression::Base::CompressionData::getSizeBits
std::size_t getSizeBits() const
Get compression size (in bits).
Definition: base.cc:74
compiler.hh
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::compression::Base::Base
Base(const Params &p)
Definition: base.cc:85
gem5::compression::Base::BaseStats::regStats
void regStats() override
Callback to set stat parameters.
Definition: base.cc:254
gem5::compression::Base::stats
gem5::compression::Base::BaseStats stats
gem5::compression::Base::BaseStats::compressions
statistics::Scalar compressions
Number of compressions performed.
Definition: base.hh:141
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::compression::Base::BaseStats::compressionSizeBits
statistics::Scalar compressionSizeBits
Total compressed data size, in number of bits.
Definition: base.hh:150
types.hh
gem5::compression::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.
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::compression::Base::compChunksPerCycle
const Cycles compChunksPerCycle
Degree of parallelization of the compression process.
Definition: base.hh:109
gem5::compression::Base::setDecompressionLatency
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
Definition: base.cc:215
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::compression::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:103
gem5::compression::Multi
Definition: multi.hh:53
gem5::compression::Base::BaseStats
Definition: base.hh:132
gem5::compression::Base::CompressionData::CompressionData
CompressionData()
Default constructor.
Definition: base.cc:58
gem5::compression::Base::CompressionData::setSizeBits
void setSizeBits(std::size_t size)
Set compression size (in bits).
Definition: base.cc:68

Generated on Tue Sep 21 2021 12:24:57 for gem5 by doxygen 1.8.17