config: Add a --without-python option to build process
Add the ability to build libgem5 without embedded Python or the ability to configure with Python. This is a prelude to a patch to allow config.ini files to be loaded into libgem5 using only C++ which would make embedding gem5 within other simulation systems easier. This adds a few registration interfaces to things which cross between Python and C++. Namely: stats dumping and SimObject resolving
This commit is contained in:
@@ -31,8 +31,8 @@
|
||||
|
||||
Import('*')
|
||||
|
||||
Source('swig/pyevent.cc')
|
||||
Source('swig/pyobject.cc')
|
||||
Source('swig/pyevent.cc', skip_no_python=True)
|
||||
Source('swig/pyobject.cc', skip_no_python=True)
|
||||
|
||||
PySource('', 'importer.py')
|
||||
PySource('m5', 'm5/__init__.py')
|
||||
|
||||
@@ -41,6 +41,7 @@ def initText(filename, desc=True):
|
||||
|
||||
def initSimStats():
|
||||
internal.stats.initSimStats()
|
||||
internal.stats.registerPythonStatsHandlers()
|
||||
|
||||
names = []
|
||||
stats_dict = {}
|
||||
|
||||
@@ -157,9 +157,12 @@ extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
|
||||
// these in sim/main.cc as well that are handled without this define.
|
||||
#define PCC(s) const_cast<char *>(s)
|
||||
|
||||
/** Single instance of PythonSimObjectResolver as its action is effectively
|
||||
* static but SimObjectResolver can use a non-persistent object */
|
||||
PythonSimObjectResolver pythonSimObjectResolver;
|
||||
|
||||
SimObject *
|
||||
resolveSimObject(const string &name)
|
||||
PythonSimObjectResolver::resolveSimObject(const string &name)
|
||||
{
|
||||
PyObject *module = PyImport_ImportModule(PCC("m5.SimObject"));
|
||||
if (module == NULL)
|
||||
@@ -188,3 +191,9 @@ resolveSimObject(const string &name)
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Checkpoint *
|
||||
getCheckpoint(const std::string &cpt_dir)
|
||||
{
|
||||
return new Checkpoint(cpt_dir, pythonSimObjectResolver);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,12 @@
|
||||
#include "sim/sim_object.hh"
|
||||
|
||||
extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
|
||||
SimObject *resolveSimObject(const std::string &name);
|
||||
|
||||
/** Resolve a SimObject name using the Python configuration */
|
||||
class PythonSimObjectResolver : public SimObjectResolver
|
||||
{
|
||||
SimObject *resolveSimObject(const std::string &name);
|
||||
};
|
||||
|
||||
EtherInt * lookupEthPort(SimObject *so, const std::string &name, int i);
|
||||
|
||||
@@ -53,11 +58,8 @@ serializeAll(const std::string &cpt_dir)
|
||||
Serializable::serializeAll(cpt_dir);
|
||||
}
|
||||
|
||||
inline Checkpoint *
|
||||
getCheckpoint(const std::string &cpt_dir)
|
||||
{
|
||||
return new Checkpoint(cpt_dir);
|
||||
}
|
||||
Checkpoint *
|
||||
getCheckpoint(const std::string &cpt_dir);
|
||||
|
||||
inline void
|
||||
unserializeGlobals(Checkpoint *cp)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "base/statistics.hh"
|
||||
#include "sim/core.hh"
|
||||
#include "sim/stat_control.hh"
|
||||
#include "sim/stat_register.hh"
|
||||
|
||||
namespace Stats {
|
||||
template <class T>
|
||||
@@ -64,20 +65,6 @@ Stats_Info_flags_set(Info *info, FlagsType flags)
|
||||
info->flags = flags;
|
||||
}
|
||||
|
||||
inline void
|
||||
processResetQueue()
|
||||
{
|
||||
extern CallbackQueue resetQueue;
|
||||
resetQueue.process();
|
||||
}
|
||||
|
||||
inline void
|
||||
processDumpQueue()
|
||||
{
|
||||
extern CallbackQueue dumpQueue;
|
||||
dumpQueue.process();
|
||||
}
|
||||
|
||||
inline char *
|
||||
PCC(const char *string)
|
||||
{
|
||||
@@ -102,13 +89,13 @@ call_module_function(const char *module_name, const char *func_name)
|
||||
}
|
||||
|
||||
void
|
||||
dump()
|
||||
pythonDump()
|
||||
{
|
||||
call_module_function("m5.stats", "dump");
|
||||
}
|
||||
|
||||
void
|
||||
reset()
|
||||
pythonReset()
|
||||
{
|
||||
call_module_function("m5.stats", "reset");
|
||||
}
|
||||
@@ -150,6 +137,8 @@ template <class T> T cast_info(Info *info);
|
||||
void initSimStats();
|
||||
Output *initText(const std::string &filename, bool desc);
|
||||
|
||||
void registerPythonStatsHandlers();
|
||||
|
||||
void schedStatEvent(bool dump, bool reset,
|
||||
Tick when = curTick(), Tick repeat = 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user