mem: Add stack distance statistics to the CommMonitor
authorKanishk Sugand <kanishk.sugand@arm.com>
Tue, 23 Dec 2014 14:31:18 +0000 (09:31 -0500)
committerKanishk Sugand <kanishk.sugand@arm.com>
Tue, 23 Dec 2014 14:31:18 +0000 (09:31 -0500)
This patch adds the stack distance calculator to the CommMonitor. The
stats are disabled by default.

src/mem/CommMonitor.py
src/mem/comm_monitor.cc
src/mem/comm_monitor.hh

index ba871357d2b7658d5479e6c1f37b6f75c05398ba..a87b0478725c9d7d2bd705f857426b24d8c9f081 100644 (file)
@@ -110,3 +110,6 @@ class CommMonitor(MemObject):
     read_addr_mask = Param.Addr(MaxAddr, "Address mask for read address")
     write_addr_mask = Param.Addr(MaxAddr, "Address mask for write address")
     disable_addr_dists = Param.Bool(True, "Disable address distributions")
+
+    # optional stack distance calculator
+    stack_dist_calc = Param.StackDistCalc(NULL, "Stack distance calculator")
index c9cbcb143d395f9bd68e2d9fbff64a4aa074123f..7539672ccbe579e0c340819a24b2fe2e2201b24f 100644 (file)
@@ -55,6 +55,7 @@ CommMonitor::CommMonitor(Params* params)
       readAddrMask(params->read_addr_mask),
       writeAddrMask(params->write_addr_mask),
       stats(params),
+      stackDistCalc(params->stack_dist_calc),
       traceStream(NULL),
       system(params->system)
 {
@@ -137,6 +138,7 @@ CommMonitor::init()
         if (!system->isTimingMode())
             warn("%s: Not in timing mode. No trace will be recorded.", name());
     }
+
 }
 
 BaseMasterPort&
@@ -174,6 +176,10 @@ CommMonitor::recvFunctionalSnoop(PacketPtr pkt)
 Tick
 CommMonitor::recvAtomic(PacketPtr pkt)
 {
+    // allow stack distance calculations for atomic if enabled
+    if (stackDistCalc)
+        stackDistCalc->update(pkt->cmd, pkt->getAddr());
+
     return masterPort.sendAtomic(pkt);
 }
 
@@ -193,7 +199,8 @@ CommMonitor::recvTimingReq(PacketPtr pkt)
     // or even deleted when sendTiming() is called.
     bool is_read = pkt->isRead();
     bool is_write = pkt->isWrite();
-    int cmd = pkt->cmdToIndex();
+    MemCmd cmd = pkt->cmd;
+    int cmd_idx = pkt->cmdToIndex();
     Request::FlagsType req_flags = pkt->req->getFlags();
     unsigned size = pkt->getSize();
     Addr addr = pkt->getAddr();
@@ -216,13 +223,18 @@ CommMonitor::recvTimingReq(PacketPtr pkt)
         delete pkt->popSenderState();
     }
 
+    // If successful and we are calculating stack distances, update
+    // the calculator
+    if (successful && stackDistCalc)
+        stackDistCalc->update(cmd, addr);
+
     if (successful && traceStream != NULL) {
         // Create a protobuf message representing the
         // packet. Currently we do not preserve the flags in the
         // trace.
         ProtoMessage::Packet pkt_msg;
         pkt_msg.set_tick(curTick());
-        pkt_msg.set_cmd(cmd);
+        pkt_msg.set_cmd(cmd_idx);
         pkt_msg.set_flags(req_flags);
         pkt_msg.set_addr(addr);
         pkt_msg.set_size(size);
index 69122cc6042f19b6055aad3a41240bd0fb9edb94..f1c6b496d222dbf71a36ba3d357f2f25e82f4250 100644 (file)
@@ -44,6 +44,7 @@
 #include "base/statistics.hh"
 #include "base/time.hh"
 #include "mem/mem_object.hh"
+#include "mem/stack_dist_calc.hh"
 #include "params/CommMonitor.hh"
 #include "proto/protoio.hh"
 #include "sim/system.hh"
@@ -268,8 +269,6 @@ class CommMonitor : public MemObject
 
     void recvRangeChange();
 
-    void periodicTraceDump();
-
     /** Stats declarations, all in a struct for convenience. */
     struct MonitorStats
     {
@@ -417,6 +416,9 @@ class CommMonitor : public MemObject
     /** Instantiate stats */
     MonitorStats stats;
 
+    /** Optional stack distance calculator */
+    StackDistCalc* stackDistCalc;
+
     /** Output stream for a potential trace. */
     ProtoOutputStream* traceStream;