- Build gem5(click me)
- Write an insteresting app(sieve)
- Use gem5
At this part, you will learn installation and simulation of gem5
You can choose either of three ways below.
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
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
- Install Docker
For windows, install wsl first by using
then download Docker Desktop for Windows and install.
wslis windows subsystem for linux. You can do most of the things you can do on Linux on WSL. To integrate docker with wsl through
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
Then, launch the container
docker run -itd -v <gem5 directiory>:/gem5 <image>
docker imagesto get info about
git clone -b v220.127.116.11 https://github.com/gem5/gem5.gitto get gem5
Then,connect to the container
docker exec -it <container> /bin/bash
docker psto get info about
To get gem5
git clone -b v18.104.22.168 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 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.
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_MODELSas a parameter in the past. Try to search the keyword
CPU_MODELSand see what you can find out. If you search
CPU_MODELSand you will see it in release-note.md. It tells that you should modify under
archdir. To simplify the exp, we give the hint that you should modify
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
simTicks? 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?