2
votes

I am using the configuration Simulation.py in configs/common. I get the error

ValueError: Attempted relative import in non-package

The full error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "build/X86/python/m5/main.py", line 438, in main
    exec(filecode, scope)
  File "configs/common/Simulation.py", line 49, in <module>
    from . import CpuConfig
ValueError: Attempted relative import in non-package

Simulation.py:

from __future__ import print_function
from __future__ import absolute_import

import sys
from os import getcwd
from os.path import join as joinpath

from . import CpuConfig
from . import BPConfig
from . import MemConfig

import m5
from m5.defines import buildEnv
from m5.objects import *
from m5.util import *

addToPath('../common')

I have tried changing to absolute import paths from relative import paths and I still get error. This guy had a similar error: https://www.mail-archive.com/[email protected]/msg16430.html but It didn't fix for me.

OS: Ubuntu 18.04.2 LTS
git SHA: d00aa3658498968f7dc2b586347771734af0d24a
1
How are you using Simulation.py? Are you calling it from a custom script, or using an in-tree script such as fs.py? What is the full gem5 command line? - Ciro Santilli
I did build/X86/gem5.opt configs/common/Simulation.py. I now realize this is not how it is supposed to be done. I was experimenting with the configs. Is there a documentation explaining what each config file does or the is only way to this is by going through the files? - eleanor

1 Answers

0
votes

After Eleanor's comment, it seems that they were trying to execute configs/common/Simulation.py directly with gem5.opt, which is not supported.

In general, Python scripts under configs/common are not meant to be executed directly, and just factor out other scripts.

The most important in-tree scripts that I am aware of are:

  • configs/example/fs.py: main cross arch full system script
  • configs/example/se.py: main cross arch syscall emulation script
  • configs/example/arm/fs_bigLITTLE.py: ARM bigLITTLE system
  • configs/example/arm/starter_fs.py: ARM minimal system
  • gem5/configs/learning_gem5/: tutorial scripts for Jason's Learning Gem5 tutorial

So you see that configs/example/ contains most of the interesting ones. You just have to learn what scripts must contain to be "runnable", the most important component is basically a call to:

Simulation.run

which actually starts the simulation.

The only considerable documentations I know of are:

  1. http://gem5.org/ which is a semi messy wiki, so hit and miss

  2. http://learning.gem5.org/ by Jason which shows how to setup some basic Python configs, and is very valuable

  3. https://github.com/cirosantilli/linux-kernel-module-cheat which contains some setups that just work and can serve as a starting reference