gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
46namespace gem5
47{
48
49class BaseCache;
50class CacheBlk;
51struct BaseCacheCompressorParams;
52
53namespace compression
54{
55
64class Base : public SimObject
65{
66 public:
71 class CompressionData;
72
73 protected:
82 typedef uint64_t Chunk;
83
88 friend class Multi;
89
93 const std::size_t blkSize;
94
96 const unsigned chunkSizeBits;
97
102 const std::size_t sizeThreshold;
103
109
115
121
127
130
157
165 std::vector<Chunk> toChunks(const uint64_t* data) const;
166
173 void fromChunks(const std::vector<Chunk>& chunks, uint64_t* data) const;
174
187 virtual std::unique_ptr<CompressionData> compress(
188 const std::vector<Chunk>& chunks, Cycles& comp_lat,
189 Cycles& decomp_lat) = 0;
190
197 virtual void decompress(const CompressionData* comp_data,
198 uint64_t* cache_line) = 0;
199
200 public:
201 typedef BaseCacheCompressorParams Params;
202 Base(const Params &p);
203 virtual ~Base() = default;
204
206 virtual void setCache(BaseCache *_cache);
207
217 std::unique_ptr<CompressionData>
218 compress(const uint64_t* data, Cycles& comp_lat, Cycles& decomp_lat);
219
227
234 static void setDecompressionLatency(CacheBlk* blk, const Cycles lat);
235
242 static void setSizeBits(CacheBlk* blk, const std::size_t size_bits);
243};
244
246{
247 private:
251 std::size_t _size;
252
253 public:
258
262 virtual ~CompressionData();
263
269 void setSizeBits(std::size_t size);
270
276 std::size_t getSizeBits() const;
277
283 std::size_t getSize() const;
284};
285
286} // namespace compression
287} // namespace gem5
288
289#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:100
A Basic Cache block.
Definition cache_blk.hh:72
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
Abstract superclass for simulation objects.
virtual ~CompressionData()
Virtual destructor.
Definition base.cc:62
CompressionData()
Default constructor.
Definition base.cc:57
std::size_t getSize() const
Get compression size (in bytes).
Definition base.cc:79
void setSizeBits(std::size_t size)
Set compression size (in bits).
Definition base.cc:67
std::size_t _size
Compressed cache line size (in bits).
Definition base.hh:251
std::size_t getSizeBits() const
Get compression size (in bits).
Definition base.cc:73
Base cache compressor interface.
Definition base.hh:65
const Cycles compExtraLatency
Extra latency added to compression due to packaging, shifting or other operations.
Definition base.hh:114
BaseCacheCompressorParams Params
Definition base.hh:201
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:133
gem5::compression::Base::BaseStats stats
Base(const Params &p)
Definition base.cc:84
BaseCache * cache
Pointer to the parent cache.
Definition base.hh:129
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:114
virtual ~Base()=default
const Cycles decompExtraLatency
Extra latency added to decompression due to packaging, shifting or other operations.
Definition base.hh:126
const Cycles compChunksPerCycle
Degree of parallelization of the compression process.
Definition base.hh:108
uint64_t Chunk
A chunk is a basic lexical unit.
Definition base.hh:82
Cycles getDecompressionLatency(const CacheBlk *blk)
Get the decompression latency if the block is compressed.
Definition base.cc:196
static void setSizeBits(CacheBlk *blk, const std::size_t size_bits)
Set the size of the compressed block, in bits.
Definition base.cc:224
const std::size_t blkSize
Uncompressed cache line size (in bytes).
Definition base.hh:93
virtual void setCache(BaseCache *_cache)
The cache can only be set once.
Definition base.cc:107
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:96
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:102
static void setDecompressionLatency(CacheBlk *blk, const Cycles lat)
Set the decompression latency of compressed block.
Definition base.cc:214
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.
const Cycles decompChunksPerCycle
Degree of parallelization of the decompression process.
Definition base.hh:120
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
A vector of scalar stats.
STL vector class.
Definition stl.hh:37
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Declaration of Statistics objects.
statistics::Scalar compressions
Number of compressions performed.
Definition base.hh:140
void regStats() override
Callback to set stat parameters.
Definition base.cc:253
BaseStats(Base &compressor)
Definition base.cc:233
statistics::Scalar decompressions
Number of decompressions performed.
Definition base.hh:155
statistics::Vector compressionSize
Number of blocks that were compressed to this power of two size.
Definition base.hh:146
statistics::Formula avgCompressionSizeBits
Average data size after compression, in number of bits.
Definition base.hh:152
statistics::Scalar failedCompressions
Number of failed compressions.
Definition base.hh:143
statistics::Scalar compressionSizeBits
Total compressed data size, in number of bits.
Definition base.hh:149

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0