Writing Gem5 Configuration Scripts With Pycharm
Solution 1:
A few pointers from what I see at gem5 d9cb548d83fa81858599807f54b52e5be35a6b03 (May 2020) under gem5/configs/learning_gem5/part1/two_level.py
:
from common
: common is atconfigs/common
which gets found because of the abovem5.util.addToPath('../../')
call, so addconfigs/
to the PYTHONPATH as shown at: PyCharm and PYTHONPATHimport m5
comes fromsrc/python/m5
so addsrc/python
to the PYTHONPATH as abovefrom caches import *
comes from the siblinglearning_gem5/part1/caches.py
, so likely this will be found automatically by PyCharm. Otherwise add that directory to the PYTHONPATH.from m5.objects import *
: this is likely the one you are really interested in as it contains all the interesting objects, but unfortunately PyCharm simply cannot handle it I believe since the SimObjects are added dynamically to that namespace at startup in a very convoluted way via PyBind11 native modules + code generation.A description of how this works in more detail can be found here, but basically every SimObject class goes through some heavy code autogeneration to make this work, say e.g.
src/cpu/simple/AtomicSimpleCPU.py
due toSimObject('AtomicSimpleCPU.py')
insrc/cpu/simple/SConscript
.As of 2017, PyCharm said they did not have plans for a proper native C/C++ extension setup: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206018984-Developing-Python-extension-in-C-using-PyCharm
With that said, I've found that it is not worth to use an IDE for the Python part of gem5. This is because the Python tends to be very simple to understand with IPDB (or impossible to setup an IDE for), and if you just grep
stuff you tend to quickly guess what is going on. For C++ though I do recommend setting up Eclipse: How to setup Eclipse IDE for gem5 development?
Related: Add custom modules to PyCharm Linter
Post a Comment for "Writing Gem5 Configuration Scripts With Pycharm"