Zsim
简介
Zsim模拟器是
- 一个快速的x86-64多核模拟器,它利用英特尔Pin工具包收集进程的内存访问跟踪,并在zsim模拟器中重放跟踪。
- 一种基于 PIN 的二进制插桩工具,可以在运行时对指令进行插桩,并插入自定义的函数调用,用于模拟内存子系统的行为。
- 它最初是为了评估ZCache而编写的,但后来它扩展了其功能
- zsim的主要目标是快速,简单和准确,重点是模拟内存层次结构和大型异构系统
模拟器发展的部分比较
- Interval Simulation: Raising the Level of Abstraction in Architectural Simulation(HPCA 2010) 提出Interval Simulation
- Sniper: exploring the level of abstraction for scalable and accurate parallel multi-core simulation(SC’2011)
- 速度:2.0 MIPS when simulating a 16-core system on an 8-core SMP machine.
- Sniper: exploring the level of abstraction for scalable and accurate parallel multi-core simulation(SC’2011)
- ZSim: Fast and Accurate Microarchitectural Simulation of Thousand-Core Systems(ISCA 2013)
- 与sniper的区别
- 模型不同Zsim 是instruction-driven timing models
- OOO scoreboard + uops based ROB (所以需要知道每条uops的execution time)
- 速度
- 单核速度 The combination of DBT and instruction-driven models allows us to achieve 20 MIPS per simulated core, and slowdowns of about 200×. This is faster than Sniper [8], which uses approximate OOO models (though slower memory system simulation likely plays a role in the difference),
- Sniper多核模拟不理想是因为频繁的多核同步,Zsim发现可以记录访存行为集中时间统一同步, 可以做到近线性的加速比
- 与sniper的区别
- An Evaluation of High-Level Mechanistic Core Models 2014, (TACO) 提出instruction-window centric (IW-centric) core model完善了Interval Simulation的细节错误
- 比如将old-new windows替换成ROB,并且关注其内指令依赖
工作原理
利用了X86上的pin来控制进程,但是pin没有开源代码,底层实现不知
Recommended Installations
- It is highly recommended to install the respective open-source Docker versions for your system. [^1]
- Note that the official version, last updated in 2015, is outdated and corresponds to
Ubuntu 12.04
andPin 2.14
. - For an unofficial but improved version that supports
Ubuntu 18.04
andPin 3.7
, you can explore the following link: Ubuntu 18.04 + Pin 3.7.
各版本Zsim开源魔改版本比较
Zsim 魔改版本根据需求有所不同,我接触过的是访存接入HMC 3D堆叠内存,和对地址翻译有支持两类。
- PIM支持:
- TLB + 地址翻译:HSCC
安装:Zsim+tlb
基于Zsim+tlb的版本
STEP1: boost
The Boost C++ libraries are a collection of open-source C++ libraries that provide support for tasks and functionalities commonly used in C++ development. Install-ref
1 | # newest 1.83 not support for missing api, use github specific 1.59 version passed |
STEP2: HDF5
The Hierarchical Data Format version 5 (HDF5) is a data model, library, and file format for storing and managing data. It supports an unlimited variety of datatypes and is designed for flexible and efficient I/O and high volume and complex data.
Install-Ref
1 | wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.2/src/hdf5-1.14.2.tar.gz |
STEP3: zsim+tlb
1 | cd zsim-nvmain |
安装:multipim (failure)
According to github, the multipim seems a combination of Zsim-ramulator +
Booksim2 and HSCC.
1 | # Install |
- check file
env.sh
- replace the include
zsim_hooks.h
path in testcase code tomisc/hooks/zsim_hooks.h
- REPLACE: all
/u/yc9uf/Workspace/MultiPIM
and/home/yuchao/Workspace/PIM/MultiPIM
in project to your path
1 | # Compile Test-case |
Install-problem
aclocal-1.15: command not found
- FIX: add
autoreconf -f -i
before ./configure command
- FIX: add
makeinfo: command not found
- FIX:
sudo apt-get install texinfo
- FIX:
[SKIP] Bug: Pin 2.14 Fails on Ubuntu 20.04.6 LTS (snode6)
- The initial approach was to replace it with zsim-tlb pim (but it turned out to be a bad idea, even for the older Pin version 2.13.)
- after replace the
pin
folder content by../HSCC/zsim-nvmain/pin_kit
, you should reinstall all the multipim fromsh compile.sh opt clean
. (of coursechmod +x bin
) which lead to the same errorPin app terminated abnormally due to signal 6.
- after replace the
- The next idea is try the newest pin version
pin3.28
- First TODO: After repeatedly adding and modifying include files to solve various compilation issues, we encountered even more problems. Maybe we should analyse how pintools include nwest pin head files
- the point is how pintool utilize the newest
CRT (C Runtime)
part code ofpin
- the point is how pintool utilize the newest
- First TODO: After repeatedly adding and modifying include files to solve various compilation issues, we encountered even more problems. Maybe we should analyse how pintools include nwest pin head files
- TODO: We should delve deeper into understanding Pin’s usage of grammar.
Running in docker
Utilizing docker like DAMOV[^1], is an effective approach to circumvent version conflicts between the Linux kernel and tools like Pin.
Here’s a Dockerfile snippet for reference:
1 | FROM gfojunior/damov:latest |
基本使用
app target code instrumentation
1 |
|
It seems hard to simulate command like mpirun -n 32 exe
, even instrumentate the executable file. Because mpirun
start 32 individual processes which will be zombie after interupting the zsim simulation.
there is a slolution
zsim config
配置参考官方
- 问题1: 可执行文件需要在特定目录执行,如何解决
cd PWD; zsim config
- set
env="PWD=xxx"
seems useless
- set
- 问题1导致无法并行,会写同一个目录的文件?
- Can config the
output
directory? default zsim not support, but our version of zsim support this.
- Can config the
zsim模拟多进程的资源冲突
使用zsim的config,可以添加process0和process1,对应两个进程
代码部分阅读
zsim tlb part
基于代码 zsim-nvmain
futex
usage is very helpful- using 4MB page
pgt_walker : mode = "Legacy_Huge";
zsim 异构计算核模拟
https://github.com/s5z/zsim/blob/master/tests/het.cfg
Result file
zsim.out
1 | contention: # Contention simulation stats |
It seems something about event contention according to the blog. And it explains how zsim use a bound-weave model to simulate the event contention(eg. multiple threads access to the cache).
This can be easily understood if you read the zsim paper. The idea is gathering the contention traces to weave phase to be dealed with.
1 | time: # Simulator time breakdown |
the real time simulation about the bound-weave model.
Bugs
zsim-tlb simulation encounter bugs, such as
1 | pinbin: build/opt/zsim.cpp:816: LEVEL_BASE::VOID VdsoCallPoint(LEVEL_VM::THREADID): Assertion `vdsoPatchData[tid].level' failed. |
需要进一步的研究学习
暂无
遇到的问题
- ZSim+Ramulator, 中计算单元是怎么模拟的。
- 如果Zsim是基于Pin,那么怎么模拟计算单元的行为呢?
开题缘由、总结、反思、吐槽~~
参考文献
zsim code implementation details in this blog
[^1]: damov github