mem: Adding verbose debug output in the memory system
[gem5.git] / src / mem / cache / tags / base.cc
index e18026a21d957399e63eb3798176857dee85079e..0cabce860890a6160c702c409c37703a3fb34405 100644 (file)
  * Definitions of BaseTags.
  */
 
+#include "cpu/smt.hh" //maxThreadsPerCPU
 #include "mem/cache/tags/base.hh"
-
 #include "mem/cache/base.hh"
-#include "cpu/smt.hh" //maxThreadsPerCPU
 #include "sim/sim_exit.hh"
 
 using namespace std;
@@ -87,5 +86,26 @@ BaseTags::regStats(const string &name)
         .desc("Cycle when the warmup percentage was hit.")
         ;
 
+    occupancies
+        .init(cache->system->maxMasters())
+        .name(name + ".occ_blocks")
+        .desc("Average occupied blocks per requestor")
+        .flags(nozero | nonan)
+        ;
+    for (int i = 0; i < cache->system->maxMasters(); i++) {
+        occupancies.subname(i, cache->system->getMasterName(i));
+    }
+
+    avgOccs
+        .name(name + ".occ_percent")
+        .desc("Average percentage of cache occupancy")
+        .flags(nozero | total)
+        ;
+    for (int i = 0; i < cache->system->maxMasters(); i++) {
+        avgOccs.subname(i, cache->system->getMasterName(i));
+    }
+
+    avgOccs = occupancies / Stats::constant(numBlocks);
+
     registerExitCallback(new BaseTagsCallback(this));
 }