Building gem5
Platforms
- Linux, BSD, MacOS X, Solaris, etc
- 64 bit machines help quite a bit
Tools
- GCC/G++ 4.4+ (or clang 2.9+)
- Python 2.4+
- SCons 0.98.1+
- SWIG 1.3.40+
If using Ubuntu install
- apt-get install python-dev scons m4 build-essential g++ swig zlib-dev
Compile Targets
build:
- build/<
isa>/< binary>
ISAs:
- ARM, ALPHA, MIPS, SPARC, POWER, X86, RISCV
Binaries
- gem5.debug
- debug build, symbols, tracing, assert
- gem5.opt
- optimized build, symbols, tracing, assert
- gem5.fast
- optimized build, no debugging, no symbols, no tracing, no assertions
- gem5.prof
- gem5.fast + profiling support
Sample Compile
[/work/gem5] scons build/ARM/gem5.opt –j4
Running Simulation
[/work/gem5] ./build/ARM/gem5.opt -h
Usage
=====
gem5.opt [gem5 options] script.py [script options]
gem5 is copyrighted software; use the --copyright option for details.
Options
=======
--version show program's version number and exit
--help, -h show this help message and exit
--build-info, -B Show build information
--copyright, -C Show full copyright information
--readme, -R Show the readme
--outdir=DIR, -d DIR Set the output directory to DIR [Default: m5out]
--redirect-stdout, -r Redirect stdout (& stderr, without -e) to file
--redirect-stderr, -e Redirect stderr to file
--stdout-file=FILE Filename for -r redirection [Default: simout]
--stderr-file=FILE Filename for -e redirection [Default: simerr]
--interactive, -i Invoke the interactive interpreter after running the
script
--pdb Invoke the python debugger before running the script
--path=PATH[:PATH], -p PATH[:PATH]
Prepend PATH to the system path when invoking the
script
Running Simulation
Statistics Options
------------------
--stats-file=FILE Sets the output file for statistics [Default: stats.txt]
Configuration Options
---------------------
--dump-config=FILE Dump configuration output file [Default: config.ini]
--json-config=FILE Create JSON output of the configuration [Default: config.json]
Debugging Options
-----------------
--debug-break=TIME[,TIME]
Cycle to create a breakpoint
--debug-help Print help on trace flags
--debug-flags=FLAG[,FLAG]
Sets the flags for tracing (-FLAG disables a flag)
--remote-gdb-port=REMOTE_GDB_PORT
Remote gdb base port (set to 0 to disable listening)
Trace Options
-------------
--trace-start=TIME Start tracing at TIME (must be in ticks)
--trace-file=FILE Sets the output file for tracing [Default: cout]
--trace-ignore=EXPR Ignore EXPR sim objects
gem5 has two fundamental modes
Full system (FS)
- For booting operating systems
- Models bare hardware, including devices
- Interrupts, exceptions, privileged instructions, fault handlers
- Simulated UART output
- Simulated frame buffer output
Syscall emulation (SE)
- For running individual applications, or set of applications on MP
- Models user-visible ISA plus common system calls
- System calls emulated, typically by calling host OS
- Simplified address translation model, no scheduling
Now dependent on how you run the binary
- No longer need to compile different binaries
Sample Run – Syscall Emulation
[/work/gem5] ./build/ARM/gem5.opt configs/example/se.py \
-c tests/test-progs/hello/bin/arm/linux/hello
Sample Run – Full System
Command Line:
22:13:19 [/work/gem5] ./build/ARM/gem5.opt configs/example/fs.py
…
info: kernel located at: /dist/binaries/vmlinux.arm.smp.fb.2.6.38.8
Listening for system connection on port 5900
Listening for system connection on port 3456
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
info: Using bootloader at address 0x80000000
**** REAL SIMULATION ****
info: Entering event queue @ 0. Starting simulation...
warn: The clidr register always reports 0 caches.
warn: clidr LoUIS field of 0b001 to match current ARM implementations.
Terminal:
22:13:19 [/work/gem5] ./util/term/m5term 127.0.0.1 3456
==== m5 slave terminal: Terminal 0 ====
[0.000000] Linux version 2.6.38.8-gem5 (saidi@zeep) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41) )
#1 SMP Mon Aug 15 21:18:38 EDT 2011
[0.000000] CPU: ARMv7 Processor [350fc000] revision 0 (ARMv7), cr=10c53c7f
[0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[0.000000] Machine: ARM-RealView PBX
...
starting pid 354, tty '': '/sbin/getty -L ttySA0 38400 vt100'
AEL login: