gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
inst_tracker.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
30
31namespace gem5
32{
33
34LocalInstTracker::LocalInstTracker(const LocalInstTrackerParams &params)
36 ifListening(params.start_listening),
37 globalInstTracker(params.global_inst_tracker)
38{
39 DPRINTF(InstTracker, "ifListening = %s\n", ifListening ? "true" : "false");
40}
41
42void
44{
45 if (ifListening) {
46 if (listeners.empty()) {
48 this, "RetiredInsts", &LocalInstTracker::retiredInstsHandler);
49 DPRINTF(InstTracker, "Start listening to RetiredInsts\n");
50 }
51 }
52}
53
54void
56{
57 globalInstTracker->updateAndCheckInstCount(inst);
58}
59
60void
62{
63 ifListening = false;
64 listeners.clear();
65 DPRINTF(InstTracker, "Stop listening to RetiredInsts\n");
66}
67
68
69GlobalInstTracker::GlobalInstTracker(const GlobalInstTrackerParams &params)
71 instCount(0)
72{
73 for (const auto &threshold : params.inst_thresholds) {
74 instThresholdSet.insert(threshold);
75 DPRINTF(InstTracker, "adding the instruction threshold\n"
76 "instThreshold = %lu\n", threshold);
77 }
78 DPRINTF(InstTracker, "instThresholdSet size = %lu\n",
79 instThresholdSet.size());
80}
81
82void
84{
85 instCount ++;
86 if (instThresholdSet.find(instCount) != instThresholdSet.end()) {
87 DPRINTF(InstTracker, "Instruction count reached the threshold\n"
88 "instCount = %lu\n",
89 instCount);
91 // note that when the threshold is reached, the simulation will raise
92 // and exit event but it will not reset the instruction counter.
93 // user can reset the counter by calling the resetCounter() function
94 // in the simulation script.
95 exitSimLoopNow("a thread reached the max instruction count");
96 }
97}
98
99} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:209
std::unordered_set< uint64_t > instThresholdSet
a set of thresholds for the number of instructions that should be executed before the simulation exit...
GlobalInstTracker(const GlobalInstTrackerParams &params)
uint64_t instCount
the number of instructions that have been executed across all the cores
void updateAndCheckInstCount(const uint64_t &inst)
this function is called by the LocalInstTracker object to update the instruction count and check if t...
virtual void regProbeListeners()
setup the probelistener
bool ifListening
a boolean variable that determines if the LocalInstTracker is listening to the ProbePoints or not
GlobalInstTracker * globalInstTracker
the pointer to the GlobalInstTracker object.
void stopListening()
stop listening to the ProbePoints
LocalInstTracker(const LocalInstTrackerParams &params)
void retiredInstsHandler(const uint64_t &inst)
this function is called when the ProbePoint "RetiredInsts" is notified
std::vector< ProbeListenerPtr<> > listeners
ProbeListenerObject(const ProbeListenerObjectParams &params)
void connectListener(Args &&...args)
const Params & params() const
SimObject(const Params &p)
Definition sim_object.cc:58
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
void exitSimLoopNow(const std::string &message, int exit_code, Tick repeat, bool serialize)
Schedule an event as above, but make it high priority so it runs before any normal events which are s...

Generated on Mon May 26 2025 09:19:08 for gem5 by doxygen 1.13.2