gem5  v22.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/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:
72  class CompressionData;
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__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
const char data[]
A basic cache interface.
Definition: base.hh:96
A Basic Cache block.
Definition: cache_blk.hh:71
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
virtual ~CompressionData()
Virtual destructor.
Definition: base.cc:63
CompressionData()
Default constructor.
Definition: base.cc:58
std::size_t getSize() const
Get compression size (in bytes).
Definition: base.cc:80
void setSizeBits(std::size_t size)
Set compression size (in bits).
Definition: base.cc:68
std::size_t _size
Compressed cache line size (in bits).
Definition: base.hh:252
std::size_t getSizeBits() const
Get compression size (in bits).
Definition: base.cc:74
Base cache compressor interface.
Definition: base.hh:66
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
Definition: base.hh:115
BaseCacheCompressorParams Params
Definition: base.hh:202
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::compression::Base::BaseStats stats
Base(const Params &p)
Definition: base.cc:85
BaseCache * cache
Pointer to the parent cache.
Definition: base.hh:130
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
virtual ~Base()=default
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
Definition: base.hh:127
const Cycles compChunksPerCycle
Degree of parallelization of the compression process.
Definition: base.hh:109
uint64_t Chunk
A chunk is a basic lexical unit.
Definition: base.hh:72
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.
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
Definition: base.cc:197
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
Definition: base.cc:225
const std::size_t blkSize
Uncompressed cache line size (in bytes).
Definition: base.hh:94
virtual void setCache(BaseCache *_cache)
The cache can only be set once.
Definition: base.cc:108
virtual void decompress(const CompressionData *comp_data, uint64_t *cache_line)=0
Apply the decompression process to the compressed data.
const unsigned chunkSizeBits
Chunk size, in number of bits.
Definition: base.hh:97
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
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
Definition: base.cc:215
const Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
Definition: base.hh:121
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
A vector of scalar stats.
Definition: statistics.hh:2007
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Declaration of Statistics objects.
statistics::Scalar compressions
Number of compressions performed.
Definition: base.hh:141
void regStats() override
Callback to set stat parameters.
Definition: base.cc:254
BaseStats(Base &compressor)
Definition: base.cc:234
statistics::Scalar decompressions
Number of decompressions performed.
Definition: base.hh:156
statistics::Vector compressionSize
Number of blocks that were compressed to this power of two size.
Definition: base.hh:147
statistics::Formula avgCompressionSizeBits
Average data size after compression, in number of bits.
Definition: base.hh:153
statistics::Scalar failedCompressions
Number of failed compressions.
Definition: base.hh:144
statistics::Scalar compressionSizeBits
Total compressed data size, in number of bits.
Definition: base.hh:150

Generated on Wed Dec 21 2022 10:22:28 for gem5 by doxygen 1.9.1