Computer Architecture 2024 Spring
Final Project Part 1
Overview
Tutorial
-
● Gem5 Introduction
-
● Environment Setup
Projects
● Part 1 (5%)
○ Write C++ program to analyze the specification of L1 data cache. ● Part 2 (5%)
○ Given the hardware specifications, try to get the best performance for more complicated program.
2
Gem5 Introduction
3
What is Gem5 simulator ?
-
● A modular platform for computer-system architecture research.
-
● Can help investigate impact of microarchitechture to applications.
-
● For example, the cache size, cpu and memory architecture could all be
configured.
./build/X86/gem5.opt ./configs/example/fs.py --num-cpu=4 \
--cpu-clock=2GHz \
--caches --l2cache \ --cpu-type=TimeSimpleCPU \--mem-size=4GB \ --mem-type=DDR4_2400_8x8
4
What information can we get and for what?
Timing, memory bandwidth, miss rate, details of executed instructions, etc. ● Timing ● DCache miss rate
You can find this information in stats.txt
● Executed instructions
5
Environment Setup
6
Steps of Environment Setup
TA has already built the Gem5 environment in a Docker Image, all you need to do is install the Docker and download the image.
Steps:
1. Linux installation
2. Docker installation
3. Download Gem5 image
4. Run Gem5 simulation
(If your computer already has Docker, you can skip step 1 & step 2)
7
Step1. Linux installation
● Since Docker needs to run in a Linux environment, if your OS is a Windows, we strongly recommend you install WSL2.
-
(1) Open the command prompt (cmd) and type
$ wsl --install -d Ubuntu
-
(2) Restart your computer
-
(3) Re-open the cmd, type wsl to enter the Linux environment
8
Step2. Docker installation
-
Open your Linux environment
-
Use the following commands to install Docker.
$ curl -fsSL https://get.docker.com -o get-docker.sh $ sudo sh get-docker.sh
3. Add user name to the docker group.
$ sudo gpasswd -a $USER docker $ newgrp docker
9
Step2. Docker installation (option)
● If you want to use the Docker GUI, you can follow the installation steps on this website: https://docs.docker.com/desktop/install/windows-install/
10
Step3. Download Gem5 image
-
● Use the following command to download TA’s Gem5 image (it may takes a few minutes)
$ docker pull yenzu/ca_final:2024
-
● Create and start a container. Only do this the first time.
$ docker run -it --name 2024CA_FP yenzu/ca_final:2024
container_name image_name
11
Step4. Run Gem5 simulation
● Go to home directory and use ./run_system<1|2> <CPP_FILE> to run the simulation.
$ cd /home
$ ./run_system1 example.cpp
● If there is no error in your cpp file, you will get the following text.
You can then go to stats.txt file to find more simulation information.
12
Docker commands
-
● Exit container → use Ctrl+D or type exit
-
● Restart the container
$ docker start 2024CA_FP
$ docker exec -it 2024CA_FP bash
-
● Copy file from container to local (type it outside the container) docker cp 2024CA_FP:<PATH_IN_CONTAINER> <FILE_NAME>
-
● Copy file from local to container (type it outside the container) docker cp <FILE_NAME> 2024CA_FP:<PATH_IN_CONTAINER>
13
Project 1
14
Description
In project1, we have created two simple computer systems, both of which have the same hardware architecture, differing only in the specifications of their L1 data caches.
Your task is to find out the specifications of these two L1 data caches by writing C++ programs. We will show you more detailed information on the next page.
15
System Specifications
-
● ISA: X86
-
● CPU: TimingSimpleCPU (no pipeline, CPU stalls on every memory request)
-
● L1 Cache
I cache size |
I cache associativity |
D cache size |
D cache associativity |
Policy |
Block size |
|
system1 |
16KB |
8 |
||||
system2 |
16KB |
8 |
* I cache and D cache use the same policy and block size ● Memory size: 8192MB
16
Grading Policy
Report
● Complete the table on the previous page. (40%)
○ 8 blanks, each blank 5%.
● For each specification, please make sure your report contain the following
information. (60%)
-
[5%] Show the screenshot of your code and explain your design concept. (i.e. what you
want to measure through this code)
-
[10%] Show your measurement result in a chart format. Please clearly indicate what
information you extracted from the stats.txt file and what you observed from the chart.
○ 4 specs, each spec 15%.
17
Submission
● Please submit your report and code on E3 before 23:59 on May 23, 2024. ● Format
-
○ Report name: FP1_team<ID>_report.pdf
-
○ Code: please put all your code in a folder
named FP1_team<ID>_code and compress it into a zip file with same name.
-
● Late submission is not allowed.
-
● Plagiarism is forbidden, otherwise you will get 0 point!!!
18
FAQ
● What program should I write?
○ We do not limit the content of your program, but if you have no direction, you can refer
to p.35-42 of this slide.
● How to write program in Docker?
○ You can write your program on your local computer and copy it into the Docker
container using docker cp command (see p.13). Or you can use Vim to write the program directly in Docker (see Appendix).
● How to execute my program?
○ Please follow the steps in p.12
19
Appendix – Vim
20
What is Vim?
-
● Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient.
-
● There are many commands in Vim. We will only teach you the most basic ones, while more advanced commands can be found on this website.
21
How to use Vim?
1. Type vim <FILE_NAME> in terminal to open Vim editor. $ vim test.cpp
2. Press button i to enter insert mode
22
How to use Vim?
-
Modify files with keyboard (use ↑↓←→ button to shift the cursor)
-
Press button esc to return to command mode
-
Type :wq , and then press enter to return to terminal
23