前几天配了gem5的环境,过程还是蛮曲折的,下东西慢,自己重装系统也好几次,装好之后也不知道干啥的,就找了gem5的官方文档看了看,这里做一些总结。
gem5是什么
官方文档的说法是:
The gem5 simulator is a modular platform for computer-system architecture research, encompassing system-level architecture as well as processor microarchitecture.
提取出重点包括
- 一个模块化平台
- 用于研究计算机体系结构
- 包括系统级体系结构和处理器微体系结构
看起来好像挺明白的,其实没啥用哈。然后经过之后的学习呢,我暂时的理解,就是这个平台,可以通过代码在上面仿真出计算机硬件,然后进行体系结构方面的设计,就和之前大物仿真实验的平台差不多的用途。再多的理解,就等之后在近一步的学习吧。
文件结构
文档里面有一个专门的tour of tree ,介绍了gem5底下所有目录的用途,不全部赘述,只说下自己用到的几个重要目录。
-
b
u
l
i
d
/
\color{red}{bulid/}
bulid/
包含了构建代码时的工具,用到的有build/X86_VI_hammer_GPU/gem5.opt -
s
r
c
/
\color{red}{src/}
src/
gem5的源码,包括体系结构的各个模块- arch/ :ISA implementations
- base/ :general data structures and facilities that could be useful for another project.
- cpu/ :CPU models
- dev/ :device models
- doxygen/ :doxygen templates & output
- kern/ :operating system specific but architecture independent code
- mem :memory system models and infrastructure
- python/ :python code for configuration and higher level functions
- sim/ :code that implements basic,fundamental simulator functionality
-
c
o
f
i
g
s
/
\color{red}{cofigs/}
cofigs/
模拟器的配置文件,python写的。- boot/
full-system下使用的rcS文件,在linux启动后,由模拟器加载,shell运行。大多用于控制benchmarks。- common/
包括了大量用于创建模拟系统的帮助脚本和函数。- Options.py
包含了很多可以在命令行设置的选项 - CacheConfig.py
包含了用于设置经典缓存系统的缓存参数的选项 - MemConfig.py
提供了设置内存系统的辅助功能 - FSConfig.py
- 包含了许多不同种类的系统设置full-system模拟的必要功能
- Options.py
- dram/
包含了测试DRAM的脚本 - example/
包含了一些gem5配置脚本的实例。 - ruby/
包含了Ruby的配置脚本,还有缓存一致性协议 - splash2/
包含了运行splash2 benchmark suite的脚本 - topologies/
包含了创建Ruby缓存结构是的topologies实现
- common/
- boot/
-
u
s
i
n
g
s
e
.
p
y
a
n
d
f
s
.
p
y
\color{red}{using se.py and fs.py}
usingse.pyandfs.py
讨论这两个文件的选项。
大多数选项都可以在Option.py中找到,在addCommonOptions中注册。运行脚本时使用 --help或者查看脚本源码可以找到所有选项的细节。
例子:
简单地运行,不带任何参数:
build/X86_VI_hammer_GPU/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello
然后查看m5out/config.ini,CPU是AtomicSimpleCPU
build/X86_VI_hammer_GPU/gem5.opt configs/example/se.py --cmd=tests/test-progs/hello/bin/x86/linux/hello --cpu-type=TimingSimpleCPU --l1d_size=64kB --l1i_size=16kB --caches
在查看m5out/config.ini,CPU是TimiSimpleCPU。@ tick 5942000变为了@ tick 31040000。
常用的 common options
- –cpu-type = CPU_TYPE
- –sys-clock = SYS_CLOCK
- –cpu-clock=CPU_CLOCK
- –mem-type=MEM_TYPE
- –caches
- –l2cache
- –ruby
- -m TICKS, --abs-max-tick=TICKS
- -I MAXINSTS, --maxinsts=MAXINSTS
- -c CMD, --cmd=CMD
- -o OPTIONS, --options=OPTIONS
- –output=OUTPUT
- –errout=ERROUT