summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SConscript3
-rw-r--r--src/base/statistics.hh1
-rw-r--r--src/base/stats/events.cc2
-rw-r--r--src/base/stats/events.hh2
-rw-r--r--src/base/stats/mysql.cc70
-rw-r--r--src/base/stats/mysql.hh31
-rw-r--r--src/base/stats/output.cc70
-rw-r--r--src/base/stats/text.cc21
-rw-r--r--src/base/stats/text.hh3
-rw-r--r--src/base/trace.cc2
-rw-r--r--src/base/traceflags.py2
-rw-r--r--src/cpu/base.cc2
-rw-r--r--src/cpu/exetrace.hh3
-rw-r--r--src/python/SConscript1
-rw-r--r--src/python/m5/SimObject.py18
-rw-r--r--src/python/m5/main.py11
-rw-r--r--src/python/m5/objects/Root.py7
-rw-r--r--src/python/swig/pyevent.cc9
-rw-r--r--src/python/swig/stats.i60
-rw-r--r--src/sim/async.hh1
-rw-r--r--src/sim/builder.cc2
-rw-r--r--src/sim/eventq.hh3
-rw-r--r--src/sim/main.cc29
-rw-r--r--src/sim/param.cc109
-rw-r--r--src/sim/param.hh47
-rw-r--r--src/sim/pseudo_inst.cc10
-rw-r--r--src/sim/serialize.cc33
-rw-r--r--src/sim/sim_object.cc9
-rw-r--r--src/sim/sim_object.hh1
-rw-r--r--src/sim/stat_control.cc96
-rw-r--r--src/sim/stat_control.hh19
31 files changed, 313 insertions, 364 deletions
diff --git a/src/SConscript b/src/SConscript
index d6b4c6c8d..c93605ff7 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -79,6 +79,7 @@ base_sources = Split('''
base/loader/object_file.cc
base/loader/symtab.cc
base/stats/events.cc
+ base/stats/output.cc
base/stats/statdb.cc
base/stats/visit.cc
base/stats/text.cc
@@ -134,6 +135,7 @@ base_sources = Split('''
python/swig/main_wrap.cc
python/swig/event_wrap.cc
python/swig/random_wrap.cc
+ python/swig/stats_wrap.cc
python/swig/trace_wrap.cc
python/swig/pyevent.cc
@@ -148,7 +150,6 @@ base_sources = Split('''
sim/sim_events.cc
sim/sim_object.cc
sim/startup.cc
- sim/stat_context.cc
sim/stat_control.cc
sim/system.cc
''')
diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 2b1b327e5..8168473a1 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -2839,6 +2839,7 @@ class Temp
*/
void check();
+void dump();
void reset();
void registerResetCallback(Callback *cb);
diff --git a/src/base/stats/events.cc b/src/base/stats/events.cc
index 6ecc5434c..fa746eab8 100644
--- a/src/base/stats/events.cc
+++ b/src/base/stats/events.cc
@@ -52,8 +52,6 @@ namespace Stats {
Tick EventStart = ULL(0x7fffffffffffffff);
-ObjectMatch event_ignore;
-
#if USE_MYSQL
class InsertEvent
{
diff --git a/src/base/stats/events.hh b/src/base/stats/events.hh
index b09b91c7c..dc1408f5b 100644
--- a/src/base/stats/events.hh
+++ b/src/base/stats/events.hh
@@ -45,8 +45,6 @@ void __event(const std::string &stat);
bool MySqlConnected();
#endif
-bool ignoreEvent(const std::string &name);
-
inline void
recordEvent(const std::string &stat)
{
diff --git a/src/base/stats/mysql.cc b/src/base/stats/mysql.cc
index 0fb31f4ce..01a82c4bf 100644
--- a/src/base/stats/mysql.cc
+++ b/src/base/stats/mysql.cc
@@ -49,14 +49,6 @@ using namespace std;
namespace Stats {
-MySqlRun MySqlDB;
-
-bool
-MySqlConnected()
-{
- return MySqlDB.connected();
-}
-
void
MySqlRun::connect(const string &host, const string &user, const string &passwd,
const string &db, const string &name, const string &sample,
@@ -198,7 +190,7 @@ SetupStat::init()
unsigned
SetupStat::setup()
{
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
stringstream insert;
ccprintf(insert,
@@ -317,7 +309,7 @@ void
InsertData::flush()
{
if (size) {
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
assert(mysql.connected());
mysql.query(query);
if (mysql.error)
@@ -349,7 +341,7 @@ InsertData::insert()
first = false;
size += sprintf(query + size, "(%u,%d,%d,%u,%llu,\"%f\")",
- stat, x, y, MySqlDB.run(), (unsigned long long)tick,
+ stat, x, y, run->run(), (unsigned long long)tick,
data);
}
@@ -367,7 +359,7 @@ struct InsertSubData
void
InsertSubData::setup()
{
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
assert(mysql.connected());
stringstream insert;
ccprintf(insert,
@@ -386,7 +378,7 @@ InsertSubData::setup()
void
InsertFormula(uint16_t stat, const string &formula)
{
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
assert(mysql.connected());
stringstream insert_formula;
ccprintf(insert_formula,
@@ -400,7 +392,7 @@ InsertFormula(uint16_t stat, const string &formula)
stringstream insert_ref;
ccprintf(insert_ref,
"INSERT INTO formula_ref(fr_stat,fr_run) values(%d, %d)",
- stat, MySqlDB.run());
+ stat, run->run());
mysql.query(insert_ref);
// if (mysql.error)
@@ -413,7 +405,7 @@ InsertFormula(uint16_t stat, const string &formula)
void
UpdatePrereq(uint16_t stat, uint16_t prereq)
{
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
assert(mysql.connected());
stringstream update;
ccprintf(update, "UPDATE stats SET st_prereq=%d WHERE st_id=%d",
@@ -426,6 +418,29 @@ UpdatePrereq(uint16_t stat, uint16_t prereq)
panic("could not commit transaction\n%s\n", mysql.error);
}
+MySql::MySql()
+ : run(new MySqlRun)
+{}
+
+MySql::~MySql()
+{
+ delete run;
+}
+
+void
+MySql::connect(const string &host, const string &user, const string &passwd,
+ const string &db, const string &name, const string &sample,
+ const string &project)
+{
+ run->connect(host, user, passwd, db, name, sample, project);
+}
+
+bool
+MySql::connected() const
+{
+ run->connected();
+}
+
void
MySql::configure()
{
@@ -434,7 +449,7 @@ MySql::configure()
*/
using namespace Database;
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
stat_list_t::const_iterator i, end = stats().end();
for (i = stats().begin(); i != end; ++i) {
@@ -605,7 +620,7 @@ MySql::configure(const FormulaData &data)
bool
MySql::valid() const
{
- return MySqlDB.connected();
+ return run->connected();
}
void
@@ -620,7 +635,7 @@ MySql::output()
// store sample #
newdata.tick = curTick;
- MySQL::Connection &mysql = MySqlDB.conn();
+ MySQL::Connection &mysql = run->conn();
Database::stat_list_t::const_iterator i, end = Database::stats().end();
for (i = Database::stats().begin(); i != end; ++i) {
@@ -825,4 +840,21 @@ MySql::visit(const FormulaData &data)
output(data);
}
-/* namespace Stats */ }
+bool
+initMySQL(string host, string user, string password, string database,
+ string name, string sample, string project)
+{
+ extern list<Output *> OutputList;
+ static MySql mysql;
+
+ if (mysql.connected())
+ return false;
+
+ if (user.empty())
+ user = username();
+
+ mysql.connect(host, user, password, database, name, sample, project);
+ OutputList.push_back(&mysql);
+
+ return true;
+}
diff --git a/src/base/stats/mysql.hh b/src/base/stats/mysql.hh
index 50f7d9e97..a43c74ecc 100644
--- a/src/base/stats/mysql.hh
+++ b/src/base/stats/mysql.hh
@@ -35,14 +35,13 @@
#include <string>
#include "base/stats/output.hh"
+#include "config/use_mysql.hh"
namespace MySQL { class Connection; }
namespace Stats {
class DistDataData;
class MySqlRun;
-bool MySqlConnected();
-extern MySqlRun MySqlDB;
struct SetupStat
{
@@ -95,6 +94,9 @@ class InsertData
class MySql : public Output
{
protected:
+ MySqlRun *run; /* Hide the implementation so we don't have a
+ #include mess */
+
SetupStat stat;
InsertData newdata;
std::list<FormulaData *> formulas;
@@ -116,6 +118,17 @@ class MySql : public Output
assert(i != idmap.end());
return (*i).second;
}
+
+ public:
+ MySql(MySqlRun &_run){}
+ ~MySql();
+
+ void connect(const std::string &host, const std::string &user,
+ const std::string &passwd, const std::string &db,
+ const std::string &name, const std::string &sample,
+ const std::string &project);
+ bool connected() const;
+
public:
// Implement Visit
virtual void visit(const ScalarData &data);
@@ -149,6 +162,20 @@ class MySql : public Output
void configure(const FormulaData &data);
};
+bool initMySQL(std::string host, std::string database, std::string user = "",
+ std::string passwd = "", std::string name = "test",
+ std::string sample = "0", std::string project = "test");
+
+#if !USE_MYSQL
+inline bool
+initMySQL(std::string host, std::string user, std::string password,
+ std::string database, std::string name, std::string sample,
+ std::string project)
+{
+ return false;
+}
+#endif
+
/* namespace Stats */ }
#endif // __BASE_STATS_MYSQL_HH__
diff --git a/src/base/stats/output.cc b/src/base/stats/output.cc
new file mode 100644
index 000000000..9f2b91c77
--- /dev/null
+++ b/src/base/stats/output.cc
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004-2005 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * Authors: Nathan Binkert
+ */
+
+#include <list>
+
+#include "base/stats/output.hh"
+#include "sim/eventq.hh"
+#include "sim/host.hh"
+
+using namespace std;
+
+namespace Stats {
+
+Tick lastDump(0);
+list<Output *> OutputList;
+
+void
+dump()
+{
+ assert(lastDump <= curTick);
+ if (lastDump == curTick)
+ return;
+ lastDump = curTick;
+
+ list<Output *>::iterator i = OutputList.begin();
+ list<Output *>::iterator end = OutputList.end();
+ for (; i != end; ++i) {
+ Output *output = *i;
+ if (!output->valid())
+ continue;
+
+ output->output();
+ }
+}
+
+/* namespace Stats */ }
+
+void
+debugDumpStats()
+{
+ Stats::dump();
+}
+
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc
index ae0d65537..66c5955d7 100644
--- a/src/base/stats/text.cc
+++ b/src/base/stats/text.cc
@@ -725,4 +725,25 @@ Text::visit(const FormulaData &data)
visit((const VectorData &)data);
}
+bool
+initText(const string &filename, bool desc, bool compat)
+{
+ static Text text;
+ static bool connected = false;
+
+ if (connected)
+ return false;
+
+ extern list<Output *> OutputList;
+
+ text.open(*simout.find(filename));
+ text.descriptions = desc;
+ text.compat = compat;
+ OutputList.push_back(&text);
+ connected = true;
+
+ return true;
+}
+
+
/* namespace Stats */ }
diff --git a/src/base/stats/text.hh b/src/base/stats/text.hh
index b3faf5ad5..0516bc60d 100644
--- a/src/base/stats/text.hh
+++ b/src/base/stats/text.hh
@@ -34,6 +34,7 @@
#include <iosfwd>
#include <string>
+#include "base/output.hh"
#include "base/stats/output.hh"
namespace Stats {
@@ -73,6 +74,8 @@ class Text : public Output
virtual void output();
};
+bool initText(const std::string &filename, bool desc=true, bool compat=true);
+
/* namespace Stats */ }
#endif // __BASE_STATS_TEXT_HH__
diff --git a/src/base/trace.cc b/src/base/trace.cc
index 7afb038be..2dde1f688 100644
--- a/src/base/trace.cc
+++ b/src/base/trace.cc
@@ -47,7 +47,7 @@ using namespace std;
namespace Trace {
const string DefaultName("global");
FlagVec flags(NumFlags, false);
-bool enabled = true;
+bool enabled = false;
//
// This variable holds the output stream for debug information. Other
diff --git a/src/base/traceflags.py b/src/base/traceflags.py
index 897bf0023..ba6aa6af8 100644
--- a/src/base/traceflags.py
+++ b/src/base/traceflags.py
@@ -253,7 +253,7 @@ def gen_hh(filename):
print >>hhfile, '''
// The remaining enum values are *not* valid indices for Trace::flags.
// They are "compound" flags, which correspond to sets of base
- // flags, and are used only by TraceParamContext::setFlags().
+ // flags, and are used by changeFlag.
''',
for flag in compoundFlags:
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 8440d2320..d5a023c59 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -63,7 +63,7 @@ int maxThreadsPerCPU = 1;
CPUProgressEvent::CPUProgressEvent(EventQueue *q, Tick ival,
BaseCPU *_cpu)
- : Event(q, Event::Stat_Event_Pri), interval(ival),
+ : Event(q, Event::Progress_Event_Pri), interval(ival),
lastNumInst(0), cpu(_cpu)
{
if (interval)
diff --git a/src/cpu/exetrace.hh b/src/cpu/exetrace.hh
index be10b4a6a..0f642c08e 100644
--- a/src/cpu/exetrace.hh
+++ b/src/cpu/exetrace.hh
@@ -157,6 +157,9 @@ getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst,
if (!IsOn(ExecEnable))
return NULL;
+ if (!Trace::enabled)
+ return NULL;
+
if (!IsOn(ExecSpeculative) && tc->misspeculating())
return NULL;
diff --git a/src/python/SConscript b/src/python/SConscript
index 51271650f..4dd614cfb 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -110,6 +110,7 @@ swig_it('main')
swig_it('debug')
swig_it('event')
swig_it('random')
+swig_it('stats')
swig_it('trace')
# Action function to build the zip archive. Uses the PyZipFile module
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index 934358298..ba79d3729 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -653,15 +653,13 @@ class SimObject(object):
instanceDict[self.path()] = self
- if hasattr(self, 'type') and not isinstance(self, ParamContext):
+ if hasattr(self, 'type'):
print 'type=%s' % self.type
child_names = self._children.keys()
child_names.sort()
- np_child_names = [c for c in child_names \
- if not isinstance(self._children[c], ParamContext)]
- if len(np_child_names):
- print 'children=%s' % ' '.join(np_child_names)
+ if len(child_names):
+ print 'children=%s' % ' '.join(child_names)
param_names = self._params.keys()
param_names.sort()
@@ -711,8 +709,7 @@ class SimObject(object):
def startDrain(self, drain_event, recursive):
count = 0
- # ParamContexts don't serialize
- if isinstance(self, SimObject) and not isinstance(self, ParamContext):
+ if isinstance(self, SimObject):
count += self._ccObject.drain(drain_event)
if recursive:
for child in self._children.itervalues():
@@ -720,7 +717,7 @@ class SimObject(object):
return count
def resume(self):
- if isinstance(self, SimObject) and not isinstance(self, ParamContext):
+ if isinstance(self, SimObject):
self._ccObject.resume()
for child in self._children.itervalues():
child.resume()
@@ -782,9 +779,6 @@ class SimObject(object):
for c in self.children:
c.outputDot(dot)
-class ParamContext(SimObject):
- pass
-
# Function to provide to C++ so it can look up instances based on paths
def resolveSimObject(name):
obj = instanceDict[name]
@@ -793,7 +787,7 @@ def resolveSimObject(name):
# __all__ defines the list of symbols that get exported when
# 'from config import *' is invoked. Try to keep this reasonably
# short to avoid polluting other namespaces.
-__all__ = ['SimObject', 'ParamContext']
+__all__ = ['SimObject']
# see comment on imports at end of __init__.py.
import proxy
diff --git a/src/python/m5/main.py b/src/python/m5/main.py
index 25b52e830..48c75434f 100644
--- a/src/python/m5/main.py
+++ b/src/python/m5/main.py
@@ -264,7 +264,7 @@ def main():
import objects
# set stats options
- objects.Statistics.text_file = options.stats_file
+ internal.stats.initText(options.stats_file)
# set debugging options
for when in options.debug_break:
@@ -292,11 +292,12 @@ def main():
for flag in off_flags:
internal.trace.clear(flag)
- if options.trace_start is not None:
- internal.trace.enabled = False
+ if options.trace_start:
def enable_trace():
- internal.event.enabled = True
- internal.event.create(enable_trace, options.trace_start)
+ internal.trace.cvar.enabled = True
+ internal.event.create(enable_trace, int(options.trace_start))
+ else:
+ internal.trace.enabled = True
internal.trace.output(options.trace_file)
diff --git a/src/python/m5/objects/Root.py b/src/python/m5/objects/Root.py
index c78ae6ccb..8db4fa5a2 100644
--- a/src/python/m5/objects/Root.py
+++ b/src/python/m5/objects/Root.py
@@ -1,8 +1,5 @@
from m5.SimObject import SimObject
from m5.params import *
-from Serialize import Serialize
-from Serialize import Statreset
-from Statistics import Statistics
class Root(SimObject):
type = 'Root'
@@ -12,7 +9,3 @@ class Root(SimObject):
"print a progress message every n ticks (0 = never)")
output_file = Param.String('cout', "file to dump simulator output to")
checkpoint = Param.String('', "checkpoint file to load")
-# stats = Param.Statistics(Statistics(), "statistics object")
-# serialize = Param.Serialize(Serialize(), "checkpoint generation options")
- stats = Statistics()
- serialize = Serialize()
diff --git a/src/python/swig/pyevent.cc b/src/python/swig/pyevent.cc
index 6fb7d3f17..7f23b8874 100644
--- a/src/python/swig/pyevent.cc
+++ b/src/python/swig/pyevent.cc
@@ -31,6 +31,7 @@
#include <Python.h>
#include "python/swig/pyevent.hh"
+#include "sim/async.hh"
PythonEvent::PythonEvent(PyObject *obj, Tick when, Priority priority)
: Event(&mainEventQueue, priority), object(obj)
@@ -52,9 +53,9 @@ PythonEvent::~PythonEvent()
void
PythonEvent::process()
{
- PyObject *result;
-
- result = PyObject_CallMethod(object, "process", "");
+ PyObject *args = PyTuple_New(0);
+ PyObject *result = PyObject_Call(object, args, NULL);
+ Py_DECREF(args);
if (result) {
// Nothing to do just decrement the reference count
@@ -62,5 +63,7 @@ PythonEvent::process()
} else {
// Somethign should be done to signal back to the main interpreter
// that there's been an exception.
+ async_event = true;
+ async_exception = true;
}
}
diff --git a/src/python/swig/stats.i b/src/python/swig/stats.i
new file mode 100644
index 000000000..d6b39c2cb
--- /dev/null
+++ b/src/python/swig/stats.i
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2006 The Regents of The University of Michigan
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * Authors: Nathan Binkert
+ */
+
+%module stats
+
+%include "std_string.i"
+
+%{
+#include "base/statistics.hh"
+#include "base/stats/mysql.hh"
+#include "base/stats/text.hh"
+#include "sim/stat_control.hh"
+%}
+
+namespace Stats {
+void initSimStats();
+void initText(const std::string &filename, bool desc=true, bool compat=true);
+void initMySQL(std::string host, std::string database, std::string user = "",
+ std::string passwd = "", std::string name = "test",
+ std::string sample = "0", std::string project = "test");
+
+void StatEvent(bool dump, bool reset, Tick when = curTick, Tick repeat = 0);
+
+void dump();
+void reset();
+
+/* namespace Stat */ }
+
+%wrapper %{
+// fix up module name to reflect the fact that it's inside the m5 package
+#undef SWIG_name
+#define SWIG_name "m5.internal._stats"
+%}
diff --git a/src/sim/async.hh b/src/sim/async.hh
index 50ae73040..6ee5eb46a 100644
--- a/src/sim/async.hh
+++ b/src/sim/async.hh
@@ -47,6 +47,7 @@ extern volatile bool async_dump; ///< Async request to dump stats.
extern volatile bool async_exit; ///< Async request to exit simulator.
extern volatile bool async_io; ///< Async I/O request (SIGIO).
extern volatile bool async_alarm; ///< Async alarm event (SIGALRM).
+extern volatile bool async_exception; ///< Python exception.
//@}
#endif // __ASYNC_HH__
diff --git a/src/sim/builder.cc b/src/sim/builder.cc
index 9074cc899..8ef54ce52 100644
--- a/src/sim/builder.cc
+++ b/src/sim/builder.cc
@@ -40,7 +40,7 @@
using namespace std;
SimObjectBuilder::SimObjectBuilder(const std::string &_iniSection)
- : ParamContext(_iniSection, NoAutoInit)
+ : ParamContext(_iniSection)
{
}
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 1aeb26e25..a57e9077e 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -169,6 +169,9 @@ class Event : public Serializable, public FastAlloc
/// everything else, but before exit.
Stat_Event_Pri = 90,
+ /// Progress events come at the end.
+ Progress_Event_Pri = 95,
+
/// If we want to exit on this cycle, it's the very last thing
/// we do.
Sim_Exit_Pri = 100
diff --git a/src/sim/main.cc b/src/sim/main.cc
index 9f9a56450..8e47ac6a0 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -53,6 +53,7 @@
#include "base/output.hh"
#include "base/pollevent.hh"
#include "base/statistics.hh"
+#include "base/stats/output.hh"
#include "base/str.hh"
#include "base/time.hh"
#include "config/pythonhome.hh"
@@ -82,6 +83,7 @@ volatile bool async_dumpreset = false;
volatile bool async_exit = false;
volatile bool async_io = false;
volatile bool async_alarm = false;
+volatile bool async_exception = false;
/// Stats signal handler.
void
@@ -219,7 +221,7 @@ loadIniFile(PyObject *_resolveFunc)
inifile.load(simout.resolve("config.ini"));
// Initialize statistics database
- Stats::InitSimStats();
+ Stats::initSimStats();
}
@@ -270,13 +272,6 @@ connectPorts(SimObject *o1, const std::string &name1, int i1,
void
finalInit()
{
- // Parse and check all non-config-hierarchy parameters.
- ParamContext::parseAllContexts(inifile);
- ParamContext::checkAllContexts();
-
- // Echo all parameter settings to stats file as well.
- ParamContext::showAllContexts(*configStream);
-
// Do a second pass to finish initializing the sim objects
SimObject::initAll();
@@ -296,7 +291,6 @@ finalInit()
SimStartup();
}
-
/** Simulate for num_cycles additional cycles. If num_cycles is -1
* (the default), do not limit simulation; some other event must
* terminate the loop. Exported to Python via SWIG.
@@ -349,16 +343,12 @@ simulate(Tick num_cycles = MaxTick)
async_event = false;
if (async_dump) {
async_dump = false;
-
- using namespace Stats;
- SetupEvent(Dump, curTick);
+ Stats::StatEvent(true, false);
}
if (async_dumpreset) {
async_dumpreset = false;
-
- using namespace Stats;
- SetupEvent(Dump | Reset, curTick);
+ Stats::StatEvent(true, true);
}
if (async_exit) {
@@ -371,6 +361,11 @@ simulate(Tick num_cycles = MaxTick)
async_alarm = false;
pollQueue.service();
}
+
+ if (async_exception) {
+ async_exception = false;
+ return NULL;
+ }
}
}
@@ -460,8 +455,6 @@ doExitCleanup()
cout.flush();
- ParamContext::cleanupAllContexts();
-
// print simulation stats
- Stats::DumpNow();
+ Stats::dump();
}
diff --git a/src/sim/param.cc b/src/sim/param.cc
index 5cc69b161..51d389f5a 100644
--- a/src/sim/param.cc
+++ b/src/sim/param.cc
@@ -583,30 +583,10 @@ SimObjectBaseParam::parse(const string &s, vector<SimObject *>&value)
//
////////////////////////////////////////////////////////////////////////
-list<ParamContext *> *ParamContext::ctxList = NULL;
-
-ParamContext::ParamContext(const string &_iniSection, InitPhase _initPhase)
+ParamContext::ParamContext(const string &_iniSection)
: iniFilePtr(NULL), // initialized on call to parseParams()
- iniSection(_iniSection), paramList(NULL),
- initPhase(_initPhase)
-{
- // Put this context on global list for initialization
- if (initPhase != NoAutoInit) {
- if (ctxList == NULL)
- ctxList = new list<ParamContext *>();
-
- // keep list sorted by ascending initPhase values
- list<ParamContext *>::iterator i = ctxList->begin();
- list<ParamContext *>::iterator end = ctxList->end();
- for (; i != end; ++i) {
- if (initPhase <= (*i)->initPhase) {
- // found where we want to insert
- break;
- }
- }
- // (fall through case: insert at end)
- ctxList->insert(i, this);
- }
+ iniSection(_iniSection), paramList(NULL)
+{
}
@@ -695,89 +675,6 @@ ParamContext::printErrorProlog(ostream &os)
os << "Parameter error in section [" << iniSection << "]: " << endl;
}
-//
-// static method: call parseParams() on all registered contexts
-//
-void
-ParamContext::parseAllContexts(IniFile &iniFile)
-{
- list<ParamContext *>::iterator iter;
-
- for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
- ParamContext *pc = *iter;
-
- pc->parseParams(iniFile);
- }
-}
-
-
-//
-// static method: call checkParams() on all registered contexts
-//
-void
-ParamContext::checkAllContexts()
-{
- list<ParamContext *>::iterator iter;
-
- for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
- ParamContext *pc = *iter;
-
- pc->checkParams();
- }
-}
-
-
-//
-// static method: call showParams() on all registered contexts
-//
-void
-ParamContext::showAllContexts(ostream &os)
-{
- list<ParamContext *>::iterator iter;
-
- for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
- ParamContext *pc = *iter;
-
- os << "[" << pc->iniSection << "]" << endl;
- pc->showParams(os);
- os << endl;
- }
-}
-
-
-//
-// static method: call cleanup() on all registered contexts
-//
-void
-ParamContext::cleanupAllContexts()
-{
- list<ParamContext *>::iterator iter;
-
- for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
- ParamContext *pc = *iter;
-
- pc->cleanup();
- }
-}
-
-
-//
-// static method: call describeParams() on all registered contexts
-//
-void
-ParamContext::describeAllContexts(ostream &os)
-{
- list<ParamContext *>::iterator iter;
-
- for (iter = ctxList->begin(); iter != ctxList->end(); ++iter) {
- ParamContext *pc = *iter;
-
- os << "[" << pc->iniSection << "]\n";
- pc->describeParams(os);
- os << endl;
- }
-}
-
void
parseTime(const std::vector<int> &time, struct tm *tm)
{
diff --git a/src/sim/param.hh b/src/sim/param.hh
index 8a4670e27..dff0fa72d 100644
--- a/src/sim/param.hh
+++ b/src/sim/param.hh
@@ -50,12 +50,6 @@ class SimObject;
//
class ParamContext : protected StartupCallback
{
- private:
-
- // static list of all ParamContext objects, built as a side effect
- // of the ParamContext constructor
- static std::list<ParamContext *> *ctxList;
-
protected:
// .ini file (database) for parameter lookup... initialized on call
@@ -78,31 +72,10 @@ class ParamContext : protected StartupCallback
public:
- /// Initialization phases for ParamContext objects.
- enum InitPhase {
- NoAutoInit = -1, ///< Don't initialize at all... params
- /// will be parsed later (used by
- /// SimObjectBuilder, which parses
- /// params in SimObject::create().
- OutputInitPhase = 0, ///< Output stream initialization
- TraceInitPhase = 1, ///< Trace context initialization:
- /// depends on output streams, but
- /// needs to come before others so we
- /// can use tracing in other
- /// ParamContext init code
- StatsInitPhase = 2, ///< Stats output initialization
- DefaultInitPhase = 3 ///< Everything else
- };
-
- /// Records the initialization phase for this ParamContext.
- InitPhase initPhase;
-
/// Constructor.
/// @param _iniSection Name of .ini section corresponding to this context.
/// @param _initPhase Initialization phase (see InitPhase).
- ParamContext(const std::string &_iniSection,
- InitPhase _initPhase = DefaultInitPhase);
-
+ ParamContext(const std::string &_iniSection);
virtual ~ParamContext() {}
// add a parameter to the context... called from the parameter
@@ -135,24 +108,6 @@ class ParamContext : protected StartupCallback
// generate the name for this instance of this context (used as a
// prefix to create unique names in resolveSimObject()
virtual const std::string &getInstanceName() { return iniSection; }
-
- // Parse all parameters registered with all ParamContext objects.
- static void parseAllContexts(IniFile &iniFile);
-
- // Check all parameters registered with all ParamContext objects.
- // (calls checkParams() on each)
- static void checkAllContexts();
-
- // Print all parameter values on indicated ostream.
- static void showAllContexts(std::ostream &os);
-
- // Clean up all registered ParamContext objects. (calls cleanup()
- // on each)
- static void cleanupAllContexts();
-
- // print descriptions of all parameters registered with all
- // ParamContext objects
- static void describeAllContexts(std::ostream &os);
};
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 4a8c0eb66..66ebc10e1 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -32,6 +32,7 @@
#include <fcntl.h>
#include <unistd.h>
+#include <fstream>
#include <string>
#include "arch/vtophys.hh"
@@ -199,8 +200,7 @@ namespace AlphaPseudo
Tick when = curTick + delay * Clock::Int::ns;
Tick repeat = period * Clock::Int::ns;
- using namespace Stats;
- SetupEvent(Reset, when, repeat);
+ Stats::StatEvent(false, true, when, repeat);
}
void
@@ -213,8 +213,7 @@ namespace AlphaPseudo
Tick when = curTick + delay * Clock::Int::ns;
Tick repeat = period * Clock::Int::ns;
- using namespace Stats;
- SetupEvent(Dump, when, repeat);
+ Stats::StatEvent(true, false, when, repeat);
}
void
@@ -254,8 +253,7 @@ namespace AlphaPseudo
Tick when = curTick + delay * Clock::Int::ns;
Tick repeat = period * Clock::Int::ns;
- using namespace Stats;
- SetupEvent(Dump|Reset, when, repeat);
+ Stats::StatEvent(true, true, when, repeat);
}
void
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index 1ff16976d..d32bb1142 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -407,36 +407,3 @@ Checkpoint::sectionExists(const std::string &section)
{
return db->sectionExists(section);
}
-
-/** Hacked stat reset event */
-
-class StatresetParamContext : public ParamContext
-{
- public:
- StatresetParamContext(const string &section);
- ~StatresetParamContext();
- void startup();
-};
-
-StatresetParamContext statParams("statsreset");
-
-Param<Tick> reset_cycle(&statParams, "reset_cycle",
- "Cycle to reset stats on", 0);
-
-StatresetParamContext::StatresetParamContext(const string &section)
- : ParamContext(section)
-{ }
-
-StatresetParamContext::~StatresetParamContext()
-{
-}
-
-void
-StatresetParamContext::startup()
-{
- if (reset_cycle > 0) {
- Stats::SetupEvent(Stats::Reset, curTick + reset_cycle, 0);
- cprintf("Stats reset event scheduled for %lli\n",
- curTick + reset_cycle);
- }
-}
diff --git a/src/sim/sim_object.cc b/src/sim/sim_object.cc
index 8fc8fe58f..434fcffe6 100644
--- a/src/sim/sim_object.cc
+++ b/src/sim/sim_object.cc
@@ -56,10 +56,6 @@ using namespace std;
//
SimObject::SimObjectList SimObject::simObjectList;
-namespace Stats {
- extern ObjectMatch event_ignore;
-}
-
//
// SimObject constructor: used to maintain static simObjectList
//
@@ -70,7 +66,6 @@ SimObject::SimObject(Params *p)
doDebugBreak = false;
#endif
- doRecordEvent = !Stats::event_ignore.match(name());
simObjectList.push_back(this);
state = Running;
}
@@ -86,7 +81,6 @@ SimObject::SimObject(const string &_name)
doDebugBreak = false;
#endif
- doRecordEvent = !Stats::event_ignore.match(name());
simObjectList.push_back(this);
state = Running;
}
@@ -245,8 +239,7 @@ debugObjectBreak(const char *objs)
void
SimObject::recordEvent(const std::string &stat)
{
- if (doRecordEvent)
- Stats::recordEvent(stat);
+ Stats::recordEvent(stat);
}
unsigned int
diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh
index 93802e247..536e761e5 100644
--- a/src/sim/sim_object.hh
+++ b/src/sim/sim_object.hh
@@ -136,7 +136,6 @@ class SimObject : public Serializable, protected StartupCallback
#endif
public:
- bool doRecordEvent;
void recordEvent(const std::string &stat);
};
diff --git a/src/sim/stat_control.cc b/src/sim/stat_control.cc
index 3fad8beb5..228c83898 100644
--- a/src/sim/stat_control.cc
+++ b/src/sim/stat_control.cc
@@ -38,14 +38,9 @@
#include "base/callback.hh"
#include "base/hostinfo.hh"
#include "base/statistics.hh"
-#include "base/str.hh"
#include "base/time.hh"
-#include "base/stats/output.hh"
#include "cpu/base.hh"
#include "sim/eventq.hh"
-#include "sim/sim_object.hh"
-#include "sim/stat_control.hh"
-#include "sim/root.hh"
using namespace std;
@@ -63,11 +58,9 @@ namespace Stats {
Time statTime(true);
Tick startTick;
-Tick lastDump(0);
-class SimTicksReset : public Callback
+struct SimTicksReset : public Callback
{
- public:
void process()
{
statTime.set();
@@ -92,7 +85,7 @@ statElapsedTicks()
SimTicksReset simTicksReset;
void
-InitSimStats()
+initSimStats()
{
simInsts
.functor(BaseCPU::numSimulatedInstructions)
@@ -153,81 +146,40 @@ InitSimStats()
registerResetCallback(&simTicksReset);
}
-class StatEvent : public Event
+class _StatEvent : public Event
{
- protected:
- int flags;
+ private:
+ bool dump;
+ bool reset;
Tick repeat;
public:
- StatEvent(EventQueue *queue, int _flags, Tick _when, Tick _repeat);
- virtual void process();
- virtual const char *description();
-};
-
-StatEvent::StatEvent(EventQueue *queue, int _flags, Tick _when, Tick _repeat)
- : Event(queue, Stat_Event_Pri),
- flags(_flags), repeat(_repeat)
-{
- setFlags(AutoDelete);
- schedule(_when);
-}
-
-const char *
-StatEvent::description()
-{
- return "Statistics dump and/or reset";
-}
-
-void
-StatEvent::process()
-{
- if (flags & Stats::Dump)
- DumpNow();
-
- if (flags & Stats::Reset) {
- cprintf("Resetting stats at cycle %d!\n", curTick);
- reset();
+ _StatEvent(bool _dump, bool _reset, Tick _when, Tick _repeat)
+ : Event(&mainEventQueue, Stat_Event_Pri), dump(_dump), reset(_reset),
+ repeat(_repeat)
+ {
+ setFlags(AutoDelete);
+ schedule(_when);
}
- if (repeat)
- schedule(curTick + repeat);
-}
+ virtual void
+ process()
+ {
+ if (dump)
+ Stats::dump();
-list<Output *> OutputList;
+ if (reset)
+ Stats::reset();
-void
-DumpNow()
-{
- assert(lastDump <= curTick);
- if (lastDump == curTick)
- return;
- lastDump = curTick;
-
- list<Output *>::iterator i = OutputList.begin();
- list<Output *>::iterator end = OutputList.end();
- for (; i != end; ++i) {
- Output *output = *i;
- if (!output->valid())
- continue;
-
- output->output();
+ if (repeat)
+ new _StatEvent(dump, reset, curTick + repeat, repeat);
}
-}
+};
void
-SetupEvent(int flags, Tick when, Tick repeat, EventQueue *queue)
+StatEvent(bool dump, bool reset, Tick when, Tick repeat)
{
- if (queue == NULL)
- queue = &mainEventQueue;
-
- new StatEvent(queue, flags, when, repeat);
+ new _StatEvent(dump, reset, when, repeat);
}
/* namespace Stats */ }
-
-void debugDumpStats()
-{
- Stats::DumpNow();
-}
-
diff --git a/src/sim/stat_control.hh b/src/sim/stat_control.hh
index 67f7cc491..1efa2554e 100644
--- a/src/sim/stat_control.hh
+++ b/src/sim/stat_control.hh
@@ -31,25 +31,10 @@
#ifndef __SIM_STAT_CONTROL_HH__
#define __SIM_STAT_CONTROL_HH__
-#include <fstream>
-#include <list>
-
-class EventQueue;
-
namespace Stats {
-enum {
- Reset = 0x1,
- Dump = 0x2
-};
-
-class Output;
-extern std::list<Output *> OutputList;
-
-void DumpNow();
-void SetupEvent(int flags, Tick when, Tick repeat = 0, EventQueue *queue = NULL);
-
-void InitSimStats();
+void initSimStats();
+void StatEvent(bool dump, bool reset, Tick when = curTick, Tick repeat = 0);
/* namespace Stats */ }