Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/38704 )

Change subject: RFC,sim: Remove ProbeListenerObject
......................................................................

RFC,sim: Remove ProbeListenerObject

The ProbeListenerObject is supposed to act as a wrapper
for SimObjects whose probe manager is the one of another
object.

The way this is implemented seems confusing, and it might
be better to explicitly call the object's manager on the
code that needs it.

Jira: https://gem5.atlassian.net/browse/GEM5-857

Change-Id: I88ad979dbede096f0227cca493769fd9e14e01a5
Signed-off-by: Daniel R. Carvalho <[email protected]>
---
M src/cpu/o3/probe/ElasticTrace.py
M src/cpu/o3/probe/SimpleTrace.py
M src/cpu/o3/probe/elastic_trace.cc
M src/cpu/o3/probe/elastic_trace.hh
M src/cpu/o3/probe/simple_trace.hh
M src/cpu/simple/probes/SimPoint.py
M src/cpu/simple/probes/simpoint.cc
M src/cpu/simple/probes/simpoint.hh
M src/mem/probes/base.hh
M src/sim/power/power_model.hh
D src/sim/probe/Probe.py
M src/sim/probe/SConscript
M src/sim/probe/probe.cc
M src/sim/probe/probe.hh
14 files changed, 37 insertions(+), 126 deletions(-)



diff --git a/src/cpu/o3/probe/ElasticTrace.py b/src/cpu/o3/probe/ElasticTrace.py
index d80b18a..95677c1 100644
--- a/src/cpu/o3/probe/ElasticTrace.py
+++ b/src/cpu/o3/probe/ElasticTrace.py
@@ -33,12 +33,16 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-from m5.objects.Probe import *
+from m5.params import *
+from m5.proxy import *
+from m5.SimObject import *
+from m5.objects.BaseCPU import *

-class ElasticTrace(ProbeListenerObject):
+class ElasticTrace(SimObject):
     type = 'ElasticTrace'
     cxx_header = 'cpu/o3/probe/elastic_trace.hh'

+    cpu = Param.BaseCPU(Parent.any, "CPU managing this probe")
# Trace files for the following params are created in the output directory. # User is forced to provide these when an instance of this class is created. instFetchTraceFile = Param.String(desc="Protobuf trace file name for " \ diff --git a/src/cpu/o3/probe/SimpleTrace.py b/src/cpu/o3/probe/SimpleTrace.py
index 10f27f3..58dbf70 100644
--- a/src/cpu/o3/probe/SimpleTrace.py
+++ b/src/cpu/o3/probe/SimpleTrace.py
@@ -33,8 +33,9 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-from m5.objects.Probe import *
+from m5.params import *
+from m5.SimObject import *

-class SimpleTrace(ProbeListenerObject):
+class SimpleTrace(SimObject):
     type = 'SimpleTrace'
     cxx_header = 'cpu/o3/probe/simple_trace.hh'
diff --git a/src/cpu/o3/probe/elastic_trace.cc b/src/cpu/o3/probe/elastic_trace.cc
index 9ef32df..81ae9ae 100644
--- a/src/cpu/o3/probe/elastic_trace.cc
+++ b/src/cpu/o3/probe/elastic_trace.cc
@@ -47,7 +47,7 @@
 #include "mem/packet.hh"

 ElasticTrace::ElasticTrace(const ElasticTraceParams &params)
-    :  ProbeListenerObject(params),
+    :  SimObject(params),
        regEtraceListenersEvent([this]{ regEtraceListeners(); }, name()),
        firstWin(true),
        lastClearedSeqNum(0),
@@ -59,7 +59,7 @@
        traceVirtAddr(params.traceVirtAddr),
        stats(this)
 {
-    cpu = dynamic_cast<FullO3CPU<O3CPUImpl>*>(params.manager);
+    cpu = dynamic_cast<FullO3CPU<O3CPUImpl>*>(params.cpu);
     fatal_if(!cpu, "Manager of %s is not of type O3CPU and thus does not "\
                 "support dependency tracing.\n", name());

@@ -119,25 +119,25 @@
         " probe listeners", curTick(), cpu->numSimulatedInsts());
// Create new listeners: provide method to be called upon a notify() for
     // each probe point.
-    getProbeManager()->addListener("FetchRequest",
+    cpu->getProbeManager()->addListener("FetchRequest",
         new ProbeListenerArg<ElasticTrace, RequestPtr>(
         this, &ElasticTrace::fetchReqTrace));
-    getProbeManager()->addListener("Execute",
+    cpu->getProbeManager()->addListener("Execute",
         new ProbeListenerArg<ElasticTrace, DynInstConstPtr>(
         this, &ElasticTrace::recordExecTick));
-    getProbeManager()->addListener("ToCommit",
+    cpu->getProbeManager()->addListener("ToCommit",
         new ProbeListenerArg<ElasticTrace, DynInstConstPtr>(
         this, &ElasticTrace::recordToCommTick));
-    getProbeManager()->addListener("Rename",
+    cpu->getProbeManager()->addListener("Rename",
         new ProbeListenerArg<ElasticTrace, DynInstConstPtr>(
         this, &ElasticTrace::updateRegDep));
-    getProbeManager()->addListener("SquashInRename",
+    cpu->getProbeManager()->addListener("SquashInRename",
         new ProbeListenerArg<ElasticTrace, SeqNumRegPair>(
         this, &ElasticTrace::removeRegDepMapEntry));
-    getProbeManager()->addListener("Squash",
+    cpu->getProbeManager()->addListener("Squash",
         new ProbeListenerArg<ElasticTrace, DynInstConstPtr>(
         this, &ElasticTrace::addSquashedInst));
-    getProbeManager()->addListener("Commit",
+    cpu->getProbeManager()->addListener("Commit",
         new ProbeListenerArg<ElasticTrace, DynInstConstPtr>(
         this, &ElasticTrace::addCommittedInst));
     allProbesReg = true;
@@ -908,12 +908,6 @@
     return Record::RecordType_Name(type);
 }

-const std::string
-ElasticTrace::name() const
-{
-    return ProbeListenerObject::name();
-}
-
 void
 ElasticTrace::flushTraces()
 {
diff --git a/src/cpu/o3/probe/elastic_trace.hh b/src/cpu/o3/probe/elastic_trace.hh
index 1c44873..ad85fa7 100644
--- a/src/cpu/o3/probe/elastic_trace.hh
+++ b/src/cpu/o3/probe/elastic_trace.hh
@@ -58,7 +58,7 @@
 #include "proto/packet.pb.h"
 #include "proto/protoio.hh"
 #include "sim/eventq.hh"
-#include "sim/probe/probe.hh"
+#include "sim/sim_object.hh"

 /**
* The elastic trace is a type of probe listener and listens to probe points
@@ -81,7 +81,7 @@
  *
  * The output trace can be read in and played back by the TraceCPU.
  */
-class ElasticTrace : public ProbeListenerObject
+class ElasticTrace : public SimObject
 {

   public:
@@ -105,9 +105,6 @@
     /** Register all listeners. */
     void regEtraceListeners();

-    /** Returns the name of the trace probe listener. */
-    const std::string name() const;
-
     /**
* Process any outstanding trace records, flush them out to the protobuf
      * output streams and delete the streams at simulation exit.
diff --git a/src/cpu/o3/probe/simple_trace.hh b/src/cpu/o3/probe/simple_trace.hh
index 2cd409f..7b26b87 100644
--- a/src/cpu/o3/probe/simple_trace.hh
+++ b/src/cpu/o3/probe/simple_trace.hh
@@ -47,21 +47,18 @@
 #include "cpu/o3/dyn_inst.hh"
 #include "cpu/o3/impl.hh"
 #include "params/SimpleTrace.hh"
-#include "sim/probe/probe.hh"
+#include "sim/sim_object.hh"

-class SimpleTrace : public ProbeListenerObject {
-
+class SimpleTrace : public SimObject
+{
   public:
-    SimpleTrace(const SimpleTraceParams &params):
-        ProbeListenerObject(params)
-    {
-    }
+    SimpleTrace(const SimpleTraceParams &params) : SimObject(params) {}

     /** Register the probe listeners. */
     void regProbeListeners();

     /** Returns the name of the trace. */
- const std::string name() const { return ProbeListenerObject::name() + ".trace"; }
+    const std::string name() const { return SimObject::name() + ".trace"; }

   private:
     void traceFetch(const O3CPUImpl::DynInstConstPtr& dynInst);
diff --git a/src/cpu/simple/probes/SimPoint.py b/src/cpu/simple/probes/SimPoint.py
index ec2c2f8..f8fb133 100644
--- a/src/cpu/simple/probes/SimPoint.py
+++ b/src/cpu/simple/probes/SimPoint.py
@@ -34,9 +34,9 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 from m5.params import *
-from m5.objects.Probe import ProbeListenerObject
+from m5.SimObject import *

-class SimPoint(ProbeListenerObject):
+class SimPoint(SimObject):
     """Probe for collecting SimPoint Basic Block Vectors (BBVs)."""

     type = 'SimPoint'
diff --git a/src/cpu/simple/probes/simpoint.cc b/src/cpu/simple/probes/simpoint.cc
index d495d8c..1f20757 100644
--- a/src/cpu/simple/probes/simpoint.cc
+++ b/src/cpu/simple/probes/simpoint.cc
@@ -42,7 +42,7 @@
 #include "base/output.hh"

 SimPoint::SimPoint(const SimPointParams &p)
-    : ProbeListenerObject(p),
+    : SimObject(p),
       intervalSize(p.interval),
       intervalCount(0),
       intervalDrift(0),
diff --git a/src/cpu/simple/probes/simpoint.hh b/src/cpu/simple/probes/simpoint.hh
index 07467f6..21cd70a 100644
--- a/src/cpu/simple/probes/simpoint.hh
+++ b/src/cpu/simple/probes/simpoint.hh
@@ -43,7 +43,7 @@
 #include "base/output.hh"
 #include "cpu/simple_thread.hh"
 #include "params/SimPoint.hh"
-#include "sim/probe/probe.hh"
+#include "sim/sim_object.hh"

 /**
  * Probe for SimPoints BBV generation
@@ -69,7 +69,7 @@
 };
 }

-class SimPoint : public ProbeListenerObject
+class SimPoint : public SimObject
 {
   public:
     SimPoint(const SimPointParams &params);
diff --git a/src/mem/probes/base.hh b/src/mem/probes/base.hh
index 3264422..c496254 100644
--- a/src/mem/probes/base.hh
+++ b/src/mem/probes/base.hh
@@ -50,13 +50,12 @@
  * Base class for memory system probes accepting Packet instances.
  *
  * This is a helper base class for memory system probes that
- * instrument Packet handling. Unlike the ProbeListenerObject base
- * class, this class supports instrumentation of multiple ProbeManager
- * instances. However, it's limited to one probe point name. This
- * enables features like tracing or stack distance analysis of packets
- * from multiple components using the same probe. For example, a stack
- * distance probe could be hooked up to multiple memories in a
- * multi-channel configuration.
+ * instrument Packet handling. Unlike regular SimObjects, this class
+ * supports instrumentation of multiple ProbeManager instances. However,
+ * it's limited to one probe point name. This enables features like
+ * tracing or stack distance analysis of packets from multiple components
+ * using the same probe. For example, a stack distance probe could be
+ * hooked up to multiple memories in a multi-channel configuration.
  */
 class BaseMemProbe : public SimObject
 {
diff --git a/src/sim/power/power_model.hh b/src/sim/power/power_model.hh
index 2aa6527..d100948 100644
--- a/src/sim/power/power_model.hh
+++ b/src/sim/power/power_model.hh
@@ -43,8 +43,8 @@
 #include "params/PowerModel.hh"
 #include "params/PowerModelState.hh"
 #include "sim/probe/probe.hh"
+#include "sim/sim_object.hh"

-class SimObject;
 class ClockedObject;

 /**
diff --git a/src/sim/probe/Probe.py b/src/sim/probe/Probe.py
deleted file mode 100644
index c1b98e3..0000000
--- a/src/sim/probe/Probe.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- mode:python -*-
-
-# Copyright (c) 2013 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.
-
-from m5.SimObject import SimObject
-from m5.params import *
-from m5.proxy import *
-
-class ProbeListenerObject(SimObject):
-    type = 'ProbeListenerObject'
-    cxx_header = 'sim/probe/probe.hh'
-    manager = Param.SimObject(Parent.any, "ProbeManager")
diff --git a/src/sim/probe/SConscript b/src/sim/probe/SConscript
index 8123e4e..ab1d3fb 100644
--- a/src/sim/probe/SConscript
+++ b/src/sim/probe/SConscript
@@ -37,6 +37,5 @@

 Import('*')

-SimObject('Probe.py')
 Source('probe.cc')
 DebugFlag('ProbeVerbose')
diff --git a/src/sim/probe/probe.cc b/src/sim/probe/probe.cc
index bf34632..997d80a 100644
--- a/src/sim/probe/probe.cc
+++ b/src/sim/probe/probe.cc
@@ -40,23 +40,11 @@

 #include "sim/probe/probe.hh"

-#include "base/logging.hh"
-#include "params/ProbeListenerObject.hh"
-
 ProbePoint::ProbePoint(const std::string& _name)
     : name(_name)
 {
 }

-ProbeListenerObject::ProbeListenerObject(
-        const ProbeListenerObjectParams &params)
-    : SimObject(params),
-      manager(params.manager->getProbeManager())
-{
-    fatal_if(manager == nullptr,
-        "The probe manager of %s has not been instantiated", name());
-}
-
 bool
 ProbeManager::addListener(std::string point_name, ProbeListener *listener)
 {
diff --git a/src/sim/probe/probe.hh b/src/sim/probe/probe.hh
index ee532c3..ba9e6af 100644
--- a/src/sim/probe/probe.hh
+++ b/src/sim/probe/probe.hh
@@ -49,9 +49,6 @@
  *                      a probe point event occurs. Multiple ProbeListeners
  *                      can be added to each ProbePoint.
  *
- * ProbeListenerObject: a wrapper around a SimObject that can connect to
- * another SimObject on which it will add ProbeListeners.
- *
  * ProbeManager:        used to match up ProbeListeners and ProbePoints.
  *                      At <b>simulation init</b> this is handled by
  *                      regProbePoints followed by regProbeListeners being
@@ -71,12 +68,10 @@
 #include "base/compiler.hh"
 #include "base/trace.hh"
 #include "debug/ProbeVerbose.hh"
-#include "sim/sim_object.hh"

 /** Forward declare the ProbeManager. */
 class ProbeManager;
 class ProbeListener;
-class ProbeListenerObjectParams;

 /**
  * Name space containing shared probe point declarations.
@@ -94,24 +89,6 @@
 }

 /**
- * This class is a minimal wrapper around SimObject. It is used to declare
- * a python derived object that can be added as a ProbeListener to any other
- * SimObject.
- *
- * It instantiates manager from a call to Parent.any.
- */
-class ProbeListenerObject : public SimObject
-{
-  protected:
-    ProbeManager *manager;
-
-  public:
-    ProbeListenerObject(const ProbeListenerObjectParams &params);
-    virtual ~ProbeListenerObject() = default;
-    ProbeManager* getProbeManager() { return manager; }
-};
-
-/**
  * ProbeListener base class; here to simplify things like containers
  * containing multiple types of ProbeListener.
  *

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

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I88ad979dbede096f0227cca493769fd9e14e01a5
Gerrit-Change-Number: 38704
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to