Computer Architecture
2024 Spring
Final Project Part 1Overview
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.
2Gem5 Introduction
3What 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
4What information can we get and for what?
Timing, memory bandwidth, miss rate, details of executed instructions, etc.
● Timing ● DCache miss rate
● Executed instructions
You can find this information in stats.txt
5Environment Setup
6Steps 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● 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
(2) Restart your computer
(3) Re-open the cmd, type wsl to enter the Linux environment
Step1. Linux installation
$ wsl --install -d Ubuntu
8Step2. Docker installation
1. Open your Linux environment
2. Use the following commands to install Docker.
3. Add user name to the docker group.
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo gpasswd -a $USER docker
$ newgrp docker
9Step2. 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/
10Step3. Download Gem5 image
● Use the following command to download TA’s Gem5 image
(it may takes a few minutes)
● Create and start a container. Only do this the first time.
$ docker pull yenzu/ca_final:2024
$ docker run -it --name 2024CA_FP yenzu/ca_final:2024
container_name image_name
11● Go to home directory and use ./run_system<1|2> <CPP_FILE> to run the
simulation.
● 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.
Step4. Run Gem5 simulation
$ cd /home
$ ./run_system1 example.cpp
12● Exit container → use Ctrl+D or type exit
● Restart the container
● Copy file from container to local (type it outside the container)
● Copy file from local to container (type it outside the container)
Docker commands
$ docker start 2024CA_FP
$ docker exec -it 2024CA_FP bash
docker cp 2024CA_FP:<PATH_IN_CONTAINER> <FILE_NAME>
docker cp <FILE_NAME> 2024CA_FP:<PATH_IN_CONTAINER>
13Project 1
14In 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.
Description
15System Specifications
● ISA: X86
● CPU: TimingSimpleCPU (no pipeline, CPU stalls on every memory request)
● L1 Cache
* I cache and D cache use the same policy and block size
● Memory size: 8192MB
16
I cache
size
I cache
associativity
D cache
size
D cache
associativity Policy Block size
system1 16KB 8
system2 16KB 8Grading 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%)
a. [5%] Show the screenshot of your code and explain your design concept. (i.e. what you
want to measure through this code)
b. [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%.
17Submission
● Please submit your report and code on E3 before 23:59 on May 23, 2024.
● Late submission is not allowed.
● Plagiarism is forbidden, otherwise you will get 0 point!!!
18
● 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.● 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
FAQ
19Appendix – Vim
20What is Vim?
21
● 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.1. Type vim <FILE_NAME> in terminal to open Vim editor.
2. Press button i to enter insert mode
How to use Vim?
22
$ vim test.cpp3. Modify files with keyboard (use ↑↓←→ button to shift the cursor)
4. Press button esc to return to command mode
5. Type :wq , and then press enter to return to terminal
How to use Vim?
23
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。