Accel-Sim Trace 收集工具的使用方法
⚠️ 要收集 trace,必须要有对应型号的硬件设备(也就是显卡!!!)
首先安装 nvbit 工具:
# 安装 nvbit
./install_nvbit.sh
# 编译工具
./make
为测试集套装产生 trace,运行以下命令:
# 为 rodinia 工作负载在硬件设备(显卡)0 上运行 trace 收集器
./run_hw_trace.py -B rodinia-3.1 -D 0
产生的 trace 位于 ../../hw_run/traces/device-0/
。
为特定的单个应用生成 trace:
# 运行 vector add 应用在硬件设备(显卡)0 上运行 trace 收集器
export CUDA_VISIBLE_DEVICES=0
LD_PRELOAD=./tracer_tool/tracer_tool.so ./nvbit_release/test-apps/vectoradd/vectoradd
#LD_PRELOAD=/home/xu/liu/accel-sim-framework-release/util/tracer_nvbit/tracer_tool/tracer_tool.so ./run
产生的 trace 位于 traces
文件夹,该文件夹包含:
- 1 - 核函数 trace 文件(以
.trace
作为扩展名(每个核函数一个文件))。例如:kernel-1.trace
,kernel-2.trace
。 - 2 -
kernelslist
(one file), this contains the kernel files list that have been traced along with the CUDA memcpy commands - 2 -
kernelslist
(一个文件),这个文件包含了使用 CUDA memcpy 命令收集 trace 的核函数文件的列表。 - 3 -
stats.csv
(one file), this contains the statistcs of the kernels, e.g. how many kernels traced, traced intructions, etc. - 3 -
stats.csv
(一个文件),这个文件包含核函数的统计数据,例如:一共收集了多少个核函数的 trace,收集 trace 包括的指令等。
现在,需要对 trace 进行后处理。之前产生的 trace 是非结构化的,我们需要通过线程块(thread block)id 对其进行分组,运行下面的命令:
/home/xu/liu/accel-sim-framework-release/util/tracer_nvbit/tracer_tool/traces-processing/post-traces-processing ./traces/kernelslist
# 删除中间文件 #
rm ./traces/*.trace
cd ..
scp -r $1 xu@10.212.67.3:/mnt/data/xu/accel_traces/$2 # 将 trace 复制到需要的地方
这里有一小段提示信息:.trace files are not required anymore. These are intermediate files and you can delete them to save disk space. Note that the above run_hw_trace.py script do all the steps automatically for you. 说 .trace 是中间文件,运行完之后可以删除以节省磁盘空间。
Accel-Sim 运行单个 kernel 应用
source ./gpu-simulator/setup_environment.sh
./gpu-simulator/bin/release/accel-sim.out -trace ../../accel-sim/accel_traces/backprop/kernelslist.g -config ./gpu-simulator/gpgpu-sim/configs/tested-cfgs/SM86_RTX3070/gpgpusim.config -config ./gpu-simulator/configs/tested-cfgs/SM86_RTX3070/trace.config
这样做的好处:
- 避免让脚本一次性运行所有 bench,导致机器承受不了。
- 可以精细化运行任务的核函数,便于在对模拟器进行修改时快速进行验证。