Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/11103

Change subject: mem-cache: Add compression stats
......................................................................

mem-cache: Add compression stats

Add compression statistics to the compressors. It tracks
the number of blocks that can fit into a certain power
of two size, and the number of decompressions.

For example, if a block is compressed to 100 bits, it will
belong to the 128-bits compression size. Although it could
also fit bigger sizes, they are not taken into account for
the stats (i.e., the 100-bit compression will fit only the
128-bits size, not 256 or higher).

We save stats for compressions that fail (i.e., compressed
size is bigger than original cache line size).

Change-Id: Idab71a40a660e33259908ccd880e42a880b5ee06
---
M src/mem/cache/compressors/base.cc
M src/mem/cache/compressors/base.hh
2 files changed, 60 insertions(+), 1 deletion(-)



diff --git a/src/mem/cache/compressors/base.cc b/src/mem/cache/compressors/base.cc
index 0f60eca..0513119 100644
--- a/src/mem/cache/compressors/base.cc
+++ b/src/mem/cache/compressors/base.cc
@@ -82,7 +82,16 @@
 BaseCacheCompressor::compress(const uint8_t* cache_line)
 {
     Cycles lat;
-    return compress(cache_line, lat);
+ std::unique_ptr<CompressionData> compression_data = compress(cache_line,
+                                                                 lat);
+
+    // Get compressed size in bits
+    std::size_t compressed_size = compression_data->getSize()*8;
+
+    // Update stats
+    compressionSize[std::ceil(std::log2(compressed_size))]++;
+
+    return compression_data;
 }

 Cycles
@@ -101,5 +110,35 @@
     assert(comp_data->matchLine(cache_line));
     #endif

+    // Update number of decompressions
+    decompressions++;
+
     return lat;
 }
+
+void
+BaseCacheCompressor::regStats()
+{
+    ClockedObject::regStats();
+
+    using namespace Stats;
+
+    decompressions
+        .name(name() + ".decompressions")
+        .desc("Number of decompressions")
+        ;
+
+    // We also store when compression is bigger than original line size
+    compressionSize
+        .init(std::log2(lineSize*8) + 2)
+        .name(name() + ".compression_size")
+        .desc("Number of blocks that were compressed to this power of" \
+              "two size.")
+        ;
+
+    for (unsigned i = 0; i <= std::log2(lineSize*8) + 1; ++i) {
+        compressionSize.subname(i, std::to_string(1 << i));
+ compressionSize.subdesc(i, "Number of blocks that compressed to fit " \ + "in " + std::to_string(1 << i) + " bits");
+    }
+}
diff --git a/src/mem/cache/compressors/base.hh b/src/mem/cache/compressors/base.hh
index fc36942..a3b0dd8 100644
--- a/src/mem/cache/compressors/base.hh
+++ b/src/mem/cache/compressors/base.hh
@@ -119,6 +119,21 @@
     const std::size_t lineSize;

     /**
+     * @defgroup CompressionStats Compression specific statistics.
+     * @{
+     */
+
+    /** Total number of decompressions. */
+    Stats::Scalar decompressions;
+
+    /** Number of blocks that were compressed to this power of two size. */
+    Stats::Vector compressionSize;
+
+    /**
+     * @}
+     */
+
+    /**
      * Apply the compression process to the cache line.
      * Returns the number of cycles used by the compressor, however it is
* usually covered by a good pipelined execution, and is currently ignored.
@@ -171,6 +186,11 @@
      * @return Decompression latency in number of cycles.
      */
     Cycles decompress(const CompressionData* comp_data);
+
+    /**
+     * Register local statistics.
+     */
+    void regStats();
 };

 #endif //__MEM_CACHE_COMPRESSORS_BASE_HH__

--
To view, visit https://gem5-review.googlesource.com/11103
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Idab71a40a660e33259908ccd880e42a880b5ee06
Gerrit-Change-Number: 11103
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to