Build and simulate
Table of contents
At this part, you will learn installation and simulation of gem5
Build gem5(click me)
You can choose either of three ways below.
Setup on Ubuntu 20.04 (gem5 >= v21.0)
sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
python3-dev python-is-python3 libboost-all-dev pkg-config
Setup on Ubuntu 18.04 (gem5 >= v21.0)
sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
python3-dev python libboost-all-dev pkg-config
Using Docker
- Install Docker
For windows, install wsl first by using
wsl --install
then download Docker Desktop for Windows and install.
wsl
is windows subsystem for linux. You can do most of the things you can do on Linux on WSL. To integrate docker with wsl throughsetting=>Resources=>WSL Integration
For other systems, reference here.
- Build gem5 with Docker
First,obtain gem5 image
docker pull gcr.io/gem5-test/ubuntu-20.04_all-dependencies:v22-0
Due to some reason, you may fail to pull that image, you can change
gcr.io
togcr.lank8s.cn
Then, launch the container
docker run -itd -v <gem5 directiory>:/gem5 <image>
using
docker images
to get info about<image>
using
git clone -b v22.0.0.2 https://github.com/gem5/gem5.git
to get gem5
Then,connect to the container
docker exec -it <container> /bin/bash
using
docker ps
to get info about<container>
Build
To get gem5
git clone -b v22.0.0.2 https://github.com/gem5/gem5.git
Within the root of the gem5 directory, gem5 can be built with SCons using:
scons build/X86/gem5.opt -j <cpu-nums>
Write an insteresting app(sieve)
Write a program that outputs one single integer at the end the number of prime numbers <= N
(at default N = 100,000,000) . Compile your program as a static binary. Note that your program must achieve O(N) complexity.
Use gem5
-
to simulate the program in gem5, these tutorials may be helpful
-
Run your sieve program in gem5
- choose an appropriate input size
You should use something large enough that the application is interesting, but not too large that gem5 takes more than 10 minutes to execute a simulation.
- change the CPU model from X86TimingSimpleCPU to X86MinorCPU.
gem5 won’t compile X86MinorCPU by default. You need to add some modifications. gem5 use
CPU_MODELS
as a parameter in the past. Try to search the keywordCPU_MODELS
and see what you can find out. If you searchCPU_MODELS
and you will see it in release-note.md. It tells that you should modify underarch
dir. To simplify the exp, we give the hint that you should modifysrc/arch/x86/X86CPU.py
.-
Vary the CPU clock from 1GHz to 2GHz (in steps of 1GHz) with both CPU models.
-
Change the memory configuration from DDR3_1600_8x8 to DDR3_2133_8x8 (DDR3 with a faster clock)
a. In each output, does
system.cpu.numCycles
timessystem.clk_domain.clock
equalssimTicks
? Why ?
b. A single-cycle processor executes one instruction per clock cycle. A classic five-stage pipelined processor, on average, executes less than one instruction per clock cycle (due to branching). So why are processors on the market pipelined?