gem5  v20.1.0.0
super_blk.cc
Go to the documentation of this file.
1 
36 
37 #include "base/logging.hh"
38 
40  : SectorSubBlk(), _size(0), _decompressionLatency(0)
41 {
42 }
43 
44 bool
46 {
47  return (status & BlkCompressed) != 0;
48 }
49 
50 void
52 {
54 }
55 
56 void
58 {
60 }
61 
62 std::size_t
64 {
65  return _size;
66 }
67 
68 void
69 CompressionBlk::setSizeBits(const std::size_t size)
70 {
71  _size = size;
72 }
73 
74 Cycles
76 {
77  return _decompressionLatency;
78 }
79 
80 void
82 {
84 }
85 
86 std::string
88 {
89  return csprintf("%s compressed: %d size: %llu decompression latency: %d",
92 }
93 
94 bool
95 SuperBlk::isCompressed(const CompressionBlk* ignored_blk) const
96 {
97  for (const auto& blk : blks) {
98  if (blk->isValid() && (blk != ignored_blk)) {
99  return static_cast<CompressionBlk*>(blk)->isCompressed();
100  }
101  }
102 
103  // An invalid block is seen as compressed
104  return true;
105 }
106 
107 bool
108 SuperBlk::canCoAllocate(const std::size_t compressed_size) const
109 {
110  // Simple co-allocation function: at most numBlocksPerSector blocks that
111  // compress at least to (100/numBlocksPerSector)% of their original size
112  // can share a superblock
113  return (compressed_size <= (blkSize * 8) / blks.size());
114 }
115 
116 void
117 SuperBlk::setBlkSize(const std::size_t blk_size)
118 {
119  assert(blkSize == 0);
120  blkSize = blk_size;
121 }
SuperBlk::canCoAllocate
bool canCoAllocate(const std::size_t compressed_size) const
Checks whether a superblock can co-allocate given compressed data block.
Definition: super_blk.cc:108
BlkCompressed
@ BlkCompressed
block holds compressed data
Definition: cache_blk.hh:77
CompressionBlk::_size
std::size_t _size
Set size, in bits, of this compressed block's data.
Definition: super_blk.hh:54
CompressionBlk::getSizeBits
std::size_t getSizeBits() const
Definition: super_blk.cc:63
SectorBlk::blks
std::vector< SectorSubBlk * > blks
List of blocks associated to this sector.
Definition: sector_blk.hh:167
SuperBlk::blkSize
std::size_t blkSize
Block size, in bytes.
Definition: super_blk.hh:129
CacheBlk::status
State status
The current status of this block.
Definition: cache_blk.hh:105
CompressionBlk::getDecompressionLatency
Cycles getDecompressionLatency() const
Get number of cycles needed to decompress this block.
Definition: super_blk.cc:75
SuperBlk::setBlkSize
void setBlkSize(const std::size_t blk_size)
Set block size.
Definition: super_blk.cc:117
CompressionBlk::isCompressed
bool isCompressed() const
Check if this block holds compressed data.
Definition: super_blk.cc:45
CompressionBlk::setDecompressionLatency
void setDecompressionLatency(const Cycles lat)
Set number of cycles needed to decompress this block.
Definition: super_blk.cc:81
CompressionBlk::_decompressionLatency
Cycles _decompressionLatency
Number of cycles needed to decompress this block.
Definition: super_blk.hh:60
CompressionBlk::setCompressed
void setCompressed()
Set compression bit.
Definition: super_blk.cc:51
CompressionBlk::setUncompressed
void setUncompressed()
Clear compression bit.
Definition: super_blk.cc:57
super_blk.hh
Copyright (c) 2018 Inria All rights reserved.
SectorSubBlk::print
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
Definition: sector_blk.cc:110
CompressionBlk::setSizeBits
void setSizeBits(const std::size_t size)
Set size, in bits, of this compressed block's data.
Definition: super_blk.cc:69
SuperBlk::isCompressed
bool isCompressed(const CompressionBlk *ignored_blk=nullptr) const
Returns whether the superblock contains compressed blocks or not.
Definition: super_blk.cc:95
logging.hh
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
SectorSubBlk
A sector is composed of sub-blocks, and each sub-block has information regarding its sector and a poi...
Definition: sector_blk.hh:48
CompressionBlk::CompressionBlk
CompressionBlk()
Definition: super_blk.cc:39
CompressionBlk
A superblock is composed of sub-blocks, and each sub-block has information regarding its superblock a...
Definition: super_blk.hh:48
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158
CompressionBlk::print
std::string print() const override
Pretty-print sector offset and other CacheBlk information.
Definition: super_blk.cc:87

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