Source('mathexpr.cc')
Source('power_state.cc')
Source('power_domain.cc')
+Source('stats.cc')
GTest('byteswap.test', 'byteswap.test.cc', '../base/types.cc')
GTest('guest_abi.test', 'guest_abi.test.cc')
/*
+ * Copyright (c) 2020 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) 2002-2005 The Regents of The University of Michigan
* Copyright (c) 2011 Advanced Micro Devices, Inc.
* All rights reserved.
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "base/hostinfo.hh"
#include "base/logging.hh"
#include "base/trace.hh"
#include "config/the_isa.hh"
#include "sim/root.hh"
Root *Root::_root = NULL;
+Root::Stats Root::Stats::instance;
+Root::Stats &rootStats = Root::Stats::instance;
+
+Root::Stats::Stats()
+ : Stats::Group(nullptr),
+ simSeconds(this, "sim_seconds", "Number of seconds simulated"),
+ simTicks(this, "sim_ticks", "Number of ticks simulated"),
+ finalTick(this, "final_tick",
+ "Number of ticks from beginning of simulation "
+ "(restored from checkpoints and never reset)"),
+ simFreq(this, "sim_freq", "Frequency of simulated ticks"),
+ hostSeconds(this, "host_seconds", "Real time elapsed on the host"),
+ hostTickRate(this, "host_tick_rate", "Simulator tick rate (ticks/s)"),
+ hostMemory(this, "host_mem_usage", "Number of bytes of host memory used"),
+
+ statTime(true),
+ startTick(0)
+{
+ simFreq.scalar(SimClock::Frequency);
+ simTicks.functor([this]() { return curTick() - startTick; });
+ finalTick.functor(curTick);
+
+ hostMemory
+ .functor(memUsage)
+ .prereq(hostMemory)
+ ;
+
+ hostSeconds
+ .functor([this]() {
+ Time now;
+ now.setTimer();
+ return now - statTime;
+ })
+ .precision(2)
+ ;
+
+ hostTickRate.precision(0);
+
+ simSeconds = simTicks / simFreq;
+ hostTickRate = simTicks / hostSeconds;
+}
+
+void
+Root::Stats::resetStats()
+{
+ statTime.setTimer();
+ startTick = curTick();
+
+ Stats::Group::resetStats();
+}
/*
* This function is called periodically by an event in M5 and ensures that
lastTime.setTimer();
simQuantum = p->sim_quantum;
+
+ // Some of the statistics are global and need to be accessed by
+ // stat formulas. The most convenient way to implement that is by
+ // having a single global stat group for global stats. Merge that
+ // group into the root object here.
+ mergeStatGroup(&Root::Stats::instance);
}
void
/*
+ * Copyright (c) 2020 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) 2011 Advanced Micro Devices, Inc.
* All rights reserved.
*
#ifndef __SIM_ROOT_HH__
#define __SIM_ROOT_HH__
+#include "base/statistics.hh"
#include "base/time.hh"
#include "params/Root.hh"
#include "sim/eventq.hh"
return _root;
}
+ public: // Global statistics
+ struct Stats : public ::Stats::Group
+ {
+ void resetStats() override;
+
+ ::Stats::Formula simSeconds;
+ ::Stats::Value simTicks;
+ ::Stats::Value finalTick;
+ ::Stats::Value simFreq;
+ ::Stats::Value hostSeconds;
+
+ ::Stats::Formula hostTickRate;
+ ::Stats::Value hostMemory;
+
+ static Stats instance;
+
+ private:
+ Stats();
+
+ Stats(const Stats &) = delete;
+ Stats &operator=(const Stats &) = delete;
+
+ Time statTime;
+ Tick startTick;
+ };
+
public:
/// Check whether time syncing is enabled.
void serialize(CheckpointOut &cp) const override;
};
+/**
+ * Global simulator statistics that are not associated with a
+ * specific SimObject.
+ */
+extern Root::Stats &rootStats;
+
#endif // __SIM_ROOT_HH__
#include <list>
#include "base/callback.hh"
-#include "base/hostinfo.hh"
#include "base/statistics.hh"
#include "base/time.hh"
#include "sim/global_event.hh"
using namespace std;
-Stats::Formula simSeconds;
-Stats::Value simTicks;
-Stats::Value finalTick;
-Stats::Value simFreq;
-Stats::Value hostSeconds;
-
namespace Stats {
-Time statTime(true);
-Tick startTick;
-
GlobalEvent *dumpEvent;
-double
-statElapsedTime()
-{
- Time now;
- now.setTimer();
-
- Time elapsed = now - statTime;
- return elapsed;
-}
-
-Tick
-statElapsedTicks()
-{
- return curTick() - startTick;
-}
-
-Tick
-statFinalTick()
-{
- return curTick();
-}
-
-struct Global
-{
- Stats::Formula hostTickRate;
- Stats::Value hostMemory;
-
- Global();
-};
-
-Global::Global()
-{
- simSeconds
- .name("sim_seconds")
- .desc("Number of seconds simulated")
- ;
-
- simFreq
- .scalar(SimClock::Frequency)
- .name("sim_freq")
- .desc("Frequency of simulated ticks")
- ;
-
- simTicks
- .functor(statElapsedTicks)
- .name("sim_ticks")
- .desc("Number of ticks simulated")
- ;
-
- finalTick
- .functor(statFinalTick)
- .name("final_tick")
- .desc("Number of ticks from beginning of simulation "
- "(restored from checkpoints and never reset)")
- ;
-
- hostMemory
- .functor(memUsage)
- .name("host_mem_usage")
- .desc("Number of bytes of host memory used")
- .prereq(hostMemory)
- ;
-
- hostSeconds
- .functor(statElapsedTime)
- .name("host_seconds")
- .desc("Real time elapsed on the host")
- .precision(2)
- ;
-
- hostTickRate
- .name("host_tick_rate")
- .desc("Simulator tick rate (ticks/s)")
- .precision(0)
- ;
-
- simSeconds = simTicks / simFreq;
- hostTickRate = simTicks / hostSeconds;
-
- registerResetCallback([]() {
- statTime.setTimer();
- startTick = curTick();
- });
-}
-
void
initSimStats()
{
- static Global global;
}
/**
namespace Stats {
-double statElapsedTime();
-
-Tick statElapsedTicks();
-
-Tick statFinalTick();
void initSimStats();
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ *
+ * 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 "sim/stats.hh"
+
+#include "sim/root.hh"
+
+Stats::Formula &simSeconds = rootStats.simSeconds;
+Stats::Value &simTicks = rootStats.simTicks;
+Stats::Value &simFreq = rootStats.simFreq;
+Stats::Value &hostSeconds = rootStats.hostSeconds;
#include "base/statistics.hh"
-extern Stats::Formula simSeconds;
-extern Stats::Value simTicks;
-extern Stats::Value simFreq;
-extern Stats::Value hostSeconds;
+extern Stats::Formula &simSeconds;
+extern Stats::Value &simTicks;
+extern Stats::Value &simFreq;
+extern Stats::Value &hostSeconds;
#endif // __SIM_SIM_STATS_HH__