All contents original from https://github.com/dependablecomputinglab
This article is just a backup incase myself later using.
Gem5 Installation
step 1: install prerequisites
for Ubuntu
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install -y git build-essential g++ zlib1g-dev scons m4 swig python-dev
step 2: Download & Build
Download
$ cd ~
~$ git clone https://github.com/gem5/gem5
Build
- Command: $ scons build//
- Supported ISA: ARM, ALPHA, MIPS, SPARC, POWER, X86
- Supported Binaries: gem5.debug, gem5.opt, gem5.fast, gem5.prof
This is a example for ARM architecture
$ cd ~/gem5
~/gem5$ scons build/ARM/gem5.opt
step 3: Run benchmark
- Command: $ build// -c
- Outputs are generated in m5out/
This is example for building gem5 for ARM ISA
$ cd ~
~$ git clone https://github.com/gem5/gem5
All simulation statistics are saved as file m5out/stats.txt
Simulation Process
- Get benchmark to simulate
- Do simulation
- Analyze simulation statistics
STEP1: Get Benchmark
You can get benchmark by:
- Making your own benchmark yourself
- Download binary
- Download source code & build binary
In our case, we will download MiBench, then cross-compile to get benchmark.
Download MiBench
$ git clone https://github.com/embecosm/mibench.git
Install Cross-compiler
$ sudo apt-get install gcc-arm-linux-gnueabi
Cross-compile to build binary
Initially, you can see Makefile in directory ‘mibench/automotive/qsort‘ looks like:
...
gcc -static qsort_large.c -O3 -o qsort_large -lm
...
Replace all ‘gcc‘ to ‘arm-linux-gnueabi-gcc‘, so the Makefile looks like:
...
arm-linux-gnueabi-gcc -static qsort_large.c -O3 -o qsort_large -lm
...
To build, execute
$ make
NOTE When you cross-compile, you must use ‘-static‘ option. If there is no ‘-static‘ option in Makefile, you have to insert it.
For example, if your Makefile looks like:
...
arm-linux-gnueabi-gcc qsort_large.c -O3 -o qsort_large -lm
...
You have to insert ‘-static‘ option. Then, Makefile will look like:
...
arm-linux-gnueabi-gcc -static qsort_large.c -O3 -o qsort_large -lm
...
STEP2: Perform Simulation
$ <gem5 binary> [gem5 options] <gem5 script> [gem5 script options]
Useful gem5 script options
- ‘-c <binary to simulate>’
- ‘-o <input set of benchmark>’
For example, if you want to simulate qsort_large,
$ ./build/ARM/gem5.opt -re configs/example/se.py --cpu-type=atomic -c <path to qsort_large> -o <path to input_large.dat>
NOTE
If you want to put multiple input to binary, you have to use quotation marks(“) and white spaces.
For example, if your fft binary is in ~/mibench/telecom/FFT,
$ ./build/ARM/gem5.opt -re configs/example/se.py --cpu-type=timing -c ~/mibench/telecom/FFT/fft -o "100 64"
STEP3: Analyzing Simulation Statistics
Find difference between two files with diff
The diff is a program in linux.
The diff compares two files, line by line.
You can use diff by executing: $ diff [options] <file1> <file2>
For example, clone this repository and execute:
$ diff goodbye1.txt goodbye2.txt
If you use ‘-u‘ option like this:
$ diff -u goodbye1.txt goodbye2.txt
Redirection may make you happy! Try this:
$ diff -u goodbye1.txt goodbye2.txt > goodbye.diff
You can see the file goodbye.diff.
Notes for reading
Topic 6 Successful students think about how to study. They ... Read more
Lemmatization of English words in sentences in XML format by Python
Lemmatization of English words in sentences in XML format by ... Read more