diff options
author | Sascha Bischoff <sascha.bischoff@arm.com> | 2012-09-25 11:49:41 -0500 |
---|---|---|
committer | Sascha Bischoff <sascha.bischoff@arm.com> | 2012-09-25 11:49:41 -0500 |
commit | 74ab69c7eafc2f0d187ce3ba7d6b9a59ba291b9f (patch) | |
tree | e5165b40b79f8cab3fbee6293b4a976f8ba44bc4 /src | |
parent | acbb7a2eed15258061e038254469197ae3831165 (diff) | |
download | gem5-74ab69c7eafc2f0d187ce3ba7d6b9a59ba291b9f.tar.xz |
Statistics: Add a function to configure periodic stats dumping
This patch adds a function, periodicStatDump(long long period), which will dump
and reset the statistics every period. This function is designed to be called
from the python configuration scripts. This allows the periodic stats dumping to
be configured more easilly at run time.
The period is currently specified as a long long as there are issues passing
Tick into the C++ from the python as they have conflicting definitions. If the
period is less than curTick, the first occurance occurs at curTick. If the
period is set to 0, then the event is descheduled and the stats are not
periodically dumped.
Due to issues when resumung from a checkpoint, the StatDump event must be moved
forward such that it occues AFTER the current tick. As the function is called
from the python, the event is scheduled before the system resumes from the
checkpoint. Therefore, the event is moved using the updateEvents() function.
This is called from simulate.py once the system has resumed from the checkpoint.
NOTE: It should be noted that this is a fairly temporary patch which re-adds the
capability to extract temporal information from the communication monitors. It
should not be used at the same time as anything that relies on dumping the
statistics based on in simulation events i.e. a context switch.
Diffstat (limited to 'src')
-rw-r--r-- | src/python/m5/simulate.py | 5 | ||||
-rw-r--r-- | src/python/swig/stats.i | 4 | ||||
-rw-r--r-- | src/sim/stat_control.cc | 68 | ||||
-rw-r--r-- | src/sim/stat_control.hh | 38 |
4 files changed, 113 insertions, 2 deletions
diff --git a/src/python/m5/simulate.py b/src/python/m5/simulate.py index e95136548..5fc00ad05 100644 --- a/src/python/m5/simulate.py +++ b/src/python/m5/simulate.py @@ -52,6 +52,7 @@ import SimObject import ticks import objects from m5.util.dot_writer import do_dot +from m5.internal.stats import updateEvents as updateStatEvents from util import fatal from util import attrdict @@ -123,6 +124,10 @@ def instantiate(ckpt_dir=None): else: for obj in root.descendants(): obj.initState() + # Check to see if any of the stat events are in the past after resuming from + # a checkpoint, If so, this call will shift them to be at a valid time. + updateStatEvents() + # Reset to put the stats in a consistent state. stats.reset() diff --git a/src/python/swig/stats.i b/src/python/swig/stats.i index 5a6910fa6..46395eb22 100644 --- a/src/python/swig/stats.i +++ b/src/python/swig/stats.i @@ -152,6 +152,10 @@ Output *initText(const std::string &filename, bool desc); void schedStatEvent(bool dump, bool reset, Tick when = curTick(), Tick repeat = 0); +void periodicStatDump(long long period = 0); + +void updateEvents(); + void processResetQueue(); void processDumpQueue(); void enable(); diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc index 965c081ee..2b47ded8d 100644 --- a/src/sim/stat_control.cc +++ b/src/sim/stat_control.cc @@ -1,4 +1,16 @@ /* + * Copyright (c) 2012 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. + * * Copyright (c) 2004-2005 The Regents of The University of Michigan * All rights reserved. * @@ -26,6 +38,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Nathan Binkert + * Sascha Bischoff */ // This file will contain default statistics for the simulator that @@ -61,6 +74,8 @@ namespace Stats { Time statTime(true); Tick startTick; +Event *dumpEvent; + struct SimTicksReset : public Callback { void process() @@ -198,6 +213,9 @@ initSimStats() static Global global; } +/** + * Event to dump and/or reset the statistics. + */ class StatEvent : public Event { private: @@ -230,8 +248,54 @@ class StatEvent : public Event void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat) { - Event *event = new StatEvent(dump, reset, repeat); - mainEventQueue.schedule(event, when); + dumpEvent = new StatEvent(dump, reset, repeat); + mainEventQueue.schedule(dumpEvent, when); +} + +void +periodicStatDump(uint64_t period) +{ + /* + * If the period is set to 0, then we do not want to dump periodically, + * thus we deschedule the event. Else, if the period is not 0, but the event + * has already been scheduled, we need to get rid of the old event before we + * create a new one, as the old event will no longer be moved forward in the + * event that we resume from a checkpoint. + */ + if (dumpEvent != NULL && (period == 0 || dumpEvent->scheduled())) { + // Event should AutoDelete, so we do not need to free it. + mainEventQueue.deschedule(dumpEvent); + } + + /* + * If the period is not 0, we schedule the event. If this is called with a + * period that is less than the current tick, then we shift the first dump + * by curTick. This ensures that we do not schedule the event is the past. + */ + if (period != 0) { + // Schedule the event + if (period >= curTick()) { + schedStatEvent(true, true, (Tick)period, (Tick)period); + } else { + schedStatEvent(true, true, (Tick)period + curTick(), (Tick)period); + } + } +} + +void +updateEvents() +{ + /* + * If the dumpEvent has been scheduled, but is scheduled in the past, then + * we need to shift the event to be at a valid point in time. Therefore, we + * shift the event by curTick. + */ + if (dumpEvent != NULL && + (dumpEvent->scheduled() && dumpEvent->when() < curTick())) { + // shift by curTick() and reschedule + Tick _when = dumpEvent->when(); + mainEventQueue.reschedule(dumpEvent, _when + curTick()); + } } } // namespace Stats diff --git a/src/sim/stat_control.hh b/src/sim/stat_control.hh index c41a9482a..9731d87cf 100644 --- a/src/sim/stat_control.hh +++ b/src/sim/stat_control.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2012 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. + * * Copyright (c) 2004-2005 The Regents of The University of Michigan * All rights reserved. * @@ -26,6 +38,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Nathan Binkert + * Sascha Bischoff */ #ifndef __SIM_STAT_CONTROL_HH__ @@ -34,9 +47,34 @@ namespace Stats { void initSimStats(); + +/** + * Update the events after resuming from a checkpoint. When resuming from a + * checkpoint, curTick will be updated, and any already scheduled events can + * end up scheduled in the past. This function checks if the dumpEvent is + * scheduled in the past, and reschedules it appropriately. + */ +void updateEvents(); + +/** + * Schedule statistics dumping. This allows you to dump and/or reset the + * built-in statistics. This can either be done once, or it can be done on a + * regular basis. + * @param dump Set true to dump the statistics. + * @param reset Set true to reset the statistics. + * @param when When the dump and/or reset should occur. + * @param repeat How often the event should repeat. Set 0 to disable repeating. + */ void schedStatEvent(bool dump, bool reset, Tick when = curTick(), Tick repeat = 0); +/** + * Schedule periodic statistics dumping. This allows you to dump and reset the + * built-in statistics on a regular basis, thereby allowing the extraction of + * temporal trends in the data. + * @param period The period at which the dumping should occur. + */ +void periodicStatDump(uint64_t period = 0); } // namespace Stats #endif // __SIM_STAT_CONTROL_HH__ |