Zhantong Qiu has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/64892?usp=email )
Change subject: sim: Added LoopPoint probes and multicore manager
......................................................................
sim: Added LoopPoint probes and multicore manager
LoopPoint is a multithread sampling method that targets PC and PC count
The LoopPoint probe object is used to keep track of the targeting PCs
and notice the LoopPointManager when the current PC is the targeting
PC.
The LoopPointManager is a SimObject that stores all the LoopPoints
related information and raise exit event when the targeting PC gets to
the targeting count.
Change-Id: Id2ab1b606e4a13a21fb79664243d4f140392d7b4
---
A src/cpu/probes/LoopPoint.py
A src/cpu/probes/LoopPointManager.py
A src/cpu/probes/SConscript
A src/cpu/probes/looppoint.cc
A src/cpu/probes/looppoint.hh
A src/cpu/probes/looppointmanager.cc
A src/cpu/probes/looppointmanager.hh
7 files changed, 531 insertions(+), 0 deletions(-)
diff --git a/src/cpu/probes/LoopPoint.py b/src/cpu/probes/LoopPoint.py
new file mode 100644
index 0000000..4ca12b6
--- /dev/null
+++ b/src/cpu/probes/LoopPoint.py
@@ -0,0 +1,39 @@
+# Copyright (c) 2022 The Regents of the University of California
+# All rights reserved.
+#
+# 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.params import *
+from m5.objects.Probe import ProbeListenerObject
+
+
+class LoopPoint(ProbeListenerObject):
+
+ type = "LoopPoint"
+ cxx_header = "cpu/probes/looppoint.hh"
+ cxx_class = "gem5::LoopPoint"
+
+ target_pc = VectorParam.UInt64("the target PC")
+ core = Param.BaseCPU("the connected cpu")
+ lpmanager = Param.LoopPointManager("the looppoint manager")
diff --git a/src/cpu/probes/LoopPointManager.py
b/src/cpu/probes/LoopPointManager.py
new file mode 100644
index 0000000..e57c153
--- /dev/null
+++ b/src/cpu/probes/LoopPointManager.py
@@ -0,0 +1,49 @@
+# Copyright (c) 2022 The Regents of the University of California
+# All rights reserved.
+#
+# 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.params import *
+from m5.objects import SimObject
+
+class LoopPointManager(SimObject):
+
+ type = "LoopPointManager"
+ cxx_header = "cpu/probes/looppointmanager.hh"
+ cxx_class = "gem5::LoopPointManager"
+
+ target_count = VectorParam.Int("the target PC count")
+ target_pc = VectorParam.UInt64("the target PC")
+ region_id = VectorParam.Int("the simulation region id")
+ relative_pc = VectorParam.UInt64("the relative PC of the target PC")
+ relative_count = VectorParam.Int("the relative PC count of the target
PC")
+
+ def setup(self, cpulist):
+ """This function takes in a list of AbstractCore and connect a
+ LoopPoint to each of them.
+
+ :param cpulist : a list of AbstractCore
+ """
+ for core in cpulist:
+ core.addLoopPointProbe(self.target_pc+self.relative_pc, self)
diff --git a/src/cpu/probes/SConscript b/src/cpu/probes/SConscript
new file mode 100644
index 0000000..057c402
--- /dev/null
+++ b/src/cpu/probes/SConscript
@@ -0,0 +1,34 @@
+# Copyright (c) 2022 The Regents of the University of California
+# All rights reserved.
+#
+# 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.
+
+Import('*')
+
+if not env['CONF']['USE_NULL_ISA']:
+ SimObject('LoopPoint.py', sim_objects=['LoopPoint'])
+ Source('looppoint.cc')
+
+ SimObject('LoopPointManager.py', sim_objects=['LoopPointManager'])
+ Source('looppointmanager.cc')
diff --git a/src/cpu/probes/looppoint.cc b/src/cpu/probes/looppoint.cc
new file mode 100644
index 0000000..eec1bdb
--- /dev/null
+++ b/src/cpu/probes/looppoint.cc
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2022 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "cpu/probes/looppoint.hh"
+
+namespace gem5
+{
+
+LoopPoint::LoopPoint(const LoopPointParams &p)
+ : ProbeListenerObject(p),
+ cpuptr(p.core),
+ manager(p.lpmanager)
+{
+ if (!cpuptr || !manager) {
+ fatal("%s is NULL", !cpuptr ? "CPU":"LoopPointManager");
+ }
+ // It loops through the target_pc vector param to construct the
targetPC
+ // set. Only the unseen PC will be inserted in the targetPC set.
+ for (int i = 0; i< p.target_pc.size(); i++) {
+ if(p.target_pc[i]!= 0 &&
+ targetPC.find(p.target_pc[i])==targetPC.end()) {
+ targetPC.insert(p.target_pc[i]);
+ }
+ }
+}
+
+LoopPoint::~LoopPoint()
+{}
+
+void
+LoopPoint::init()
+{}
+
+void
+LoopPoint::regProbeListeners()
+{
+ typedef ProbeListenerArg<LoopPoint, Addr> LoopPointListener;
+ listeners.push_back(new LoopPointListener(this, "RetiredInstsPC",
+ &LoopPoint::check_pc));
+}
+
+void
+LoopPoint::check_pc(const Addr& pc)
+{
+ if(targetPC.find(pc) != targetPC.end()) {
+ manager->check_count(pc);
+ }
+}
+
+}
diff --git a/src/cpu/probes/looppoint.hh b/src/cpu/probes/looppoint.hh
new file mode 100644
index 0000000..c6f6e10
--- /dev/null
+++ b/src/cpu/probes/looppoint.hh
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2022 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef __CPU_PROBES_LOOPPOINT_HH__
+#define __CPU_PROBES_LOOPPOINT_HH__
+
+#include <unordered_set>
+
+#include "cpu/base.hh"
+#include "cpu/probes/looppointmanager.hh"
+#include "params/LoopPoint.hh"
+#include "sim/probe/probe.hh"
+
+namespace gem5
+{
+
+class LoopPoint : public ProbeListenerObject
+{
+ public:
+ LoopPoint(const LoopPointParams ¶ms);
+ virtual ~LoopPoint();
+ virtual void init();
+ /**
+ * @brief This connects a ProbeListener to the "RetiredInstsPC"
ProbePoint
+ * from the corresponding core.
+ */
+ virtual void regProbeListeners();
+ /**
+ * @brief When the "RetiredInstsPC" ProbePoint notifys the
ProbeListener,
+ * this function is called. This function will check if the committed
PC
+ * matches the target PC. If it does, then it will call the
check_count()
+ * in its LoopPointManager.
+ */
+ void check_pc(const Addr&);
+
+ private:
+ /** This stores the targetPC.
+ */
+ std::unordered_set<Addr> targetPC;
+ /** The pointer to the connected core.
+ */
+ BaseCPU *cpuptr;
+ /** The pointer to its LoopPointManager.
+ */
+ LoopPointManager *manager;
+
+};
+
+}
+
+#endif // __CPU_PROBES_LOOPPOINT_HH__
diff --git a/src/cpu/probes/looppointmanager.cc
b/src/cpu/probes/looppointmanager.cc
new file mode 100644
index 0000000..64cddb4
--- /dev/null
+++ b/src/cpu/probes/looppointmanager.cc
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2022 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#include "cpu/probes/looppointmanager.hh"
+
+namespace gem5
+{
+LoopPointManager::LoopPointManager(const LoopPointManagerParams &p)
+ : SimObject(p)
+{
+ // This loops through the target_pc vector param to construct the
counter
+ // map and the targetCount map. If the PC is unseen in the maps, then
the
+ // counter inserts a new item with the PC as the key and an integer 0
as
+ // the value. The targetCount inserts a new item with the PC as the
key and
+ // a new vector that contains the PC's target count (target_count[i])
as
+ // the value. If the PC is in the maps, then the targetCount push_back
the
+ // new target count (target_count[i]) for that PC in its corresponding
+ // vector.
+ if_inputRelative = true;
+ if(p.relative_pc.empty()) {
+ if_inputRelative = false;
+ }
+ int rPCcounter = 0;
+
+ for (int i = 0; i< p.target_pc.size(); i++) {
+ auto map_itr = targetCount.find(p.target_pc[i]);
+ if (map_itr == targetCount.end()) {
+ std::vector<int> pcCount = {p.target_count[i]};
+ targetCount.insert(std::make_pair(p.target_pc[i], pcCount));
+ counter.insert(std::make_pair(p.target_pc[i],0));
+ } else {
+ std::vector<int>& pcCount = map_itr->second;
+ pcCount.push_back(p.target_count[i]);
+ }
+ regionId.insert(
+ std::make_pair(
+ std::make_pair(p.target_pc[i],p.target_count[i]),
+ p.region_id[i]
+ )
+ );
+ if (if_inputRelative) {
+ std::vector<Addr> rPC;
+ std::vector<int> rPCcount;
+ for (int j = 0; j < 2; j++)
+ {
+ if(p.relative_pc[rPCcounter] != 0) {
+ if(
+
counter.find(p.relative_pc[rPCcounter])==counter.end()
+ ) {
+ counter.insert(
+ std::make_pair(p.relative_pc[rPCcounter],0)
+ );
+ }
+ rPC.push_back(p.relative_pc[rPCcounter]);
+ rPCcount.push_back(p.relative_count[rPCcounter]);
+ }
+ rPCcounter ++;
+ }
+ relativePC.insert(
+ std::make_pair(
+ std::make_pair(p.target_pc[i],p.target_count[i]),
+ std::make_pair(rPC,rPCcount)
+ )
+ );
+ }
+ }
+ info = simout.create("LoopPointInfo.txt", false);
+ if (!info) {
+ fatal("unable to open LoopPoint info txt");
+ }
+
+}
+
+LoopPointManager::~LoopPointManager()
+{
+ simout.close(info);
+}
+
+void
+LoopPointManager::init()
+{}
+
+void
+LoopPointManager::check_count(Addr pc)
+{
+ int& count = counter.find(pc) -> second;
+ // increase the count for the target PC
+ count += 1;
+
+ auto map_itr = targetCount.find(pc);
+ if (map_itr != targetCount.end()) {
+ std::vector<int>& targetcount = map_itr -> second;
+ // loop through its target count vector to check for the matching
count
+ for (std::vector<int>::iterator iter = targetcount.begin();
+ iter < targetcount.end();
iter++) {
+ // if matching count found, then erase the target count from
the
+ // vector, record the infomation, and raise an exit event
+ if(*iter==count) {
+ targetcount.erase(iter);
+ *info->stream() << curTick() << ":" <<
+
regionId.find(std::make_pair(pc,count))->second
+ << ":" << pc << ":" <<
count;
+ if (if_inputRelative) {
+ auto rela_itr =
relativePC.find(std::make_pair(pc,count));
+ std::vector<Addr>& rPC = rela_itr->second.first;
+ std::vector<int>& rPCcount = rela_itr->second.second;
+ int rela_count = 0;
+ for (int i = 0; i< rPC.size(); i++) {
+ rela_count =
rPCcount[i]-counter.find(rPC[i])->second;
+ *info->stream() << ":" << rPC[i] << ":" <<
rela_count;
+ }
+ }
+ *info->stream() <<":"<< "\n";
+ exitSimLoopNow("simpoint starting point found");
+ if(targetcount.size()==0) {
+ targetCount.erase(pc);
+ if (targetCount.size()==0) {
+ printf("\nall targets are encountered\n");
+ exitSimLoop("m5_exit instruction encountered");
+ }
+ }
+ }
+ }
+ }
+
+}
+
+
+}
diff --git a/src/cpu/probes/looppointmanager.hh
b/src/cpu/probes/looppointmanager.hh
new file mode 100644
index 0000000..688e8a1
--- /dev/null
+++ b/src/cpu/probes/looppointmanager.hh
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2022 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef __CPU_PROBES_LOOPPOINTMANAGER_HH__
+#define __CPU_PROBES_LOOPPOINTMANAGER_HH__
+
+#include <unordered_map>
+
+#include "cpu/base.hh"
+#include "params/LoopPointManager.hh"
+#include "sim/probe/probe.hh"
+#include "base/output.hh"
+#include "sim/sim_exit.hh"
+
+namespace gem5
+{
+
+class LoopPointManager : public SimObject
+{
+ public:
+ LoopPointManager(const LoopPointManagerParams ¶ms);
+ virtual ~LoopPointManager();
+ virtual void init();
+ /**
+ * @brief This function checks if the current count for the input PC
+ * matches the target count of the PC. If they match, then it raises an
+ * exit event to exit the Simulation loop.
+ *
+ * @param pc The target PC of LoopPoint
+ */
+ void check_count(Addr pc);
+
+ private:
+ /** This output a file thats has [currTick : PC : Count] for each exit
event
+ * raised.
+ */
+ OutputStream *info;
+ /** This stores the target counts for each target PC.
+ * ex. PC 0x4069d0 has target count [211076617, 219060252, 407294228]
+ */
+ std::unordered_map<Addr, std::vector<int>> targetCount;
+ /** This stores the current count for each target PC.
+ */
+ std::unordered_map<Addr, int> counter;
+
+ struct pair_hash {
+ std::size_t operator () (const std::pair<Addr,int> &p) const {
+ auto h1 = std::hash<Addr>{}(p.first);
+ auto h2 = std::hash<int>{}(p.second);
+ return h1 ^ h2;
+ }
+ };
+
+ std::unordered_map<std::pair<Addr,int>,
std::pair<std::vector<Addr>,std::vector<int>>, pair_hash> relativePC;
+ std::unordered_map<std::pair<Addr,int>, int, pair_hash> regionId;
+ bool if_inputRelative;
+};
+
+}
+
+#endif // __CPU_PROBES_LOOPPOINTMANAGER_HH__
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/64892?usp=email
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: Id2ab1b606e4a13a21fb79664243d4f140392d7b4
Gerrit-Change-Number: 64892
Gerrit-PatchSet: 1
Gerrit-Owner: Zhantong Qiu <zt...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org