summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel R. Carvalho <odanrc@yahoo.com.br>2018-03-30 15:09:51 +0200
committerDaniel Carvalho <odanrc@yahoo.com.br>2019-05-08 17:41:09 +0000
commit784642b4312c3366cae727b4fef1ea763ace2c87 (patch)
tree3a2ec5375e111e6f5d68db5890ac47600df0c327 /src
parentbba32e6df86f8cdd1e605b1637652bb13032304a (diff)
downloadgem5-784642b4312c3366cae727b4fef1ea763ace2c87.tar.xz
mem-cache: Add compression data to CompressionBlk
Add a compression bit, decompression latency and compressed block size and their respective getters and setters. Change-Id: Ia9d8656552d60e8d4e85fe5379dd75fc5adb0abe Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/11102 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/mem/cache/cache_blk.hh2
-rw-r--r--src/mem/cache/tags/super_blk.cc65
-rw-r--r--src/mem/cache/tags/super_blk.hh72
3 files changed, 138 insertions, 1 deletions
diff --git a/src/mem/cache/cache_blk.hh b/src/mem/cache/cache_blk.hh
index 611ce448d..ddcf3ecb6 100644
--- a/src/mem/cache/cache_blk.hh
+++ b/src/mem/cache/cache_blk.hh
@@ -76,6 +76,8 @@ enum CacheBlkStatusBits : unsigned {
BlkHWPrefetched = 0x20,
/** block holds data from the secure memory space */
BlkSecure = 0x40,
+ /** block holds compressed data */
+ BlkCompressed = 0x80
};
/**
diff --git a/src/mem/cache/tags/super_blk.cc b/src/mem/cache/tags/super_blk.cc
index 3e8835625..530a2c078 100644
--- a/src/mem/cache/tags/super_blk.cc
+++ b/src/mem/cache/tags/super_blk.cc
@@ -39,6 +39,69 @@
#include "base/logging.hh"
CompressionBlk::CompressionBlk()
- : SectorSubBlk()
+ : SectorSubBlk(), _size(0), _decompressionLatency(0)
{
}
+
+bool
+CompressionBlk::isCompressed() const
+{
+ return (status & BlkCompressed) != 0;
+}
+
+void
+CompressionBlk::setCompressed()
+{
+ status |= BlkCompressed;
+}
+
+void
+CompressionBlk::setUncompressed()
+{
+ status &= ~BlkCompressed;
+}
+
+std::size_t
+CompressionBlk::getSizeBits() const
+{
+ return _size;
+}
+
+void
+CompressionBlk::setSizeBits(const std::size_t size)
+{
+ _size = size;
+}
+
+Cycles
+CompressionBlk::getDecompressionLatency() const
+{
+ return _decompressionLatency;
+}
+
+void
+CompressionBlk::setDecompressionLatency(const Cycles lat)
+{
+ _decompressionLatency = lat;
+}
+
+std::string
+CompressionBlk::print() const
+{
+ return csprintf("%s compressed: %d size: %llu decompression latency: %d",
+ SectorSubBlk::print(), isCompressed(), getSizeBits(),
+ getDecompressionLatency());
+}
+
+bool
+SuperBlk::isCompressed() const
+{
+ for (const auto& blk : blks) {
+ if (blk->isValid()) {
+ return static_cast<CompressionBlk*>(blk)->isCompressed();
+ }
+ }
+
+ // An invalid block is seen as compressed
+ return true;
+}
diff --git a/src/mem/cache/tags/super_blk.hh b/src/mem/cache/tags/super_blk.hh
index 45c7f1a66..bf35c6992 100644
--- a/src/mem/cache/tags/super_blk.hh
+++ b/src/mem/cache/tags/super_blk.hh
@@ -49,11 +49,75 @@ class SuperBlk;
*/
class CompressionBlk : public SectorSubBlk
{
+ private:
+ /**
+ * Set size, in bits, of this compressed block's data.
+ */
+ std::size_t _size;
+
+ /**
+ * Number of cycles needed to decompress this block. We store it to avoid
+ * doing decompressions.
+ */
+ Cycles _decompressionLatency;
+
public:
CompressionBlk();
CompressionBlk(const CompressionBlk&) = delete;
CompressionBlk& operator=(const CompressionBlk&) = delete;
~CompressionBlk() {};
+
+ /**
+ * Check if this block holds compressed data.
+ *
+ * @return True if the block holds compressed data.
+ */
+ bool isCompressed() const;
+
+ /**
+ * Set compression bit.
+ */
+ void setCompressed();
+
+ /**
+ * Clear compression bit.
+ */
+ void setUncompressed();
+
+ /*
+ * Get size, in bits, of this compressed block's data.
+ *
+ * @return The compressed size.
+ */
+ std::size_t getSizeBits() const;
+
+ /**
+ * Set size, in bits, of this compressed block's data.
+ *
+ * @param The compressed size.
+ */
+ void setSizeBits(const std::size_t size);
+
+ /**
+ * Get number of cycles needed to decompress this block.
+ *
+ * @return Decompression latency.
+ */
+ Cycles getDecompressionLatency() const;
+
+ /**
+ * Set number of cycles needed to decompress this block.
+ *
+ * @param Decompression latency.
+ */
+ void setDecompressionLatency(const Cycles lat);
+
+ /**
+ * Pretty-print sector offset and other CacheBlk information.
+ *
+ * @return string with basic state information
+ */
+ std::string print() const override;
};
/**
@@ -67,6 +131,14 @@ class SuperBlk : public SectorBlk
SuperBlk(const SuperBlk&) = delete;
SuperBlk& operator=(const SuperBlk&) = delete;
~SuperBlk() {};
+
+ /**
+ * Returns whether the superblock contains compressed blocks or not. By
+ * default, if not blocks are valid, the superblock is compressible.
+ *
+ * @return The compressibility state of the superblock.
+ */
+ bool isCompressed() const;
};
#endif //__MEM_CACHE_TAGS_SUPER_BLK_HH__