It would be great if you could add a paragraph on the aforementioned SimObject
page with your findings.
Andreas
From: Zheng Wu <[email protected]<mailto:[email protected]>>
Reply-To: gem5 users mailing list
<[email protected]<mailto:[email protected]>>
Date: Thursday, 11 July 2013 02:55
To: gem5 users mailing list <[email protected]<mailto:[email protected]>>
Subject: Re: [gem5-users] Python Interaction with C++
Okay ignore my previous question….I got it… Py_Initialize() is a python/c++ API
call provided by the python library.
On 2013-07-10, at 12:47 PM, Jack Wu
<[email protected]<mailto:[email protected]>> wrote:
Hi Andreas,
Thanks for your feedback. I looked over the tutorial and I'm reading about the
SimObjects (http://www.m5sim.org/SimObjects) and there is a call sequence
diagram.
Based on the diagram, the gem5 program starts at the main() function in c++ and
then invokes the python interpreter to deal with the configuration scripts like
you mentioned.
But what I am confused about is how the python is invoked. The functions that
main() calls are:
-initSignals()
-Py_SetProgramName(argv[0])
-Py_Initialize()
-initM5Python()
-m5Main(argc, argv)
-Py_Finalize()
>From comments in source code, the "Py_Initialize()" function is used to
>initialize the embedded python interpreter.
I tried to grep for this function and see where it's implemented and can't find
anything, so how does this function invoke the python interpreter?
(Also the Py_SetProgramName() and Py_Finalize() functions have no
implementation either )
Many Thanks,
Jack
On 2013-07-10, at 12:13 PM, Andreas Hansson
<[email protected]<mailto:[email protected]>> wrote:
Hi Jack,
If you look at the HiPEAC tutorial slides there is an overview of "the big
picture" that shows roughly what is going on. gem5 kicks off a python
interpreter that reads your configuration script, for example se.py. This
script works with a bunch of Python classes to assemble and configure your
system. The System() class you mention is a Python class with a bunch of
knobs (and some of these also have ports).
Once you have got all these configured and assembled, the simulate.py
script goes and turns them into their corresponding C++ classes and passes
the parameters that you set in the Python code. Thus, the Python code is
used to assemble and configure the system (and orchestrate the
simulation), and the C++ classes actually _do_ something during the
simulation itself.
I hope that makes things a bit more clear.
Andreas
On 10/07/2013 16:52, "Jack Wu" <[email protected]<mailto:[email protected]>>
wrote:
Dear Community,
I am new to gem5 and trying to understand gem5 by looking at the source
code starting from the main() function and configuration scripts such as
config/example/se.py.
I don't quite understand the interaction between python and c++. The
following are what I think how it works, please correct me if something
is not right.
1) Python accessing c++ objects:
-SWIG is used to provide the abstraction of c++ object through *.i files
so these objects can be used in python like regular python objects (e.g.
list or dictionary).
- all c++ objects are compiled into a python module called "m5", which is
compiled directly into the gem5 binary (e.g. gem.opt).
-an example of using c++ objects in python would something like (from
se.py): system = System(Š.) // I am guessing System is an object in c++?
2) c++ accessing python objects:
-while looking at the main() function, it calls initM5python(), which in
turn calls a) EmeddedSwig::initAll() and b) EmbeddedPython::initAll()
-I am quite confused about these function calls and their purpose. Are
they trying to access certain objects in python?
-For example: I see an variable called "PyObject" and it's a "typedef
_object PyObject" (in src/sim/init.hh). However "_object" is declared as
"struct _object" and it's not defined anywhere.
-There are a bunch of other variables which are declared but not defined
and it seems to have something to do with python, but I am not sure how
this works
Comments and feedback are much appreciated.
Thanks In Advance,
Jack
_______________________________________________
gem5-users mailing list
[email protected]<mailto:[email protected]>
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
-- IMPORTANT NOTICE: The contents of this email and any attachments are
confidential and may also be privileged. If you are not the intended recipient,
please notify the sender immediately and do not disclose the contents to any
other person, use it for any purpose, or store or copy the information in any
medium. Thank you.
_______________________________________________
gem5-users mailing list
[email protected]<mailto:[email protected]>
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
_______________________________________________
gem5-users mailing list
[email protected]<mailto:[email protected]>
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
-- IMPORTANT NOTICE: The contents of this email and any attachments are
confidential and may also be privileged. If you are not the intended recipient,
please notify the sender immediately and do not disclose the contents to any
other person, use it for any purpose, or store or copy the information in any
medium. Thank you.
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users