Hello,

Unfortunately, I don't think gem5 is the right tool for this job. When you
run that command, gem5's embedded python interpreter is executing `se.py`.
There's not really a way to easily get around this. You could try to
compile gem5 without python (--without-python, IIRC), but then configuring
the system you're running is difficult, if not impossible, depending on the
system you want to simulate.

Cheers,
Jason

On Thu, Jul 1, 2021 at 6:06 PM Konstantin Serebryany <
konstantin.s.serebry...@gmail.com> wrote:

> Hi Jason,
>
> Thanks for the reply!
> I was hoping for something light-weight, similar to Unicorn, but based on
> gem5 instead of QEMU...
>
> I tried running
>   build/X86/gem5.opt configs/example/se.py -c
> ./tests/test-progs/hello/bin/x86/linux/hello
> and it takes 0.3 second -- too slow.
>
> The profile shows:
>   14.55%  gem5.opt  libpython3.9.so.1.0    [.] _PyEval_EvalFrameDefault
>
>
>
>    2.31%  gem5.opt  libpython3.9.so.1.0    [.] _PyType_Lookup
>
>
>
>    2.01%  gem5.opt  libpython3.9.so.1.0    [.]
> _PyObject_GenericGetAttrWithDict
>
>
>    1.09%  gem5.opt  libpython3.9.so.1.0    [.] _Py_CheckFunctionResult
>
>
>
>    1.06%  gem5.opt  libpython3.9.so.1.0    [.] 0x00000000002000b0
>
>
>
> ...
> I.e. all the time for simulating a tiny test is spent in python.
>
> I'd like to be able to simulate tiny programs, like "hello" from the
> examples,
> but hopefully at least 100x faster than this.
>
> What's the best supported mechanism for running many tiny simulations
> w/o having to pay for the large python overhead?
> Any examples?
>
> --kcc
>
>
>
>
>
>
> On Thu, Jul 1, 2021 at 5:00 PM Jason Lowe-Power <ja...@lowepower.com>
> wrote:
>
>> Hello,
>>
>> It's somewhat possible. You can compile gem5 as a library (e.g., scons
>> build/<Default build opts>/libgem5-opt.so). However, gem5 *is a python
>> interpreter* and is configured via python scripts. Getting that to work
>> with an external program is "exciting". It's possible to get python
>> working, and there are other workarounds like using the CXXConfig
>> interface, but it's not straightforward or easy to understand.
>>
>> Unless you're trying to integrate gem5 into another simulator, it's
>> unlikely that invoking gem5 from another program is the best option. Even
>> in this case, I would advise going the other way and using gem5 as the
>> driver simulator. That said, there are many simulators that integrate with
>> gem5. You can easily hook in things like DRAMSim, at one point I integrated
>> it with GPGPU-Sim (this is now incredibly out of date), and there is an
>> SST-gem5 bridge that we are actively working on. Finally, there are many
>> efforts to integrate gem5 with SystemC including implementing the entire
>> SystemC spec in gem5.
>>
>> Hopefully this helps. I'd be happy to provide more specific help with
>> some more information :).
>>
>> Cheers,
>> Jason
>>
>> On Thu, Jul 1, 2021 at 4:49 PM Konstantin Serebryany via gem5-users <
>> gem5-users@gem5.org> wrote:
>>
>>> Hi,
>>>
>>> [gem5 newbie here... ]
>>>
>>> Does gem5 have a C++ API?
>>>
>>> I am interested in using gem5 as a library, i.e. invoking
>>> the system call emulation mode from within my process,
>>> without fork/exec or python.
>>> Is that at all possible?
>>> Any pointers?
>>>
>>> thanks!
>>>
>>> --kcc
>>>
>>> _______________________________________________
>>> gem5-users mailing list -- gem5-users@gem5.org
>>> To unsubscribe send an email to gem5-users-le...@gem5.org
>>> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
>>
>>
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to