1 Zsim 简介
zsim 是一个基于 Pin 的体系结构模拟器,官方描述为:
zsim is a fast x86-64 simulator. It was originally written to evaluate ZCache (Sanchez and Kozyrakis, MICRO-44, Dec 2010), hence the name, but it has since outgrown its purpose. zsim’s main goals are to be fast, simple, and accurate, with a focus on simulating memory hierarchies and large, heterogeneous systems. It is parallel and uses DBT extensively, resulting in speeds of hundreds of millions of instructions/second in a modern multicore host. Unlike conventional simulators, zsim is organized to scale well (almost linearly) with simulated core count.
2 安装环境
由于 zsim 最新版本是 2015 年左右,因此其对安装环境的要求较旧。我的安装环境为:
- Ubuntu 12.04
- Pin 2.14
2.1 Ubuntu 源
由于 ubuntu12.04 已经不被官方维护,因此从网上搜索的很多源是不可用的,经过长时间搜索后,可用源为:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
2.2 Pin 安装
直接解压安装,安装结束后,把 Pin 的路径添加到系统环境变量中
# 临时
export PATH=xxx
# 永久
vi /etc/profile
PATH=xxx
source /etc/profile
其中,XXX 指 pin 的路径
3 Zsim 使用
正确设置 pin 路径后,需要对 zsim 进行编译,具体为:
scons -j8
3.1 error 信息
# error: gm_create failed shmget
# 共享空间不足
sysctl -w kernel.shmmax=8589934592
echo 0 > /proc/sys/kernel/yama/ptrace_scope
3.2 运行
./build/opt/zsim scripts/test.cfg
3.3 Debug
# .cfg 文件
attachDebugger = True;
4 Tips
基于 Ubuntu 18.04 的 Zsim 安装
虽然官方版本是在几年前,但是仍有很多大佬的 Zsim 分支对现有版本进行改进,可以安装到新的版本上,具体的分支为:
Yang-YiFan
非常感谢大佬的无私分享。