gem5 v24.0.0.0
Loading...
Searching...
No Matches
stat_control.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2004-2005 The Regents of The University of Michigan
15 * Copyright (c) 2013 Advanced Micro Devices, Inc.
16 * Copyright (c) 2013 Mark D. Hill and David A. Wood
17 * All rights reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are
21 * met: redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer;
23 * redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution;
26 * neither the name of the copyright holders nor the names of its
27 * contributors may be used to endorse or promote products derived from
28 * this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42
43// This file will contain default statistics for the simulator that
44// don't really belong to a specific simulator object
45
46#include "sim/stat_control.hh"
47
48#include <fstream>
49#include <iostream>
50#include <list>
51
52#include "base/callback.hh"
53#include "base/statistics.hh"
54#include "base/time.hh"
55#include "sim/global_event.hh"
56
57namespace gem5
58{
59
60namespace statistics
61{
62
64
65void
67{
68}
69
73class StatEvent : public GlobalEvent
74{
75 private:
76 bool dump;
77 bool reset;
79
80 public:
81 StatEvent(Tick _when, bool _dump, bool _reset, Tick _repeat)
82 : GlobalEvent(_when, Stat_Event_Pri, 0),
83 dump(_dump), reset(_reset), repeat(_repeat)
84 {
85 }
86
87 virtual void
89 {
90 if (dump)
92
93 if (reset)
95
96 if (repeat) {
98 repeat);
99 }
100 }
101
102 const char *description() const { return "GlobalStatEvent"; }
103};
104
105void
106schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
107{
108 // simQuantum is being added to the time when the stats would be
109 // dumped so as to ensure that this event happens only after the next
110 // sync amongst the event queues. Asingle event queue simulation
111 // should remain unaffected.
112 dumpEvent = new StatEvent(when + simQuantum, dump, reset, repeat);
113}
114
115void
117{
118 /*
119 * If the period is set to 0, then we do not want to dump periodically,
120 * thus we deschedule the event. Else, if the period is not 0, but the
121 * event has already been scheduled, we need to get rid of the old event
122 * before we create a new one, as the old event will no longer be moved
123 * forward in the event that we resume from a checkpoint.
124 */
125 if (dumpEvent != NULL && (period == 0 || dumpEvent->scheduled())) {
126 // Event should AutoDelete, so we do not need to free it.
128 }
129
130 /*
131 * If the period is not 0, we schedule the event. If this is called with a
132 * period that is less than the current tick, then we shift the first dump
133 * by curTick. This ensures that we do not schedule the event is the past.
134 */
135 if (period != 0) {
136 // Schedule the event
137 if (period >= curTick()) {
138 schedStatEvent(true, true, (Tick)period, (Tick)period);
139 } else {
140 schedStatEvent(true, true, (Tick)period + curTick(), (Tick)period);
141 }
142 }
143}
144
145void
147{
148 /*
149 * If the dumpEvent has been scheduled, but is scheduled in the past, then
150 * we need to shift the event to be at a valid point in time. Therefore, we
151 * shift the event by curTick.
152 */
153 if (dumpEvent != NULL &&
154 (dumpEvent->scheduled() && dumpEvent->when() < curTick())) {
155 // shift by curTick() and reschedule
156 Tick _when = dumpEvent->when();
157 dumpEvent->reschedule(_when + curTick());
158 }
159}
160
161} // namespace statistics
162} // namespace gem5
void reschedule(Tick when)
The main global event class.
Event to dump and/or reset the statistics.
StatEvent(Tick _when, bool _dump, bool _reset, Tick _repeat)
const char * description() const
Global events and related declarations.
static const Priority Stat_Event_Pri
Statistics events (dump, reset, etc.) come after everything else, but before exit.
Definition eventq.hh:222
GlobalEvent * dumpEvent
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
void periodicStatDump(Tick period)
Schedule periodic statistics dumping.
void updateEvents()
Update the events after resuming from a checkpoint.
void dump()
Dump all statistics data to the registered outputs.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick simQuantum
Simulation Quantum for multiple eventq simulation.
Definition eventq.cc:48
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of Statistics objects.

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0