Addis Ababa University Addis Ababa Institute of Technology School of Electrical and Computer Engineering
Addis Ababa University Addis Ababa Institute of Technology School of Electrical and Computer Engineering
Addis Ababa University Addis Ababa Institute of Technology School of Electrical and Computer Engineering
Assignment One
Overview
The purpose of this assignment is dual-fold. First, it will expose you to gem5, which we will use
more heavily later. Second, it will give you experience measuring performance on different
systems and comparing and contrasting those systems.
For this assignment, you will go through the first few parts of the gem5 book by yourself. gem5
is a system simulator. It is a modular platform for computer-system architecture research,
encompassing system-level architecture as well as processor micro-architecture.
Go through the Introduction and Building gem5 pages of the gem5 book. Make sure to get your
gem5 install working before moving on.
gem5 on Linux
gem5 will work the best on Linux. The Building gem5 page lists the dependency names on
Ubuntu. If you are using a different distribution, you should be able to find the corresponding
packages through your package manager, if the names aren't the same.
gem5 on OS X
gem5 will run on OS X. However, in years past, we have had a lot of difficulty with certain tools
used in the compilation process. In particular, we have had trouble with Python versions, SCons,
the tool used to compile gem5, and LLVM, which Xcode uses as its back-end for gcc. See
the Common Errors section for more information.
gem5 on Windows
There is limited support for Windows running the Windows Subsystem for Linux. If you use
Windows, consider running a distribution of Linux in a VM or dual-booting. This will be a good
idea for the rest of your time as a student s, as well.
1
Compilation Instructions
Note: there is one modification to the compilation command in the book that you will need
to make. When you are compiling, you will need to pass the following option to SCons:
CPU_MODELS=AtomicSimpleCPU,TimingSimpleCPU,O3CPU,MinorCPU
The entire compilation command should look like this:
scons build/X86/gem5.opt -jX \
CPU_MODELS=AtomicSimpleCPU,TimingSimpleCPU,O3CPU,MinorCPU
where X in -jX is the number of cores in your system, plus one.
As mentioned in the book, it takes a while to compile gem5. You should download and start the
compilation process before doing anything else.
Go through the rest of Part I of the gem5 book. You will go through the following topics:
There are YouTube videos of me giving lectures on different parts of the book. The video
for Part I will be helpful to watch. You can find all of the videos on this channel.
Write a simple C++ program to implement the Sieve of Eratosthenes. The sieve is an algorithm
to calculate all prime numbers up to a certain limit. If you are unfamiliar, have a look at
the linked Wikipedia page.
For this sieve, we want an output of one single integer at the end: the number of prime numbers
<= the input argument, taken from the command line. Compile your program as a static binary.
For the number of prime numbers <= 100 000 000, the output should be 5761455.
Now, you will run your application in gem5 with the configuration script you made in the book.
You will change the CPU model, frequency, and memory configuration while testing your sieve
program.
2
Run your sieve program in gem5 instead of the 'hello' example. You will need to change the
location in your configuration script to where your static binary is located. Do not use se.py or
any other configuration script. Use the one you made in the book. Save the statistics file
generated from this run, and for every run after this one.
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.
Somewhere around 1 000 000 takes about 5 minutes, which is a good compromise.
Note: the MinorCPU model (the next step) takes about 10x longer than TimingSimpleCPU takes.
Change the CPU clock from 1 GHz to 2 and 4 GHz with both CPU models.
Hint: you may want to add a command line parameter as in the previous case to change the
frequency.
Hint: you may want to add a command line parameter to control the memory configuration.
You should have twelve statistic files for the following runs:
TimingSimpleCPU 1 DDR3_1600_8x8
3
CPU Model Frequency (GHz) Memory
TimingSimpleCPU 2 DDR3_1600_8x8
TimingSimpleCPU 4 DDR3_1600_8x8
MinorCPU 1 DDR3_1600_8x8
MinorCPU 2 DDR3_1600_8x8
MinorCPU 4 DDR3_1600_8x8
TimingSimpleCPU 4 DDR3_2133_8x8
TimingSimpleCPU 4 LPDDR2_S4_1066_1x32
TimingSimpleCPU 4 HBM_1000_4H_1x64
MinorCPU 4 DDR3_2133_8x8
MinorCPU 4 LPDDR2_S4_1066_1x32
MinorCPU 4 HBM_1000_4H_1x64
Step 5: Report
Finally, you will describe the changes in performance between your tests.
Your report should be in PDF format and should contain your observations and conclusions from
the experiment.
1. What metric should you use to compare the performance between different system
configurations? Why?
2. Which CPU model is more sensitive to changing the CPU frequency? Why?
3. Which CPU model is more sensitive to changing the memory technology? Why?
4. Is the sieve application more sensitive to the CPU model, the memory technology, or
CPU frequency? Why?
5. If you were to use a different application, do you think your conclusions would change?
Why?
Submission
Archive the following into a .gz or .tgz file:
4
• Your sieve .cpp file.
• Your final gem5 configuration script from the book.
• Your statistics files (stats.txt) from your runs of your sieve, appropriately named.
Submit your archive, as well as the PDF of your report through the google classroom
platform. Do not include the PDF in the archive, submit it as a separate file.
Late assignments receive an automatic 10% reduction per day they are late. Assignments will not
be accepted for late submission four days after the due date.
Common Errors
See the Building gem5 page of the book if you are having trouble getting gem5 to build.
For OS X, if you are having issues with SCons, you will need to downgrade to SCons 2.5.1.
SCons 3.0.0, which is default that Homebrew installs, does not work.
Additionally, on OS X, you will need to ensure that you are using the correct Python version. As
mentioned in the book, use the following command to specify the correct Python version:
python `which scons` build/X86/gem5.opt -jX \
CPU_MODELS=AtomicSimpleCPU,TimingSimpleCPU,O3CPU,MinorCPU
If your sieve program needs a command line argument to run, then you need to pass the options
through the process.cmd parameter. You can add another element to the list assigned to process.cmd.
This parameter is like argv[] in a normal C program.
You can also add a command line option to your script to pass options through to the simulated
process.