Multi2sim 是一款较为少见的 CPU-GPU 异构模拟器。其支持多CPU 架构,如 x86、ARM 和MIPS 等。对于 GPU,它支持 AMD 的 southern-islands 架构。由于该模拟器比较古早,其环境配置比较麻烦,本文将采用 Docker 的方式来使用 Multi2sim。
一、Docker的安装
Docker 是一种容器化技术,它可以让你将应用程序及其依赖环境打包成一个“容器”,这样就可以在任何支持 Docker 的系统上运行,而无需担心环境配置问题。
直白地说,Docker 容器就像一个轻量级的虚拟机,但比传统的虚拟机更高效,因为它们共享宿主操作系统的内核。每个容器都包含应用程序运行所需的所有内容,比如代码、库、配置文件等,因此无论在什么系统上运行,都可以保证行为一致。
使用以下命令安装 Docker 并且获取 Multi2sim 资源。从 Dockerhub 的资源来看,目前的 Multi2sim 是最新版的 5.0 版本。
sudo apt install docker.io
docker pull multi2sim/multi2sim
接下来在 Docker 和宿主机之间构建共享路径,此时便可以实现两者之间的通信,而且是即使通信。即宿主机修改路径下的文件,Docker 可以立刻接收到。
# 1. 创建要挂载的本地目录(可选,如果已存在则可以跳过)
mkdir -p /home/multi
# 2. 启动 Docker 容器并挂载目录
sudo docker run -it -v /home/wq/multi2sim:/home/multi multi2sim/multi2sim /bin/bash
# 3. 在容器内检查挂载是否成功
ls /home/multi
二、运行Multi2sim
使用 Docker 的好处就在于无需配置环境以及无需编译,在 Docker 使用 m2s 命令就可以直接运行 Multi2sim。
使用 m2s --help 命令查询使用帮助:
General Multi2Sim Options
=========================--call-debug <file>
Dump debug information related with the CPU context call stacks,
including function invocations and returns.--ctx-config <file>
Use <file> as the context configuration file. This file describes the
initial set of running applications, their arguments, and environment
variables. Use option --ctx-config-help for a description of the context
configuration file format.--esim-debug <file>
Dump debug information related with the event-driven simulation engine.
--inifile-debug <file>
Dump debug information about all processed INI files into the specified
path.--max-time <time> (default = 0)
Maximum simulation time in seconds. The simulator will stop once this
time is exceeded. A value of 0 (default) means no time limit.--trace <file>
Generate a trace file with debug information on the configuration of the
modeled CPUs, GPUs, and memory system, as well as their dynamic
simulation. The trace is a compressed plain-text file in format. The
user should watch the size of the generated trace as simulation runs,
since the trace file can quickly become extremely large.--visual <file>
Run the Multi2Sim Visualization Tool. This option consumes a file
generated with the '--trace' option in a previous simulation. This
option is only available on systems with support for GTK 3.0 or higher.ARM Options
===========--arm-debug-ctx <file>
Dump debug information related with context creation, destruction,
allocation, or state change.--arm-debug-isa <file>
Debug information for dynamic execution of ARM instructions. Updates on
the processor state can be analyzed using this information.--arm-debug-loader <file>
Dump debug information extending the analysis of the ELF program binary.
This information shows which ELF sections and symbols are loaded to the
initial program memory image.--arm-debug-syscall <file>
Debug information for system calls performed by a ARM program,