gem5 v24.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
inst_tracker.hh
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
29#ifndef __CPU_PROBES_INST_TRACKER_HH__
30#define __CPU_PROBES_INST_TRACKER_HH__
31
32#include <unordered_set>
33
34#include "debug/InstTracker.hh"
35#include "params/GlobalInstTracker.hh"
36#include "params/LocalInstTracker.hh"
37#include "sim/probe/probe.hh"
38#include "sim/sim_exit.hh"
39
40namespace gem5
41{
42
44{
45 public:
46 LocalInstTracker(const LocalInstTrackerParams &params);
47
49 virtual void regProbeListeners();
50
56 void retiredInstsHandler(const uint64_t& inst);
57
58 private:
61
66
73
74 public:
76 void stopListening();
77
79 void
81 {
82 ifListening = true;
84 }
85
86};
87
89{
90 public:
91 GlobalInstTracker(const GlobalInstTrackerParams &params);
92
98 void updateAndCheckInstCount(const uint64_t& inst);
99
100 private:
103 uint64_t instCount;
104
109 std::unordered_set<uint64_t> instThresholdSet;
110
111 public:
112 void
113 addThreshold(uint64_t new_threshold)
114 {
115 instThresholdSet.insert(new_threshold);
116 DPRINTF(InstTracker, "adding the instruction threshold %lu\n",
117 new_threshold);
118 };
119
120 uint64_t
122 {
123 return instCount;
124 };
125
126 void
128 {
129 instCount = 0;
130 DPRINTF(InstTracker, "Resetting the instruction counter\n"
131 "instCount = %lu\n", instCount);
132 };
133
134 std::unordered_set<uint64_t>
136 {
137 return instThresholdSet;
138 };
139
140 void
142 {
143 instThresholdSet.clear();
144 DPRINTF(InstTracker, "Resetting the instruction thresholds\n");
145 };
146};
147
148}
149
150#endif // __CPU_PROBES_INST_TRACKER_HH__
#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...
void addThreshold(uint64_t new_threshold)
uint64_t instCount
the number of instructions that have been executed across all the cores
uint64_t getCounter() const
std::unordered_set< uint64_t > getThresholds() const
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
ProbeListenerArg< LocalInstTracker, uint64_t > LocalInstTrackerListener
void retiredInstsHandler(const uint64_t &inst)
this function is called when the ProbePoint "RetiredInsts" is notified
void startListening()
start listening to the ProbePoints
ProbeListenerArg generates a listener for the class of Arg and the class type T which is the class co...
Definition probe.hh:229
This class is a minimal wrapper around SimObject.
Definition probe.hh:108
Abstract superclass for simulation objects.
const Params & params() const
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36

Generated on Mon Jan 13 2025 04:28:32 for gem5 by doxygen 1.9.8