changeset a114e2712642 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=a114e2712642
description:
        mem: Redesign the stack distance calculator as a probe

        This changeset removes the stack distance calculator hooks from the
        CommMonitor class and implements a stack distance calculator as a
        memory system probe instead. The probe can be hooked up to any
        component that exports probe points of the type ProbePoints::Packet.

diffstat:

 src/mem/CommMonitor.py           |    3 -
 src/mem/SConscript               |    1 -
 src/mem/StackDistCalc.py         |   54 ---------------
 src/mem/comm_monitor.cc          |   10 --
 src/mem/comm_monitor.hh          |    4 -
 src/mem/probes/SConscript        |    3 +
 src/mem/probes/StackDistProbe.py |   64 ++++++++++++++++++
 src/mem/probes/stack_dist.cc     |  138 +++++++++++++++++++++++++++++++++++++++
 src/mem/probes/stack_dist.hh     |   91 +++++++++++++++++++++++++
 src/mem/stack_dist_calc.cc       |   81 +--------------------
 src/mem/stack_dist_calc.hh       |  105 +++++++++--------------------
 tests/configs/tgen-simple-mem.py |    4 +-
 12 files changed, 339 insertions(+), 219 deletions(-)

diffs (truncated from 733 to 300 lines):

diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/CommMonitor.py
--- a/src/mem/CommMonitor.py    Tue Aug 04 10:29:13 2015 +0100
+++ b/src/mem/CommMonitor.py    Tue Aug 04 10:29:13 2015 +0100
@@ -110,6 +110,3 @@
     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")
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/SConscript
--- a/src/mem/SConscript        Tue Aug 04 10:29:13 2015 +0100
+++ b/src/mem/SConscript        Tue Aug 04 10:29:13 2015 +0100
@@ -44,7 +44,6 @@
 SimObject('ExternalSlave.py')
 SimObject('MemObject.py')
 SimObject('SimpleMemory.py')
-SimObject('StackDistCalc.py')
 SimObject('XBar.py')
 
 Source('abstract_mem.cc')
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/StackDistCalc.py
--- a/src/mem/StackDistCalc.py  Tue Aug 04 10:29:13 2015 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-# Copyright (c) 2014 ARM Limited
-# All rights reserved.
-#
-# The license below extends only to copyright in the software and shall
-# not be construed as granting a license to any other intellectual
-# property including but not limited to intellectual property relating
-# to a hardware implementation of the functionality of the software
-# licensed hereunder.  You may use the software subject to the license
-# terms below provided that you ensure that this notice is replicated
-# unmodified and in its entirety in all distributions of the software,
-# modified or unmodified, in source code or in binary form.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met: redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer;
-# redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution;
-# neither the name of the copyright holders nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Authors: Andreas Hansson
-
-from m5.SimObject import SimObject
-from m5.params import *
-
-class StackDistCalc(SimObject):
-    type = 'StackDistCalc'
-    cxx_header = "mem/stack_dist_calc.hh"
-
-    # enable verification stack
-    verify = Param.Bool(False, "Verify behaviuor with reference 
implementation")
-
-    # linear histogram bins and enable/disable
-    linear_hist_bins = Param.Unsigned('16', "Bins in linear histograms")
-    disable_linear_hists = Param.Bool(False, "Disable linear histograms")
-
-    # logarithmic histogram bins and enable/disable
-    log_hist_bins = Param.Unsigned('32', "Bins in logarithmic histograms")
-    disable_log_hists = Param.Bool(False, "Disable logarithmic histograms")
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/comm_monitor.cc
--- a/src/mem/comm_monitor.cc   Tue Aug 04 10:29:13 2015 +0100
+++ b/src/mem/comm_monitor.cc   Tue Aug 04 10:29:13 2015 +0100
@@ -55,7 +55,6 @@
       samplePeriod(params->sample_period / SimClock::Float::s),
       readAddrMask(params->read_addr_mask),
       writeAddrMask(params->write_addr_mask),
-      stackDistCalc(params->stack_dist_calc),
       system(params->system),
       traceStream(nullptr),
       stats(params)
@@ -183,10 +182,6 @@
 {
     ppPktReq->notify(pkt);
 
-    // do stack distance calculations if enabled
-    if (stackDistCalc)
-        stackDistCalc->update(pkt->cmd, pkt->getAddr());
-
     // if tracing enabled, store the packet information
     // to the trace stream
     if (traceStream != NULL) {
@@ -258,11 +253,6 @@
         pkt->cmd = response_cmd;
     }
 
-    // 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
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/comm_monitor.hh
--- a/src/mem/comm_monitor.hh   Tue Aug 04 10:29:13 2015 +0100
+++ b/src/mem/comm_monitor.hh   Tue Aug 04 10:29:13 2015 +0100
@@ -43,7 +43,6 @@
 
 #include "base/statistics.hh"
 #include "mem/mem_object.hh"
-#include "mem/stack_dist_calc.hh"
 #include "params/CommMonitor.hh"
 #include "proto/protoio.hh"
 #include "sim/probe/mem.hh"
@@ -417,9 +416,6 @@
     /** Address mask for sources of write accesses to be captured */
     const Addr writeAddrMask;
 
-    /** Optional stack distance calculator */
-    StackDistCalc *const stackDistCalc;
-
     /** The system in which the monitor lives */
     System *const system;
 
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/probes/SConscript
--- a/src/mem/probes/SConscript Tue Aug 04 10:29:13 2015 +0100
+++ b/src/mem/probes/SConscript Tue Aug 04 10:29:13 2015 +0100
@@ -41,3 +41,6 @@
 
 SimObject('BaseMemProbe.py')
 Source('base.cc')
+
+SimObject('StackDistProbe.py')
+Source('stack_dist.cc')
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/probes/StackDistProbe.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mem/probes/StackDistProbe.py  Tue Aug 04 10:29:13 2015 +0100
@@ -0,0 +1,64 @@
+# Copyright (c) 2014-2015 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Andreas Hansson
+#          Andreas Sandberg
+
+from m5.params import *
+from m5.proxy import *
+from BaseMemProbe import BaseMemProbe
+
+class StackDistProbe(BaseMemProbe):
+    type = 'StackDistProbe'
+    cxx_header = "mem/probes/stack_dist.hh"
+
+    system = Param.System(Parent.any,
+                          "System to use when determining system cache "
+                          "line size")
+
+    line_size = Param.Unsigned(Parent.cache_line_size,
+                               "Cache line size in bytes (must be larger or "
+                               "equal to the system's line size)")
+
+    # enable verification stack
+    verify = Param.Bool(False, "Verify behaviuor with reference 
implementation")
+
+    # linear histogram bins and enable/disable
+    linear_hist_bins = Param.Unsigned('16', "Bins in linear histograms")
+    disable_linear_hists = Param.Bool(False, "Disable linear histograms")
+
+    # logarithmic histogram bins and enable/disable
+    log_hist_bins = Param.Unsigned('32', "Bins in logarithmic histograms")
+    disable_log_hists = Param.Bool(False, "Disable logarithmic histograms")
diff -r 51ff41f6a4a5 -r a114e2712642 src/mem/probes/stack_dist.cc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mem/probes/stack_dist.cc      Tue Aug 04 10:29:13 2015 +0100
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2015 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Andreas Sandberg
+ */
+
+#include "mem/probes/stack_dist.hh"
+
+#include "params/StackDistProbe.hh"
+#include "sim/system.hh"
+
+StackDistProbe::StackDistProbe(StackDistProbeParams *p)
+    : BaseMemProbe(p),
+      lineSize(p->line_size),
+      disableLinearHists(p->disable_linear_hists),
+      disableLogHists(p->disable_log_hists),
+      calc(p->verify)
+{
+    fatal_if(p->system->cacheLineSize() > p->line_size,
+             "The stack distance probe must use a cache line size that is "
+             "larger or equal to the system's cahce line size.");
+}
+
+void
+StackDistProbe::regStats()
+{
+    const StackDistProbeParams *p(
+        dynamic_cast<const StackDistProbeParams *>(params()));
+    assert(p);
+
+    using namespace Stats;
+
+    readLinearHist
+        .init(p->linear_hist_bins)
+        .name(name() + ".readLinearHist")
+        .desc("Reads linear distribution")
+        .flags(disableLinearHists ? nozero : pdf);
+
+    readLogHist
+        .init(p->log_hist_bins)
+        .name(name() + ".readLogHist")
+        .desc("Reads logarithmic distribution")
+        .flags(disableLogHists ? nozero : pdf);
+
+    writeLinearHist
+        .init(p->linear_hist_bins)
+        .name(name() + ".writeLinearHist")
+        .desc("Writes linear distribution")
+        .flags(disableLinearHists ? nozero : pdf);
+
+    writeLogHist
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to