ECE 752 Fall 2019 Homework 1 // Due xxx, 2019

The purpose of this assigment is to:

This assignment is to be completed individually.

NOTE: this assignment writeup is a work in progress. If you discover any problems or issues, please let me know as soon as possible.


Programming environment: You may do this assignment using best-tux.cae.wisc.edu (one of the CAE linux machines in B555) or any other linux machine you have access to. The tux machines typically contain a quad-core CPU, so the amount of parallelism you can effectively explore will be limited.

Program Description:

In this homework, you will be compile, run, and then simulate a very simple program that simulates a simple CPU. In other words, you will simulate a simulator.

The program in question is from Prof. Daniel Jimenez at TAMU, and is a simple toy simulator that estimates the CPI of a multi-cycle CPU. The source code is here.

Homework Requirements

This homework involves the completion of three primary tasks.
  1. Compiling and running the sim.cc program on a linux system./li>
  2. Compiling the gem5 simulator on a linux system.
  3. Simulating the sim.cc in gem5.

The results of all steps need to be neatly documented in a report you must upload to canvas for grading.

Part 1 - Compiling and running the sim.cc program

Download sim.cc into a suitable directory on a linux machine.

  1. Compile it with 'g++ -O0 -o sim.unopt sim.cc'
  2. Run the program and time its execution with 'time ./sim.unopt'
  3. Now recompile it with optimization enabled: 'g++ -O3 -o sim.opt sim.cc'
  4. Run the program and time its execution with 'time ./sim.opt'
  5. Report the runtime for both optimized and unoptimized versions and compute the speedup from compiler optimization.

Part 2 - Compiling gem5

Follow the directions in Part I of the gem5 tutorial to build gem5, create a simple configuration script, and adding cache to the configuration script.

If you have a personal linux machine, you will have to make sure the "scons" and "swig" packages are installed.

If you have a reasonably fast PC with a decent amount of memory, but it runs windows, I highly recommend running linux in a virtual machine using the Virtual Box platform. It is quite straightforward to create a VM and install the latest stable version of Ubuntu on it.

If you are using the best-tux.cae.wisc.edu machines, you will need to issue the following command to pick up locally-installed versions of scons and swig (you can also add this to the .bashrc file in your home directory, if you wish; that way it is automatically performed whenever you log in):
$ source /home/vhosts/ece752.ece.wisc.edu/.bashrc

The above script will also set GEM5=/home/vhosts/ece.752.wisc.edu/src/gem5 as a shortcut to find the gem5 install on the best-tux machines. You should create your own installation and set this variable to point to that location.

NOTE: There is one small issue with the compilation command in the Learning gem5 book: it will not compile the MinorCPU model by default. Use the following command instead:
scons build/X86/gem5.opt -j5 CPU_MODELS=AtomicSimpleCPU,TimingSimpleCPU,O3CPU,MinorCPU

Part 3 - Running gem5

Run your sim.opt program in gem5 instead of the 'hello' example from the tutorial by changing the location of the binary in the configuration file. Use the two_level.py file you created while following the tutorial.

By default, gem5 will write the output file to the same folder (m5out) every time. Make sure to move your output file before a subsequent run.

You should run the sim.opt program a total of twelve times in the configurations shown below, varying the CPU model, clock frequency, and main memory. You will need to refer to the tutorial to figure out how to do modify these configuration parameters.
CPU Model CPU Frequency (GHz) Memory
TimingSimpleCPU 1 DDR3_1600_8x8
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

After collecting all of the data from the previous steps, analyze the statistics your runs generated and write a report. Your report should be nicely-formatted PDF file, and should answer the following questions:

  1. Report the native runtime for both optimized and unoptimized versions and compute the speedup from compiler optimization.
  2. Compare the native runtime to the reported runtimes in gem5. Can you explain the differences, if any?
  3. Which CPU model is more sensitive to changing the CPU frequency? Why?
  4. Which CPU model is more sensitive to changing the memory technology? Why?
  5. Is the sim.cc application more sensitive to the CPU model, the memory technology, or CPU frequency? Why?
  6. If you were to use a different application, do you think your conclusions would change? Why?

What to Hand In

  1. Create an archive (.zip, .gz, or .tgz) that contains the statistics files (stats.txt) from your runs of your the sim.cc program in gem5, appropriately named to convey which stats file is from which run.
  2. Additionally, separate from the above archive, create a file named report.pdf that contains a short report with your observations and conclusions from the experiment, including answers to the above questions.

Submit your archive and report to the Dropbox on Canvas.