Gem5 学习指南——基本配置

最近开始系统地学习gem5模拟器了,这个系列主要用于记录学习过程,方便以后回溯。

下面是几个学习网站:

gem5官网

learning gem5 官方的学习向导

计算机体系结构-gem5模拟器入门-知乎

gem5-github

远程连接工作站

组里配了一个工作站,所以首先需要一个SSH环境,这里我选择的是Terminus。

下载地址:https://www.termius.com/

Gem5 学习指南——基本配置_第1张图片

这是微软开发的可以多终端同步的SSH环境,是一款收费软件,好消息是学生可以通过认证github的开发包而免费使用到毕业。

Github学生认证

 第一步:打开认证网站:https://education.github.com/pack 点击Sign up

Gem5 学习指南——基本配置_第2张图片

第二步:点击学生认证,登记学校的邮箱,然后根据提示上传学生证,认证。

第三步:认证完成后在开发包的offers里面选择Terminus,将你的Github账号与Terminus账号绑定

查看服务器硬件配置

这一步主要是方便之后gem5构建,使用命令:

lscpu

硬件配置为:AMD Ryzen Threadripper 3970X 32-Core Processor,64bits的X86架构,具有64线程,32核心,这意味着之后我们在Scons时可以使用-j33(核心数+1)并行构建gem5模拟器。

Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   43 bits physical, 48 bits virtual
CPU(s):                          64
On-line CPU(s) list:             0-63
Thread(s) per core:              2
Core(s) per socket:              32
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model:                           49
Model name:                      AMD Ryzen Threadripper 3970X 32-Core Processor
Stepping:                        0
Frequency boost:                 enabled
CPU MHz:                         2200.000
CPU max MHz:                     4549.1211
CPU min MHz:                     2200.0000
BogoMIPS:                        7386.02
Virtualization:                  AMD-V
L1d cache:                       1 MiB
L1i cache:                       1 MiB
L2 cache:                        16 MiB
L3 cache:                        128 MiB
NUMA node0 CPU(s):               0-63

环境配置:

基本的环境配置可以参考官网:https://www.gem5.org/documentation/learning_gem5/part1/building/

组里的工作站由于限制了sudo权限,在一开始就在服务器上把需要的环境都配置好了,所以这部分不作过多讲解。

有一个问题是在clone的时候记得把官网提供的github地址换成国内的,例如gitee。

git clone https://gitee.com/koverlu/gem5.git

如果你是用的是服务器或者虚拟机的方式构建gem5,建议不要通过在windows下载gem5包然后copy到服务器或者虚拟机的方式获得gem5源代码,可能会遇到权限错误如下:

util/cpt_upgrader.py: Permission denied

如果使用的是个人设备,可以给予sudo权限并继续构建gem5模拟器(直接在linux系统中clone则不会遇到这个问题)。

sudo chmod 777 ./util/cpt_upgrader.py

构建Gem5模拟器

clone完成后会在当前目录下多出一个gem5文件夹,此时需要选择构建gem5模拟器的哪一个版本,详细的描述在官网有介绍:https://www.gem5.org/documentation/learning_gem5/part1/building/

Gem5 学习指南——基本配置_第3张图片

 通常会使用opt这个版本。

接下来使用命令:

scons build/X86/gem5.opt -j33

然后会出现一连串的yes,

scons: Reading SConscript files ...
Checking for linker -Wl,--as-needed support... (cached) yes
Checking for compiler -Wno-free-nonheap-object support... (cached) yes
Checking for compiler -gz support... (cached) yes
Checking for linker -gz support... (cached) yes
Info: Using Python config: python3-config
Checking for C header file Python.h... (cached) yes
Checking Python version... (cached) 3.8.10
Checking for accept(0,0,0) in C++ library None... (cached) yes
Checking for zlibVersion() in C++ library z... (cached) yes
Checking for C library tcmalloc... (cached) yes
Checking for C header file linux/kvm.h... (cached) yes
Checking for timer_create(CLOCK_MONOTONIC, NULL, NULL) in C library None... (cached) no
Checking for timer_create(CLOCK_MONOTONIC, NULL, NULL) in C library rt... (cached) yes
Checking size of struct kvm_xsave ... (cached) yes
Checking for member exclude_host in struct perf_event_attr...(cached) yes
Checking for shm_open("/test", 0, 0) in C library None... (cached) yes
Checking for pkg-config package protobuf... (cached) yes
Checking for GOOGLE_PROTOBUF_VERIFY_VERSION in C++ library protobuf... (cached) yes
Checking for char temp; backtrace_symbols_fd((void *)&temp, 0, 0) in C library None... (cached) yes
Checking for C header file linux/if_tun.h... (cached) yes
Checking for C header file fenv.h... (cached) yes
Checking for C header file png.h... (cached) yes
Checking for clock_nanosleep(0,0,NULL,NULL) in C library None... (cached) yes
Checking for C header file valgrind/valgrind.h... (cached) no
Warning: Deprecated namespaces are not supported by this compiler.
         Please make sure to check the mailing list for deprecation announcements.
Checking for pkg-config package hdf5-serial... (cached) yes
Checking for H5Fcreate("", 0, 0, 0) in C library hdf5... (cached) yes
Checking for H5::H5File("", 0) in C++ library hdf5_cpp... (cached) yes
Checking whether __i386__ is declared... (cached) no
Checking whether __x86_64__ is declared... (cached) yes
Building in /home/liuzx/Gem5/gem5-20220928/gem5/build/X86
Using saved variables file /home/liuzx/Gem5/gem5-20220928/gem5/build/variables/X86
Checking for compiler -Wno-self-assign-overloaded support... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...

大概5分钟之后,会出现提示:

scons: done building targets.

说明构建成功。

接下来的文章将会具体说明使用gem5模拟器进行full system模式运行linux系统。

你可能感兴趣的:(gem5,c++,python)