Vortex GPGPU的github流程跑通与功能模块波形探索(二)

文章目录


前言

昨天另辟蹊径地去探索了子模块的波形仿真,但找朋友唠嗑发现有可以直接生成vcd格式波形文件的方式。遂,写下此篇,简单记录下。不过今天测试完,发现看子模块波形还是有点不方便,得把引脚拉出来才能看到子模块波形。尽管多少还是有点不方便,但起码有个例子可以参考了 。傻了,信号都在里面。

还是打算再琢磨琢磨子模块直接导出波形。

接下来就结合波形分析模块代码和功能吧!


一、环境配置和debugging.md文档

其实跟昨天那个一样,没有多大改动(就是昨天大改动前没备份,今天重新配了一次环境)

主要还是参考这个文档https://github.com/vortexgpgpu/vortex/blob/master/docs/install_vortex.md

用的是ubuntu18.04镜像,能在vmware上跑通,具体流程如下:

c 复制代码
# step 1. 安装依赖
sudo apt-get install build-essential zlib1g-dev libtinfo-dev libncurses5 uuid-dev libboost-serialization-dev libpng-dev libhwloc-dev

# step 2. 升级到g++-11和gcc-11
# 展开一下,ubuntu18.04默认的gcc和g++版本是7.4,没有11的ppa源,因此只能在添加ppa源以后再进行安装
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update & upgrade
sudo apt install gcc-11 g++-11
# 随后修改gcc和g++运行版本
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11

# step 3. 下载vortex gpgpu包
git clone --depth=1 --recursive https://github.com/vortexgpgpu/vortex.git
# 多提一嘴,这个步骤有点麻烦,国内下载速度慢
# 我用了proxychains4和socks5通过主机代理加速下载,具体怎么配合不能说太多,我贴个链接
# https://blog.csdn.net/weixin_48915167/article/details/136705698
# 加速器方案自个儿确定
# 在有proxychains4的情况下,使用
proxychains4 git clone --depth=1 --recursive https://github.com/vortexgpgpu/vortex.git
# 可以加速下载

# step4. build vortex
cd vortex
mkdir -p build
cd build
../configure --xlen=32 --tooldir=$HOME/tools
#./ci/toolchain_install.sh --all # 这一步略麻烦,需要下载包,否则不太能成功,建议改为如下:
proxychains4 ./ci/toolchain_install.sh --all
source ./ci/toolchain_env.sh
make -s
# 至此环境搭建完毕

官网跑出vcddebugging.md文件如下:

1.1 调试 Vortex GPU

1.1.1测试 RTL 或模拟器 GPU 驱动的更改

如果硬件配置与上次运行时相同,Blackbox 实用脚本将不会检测到您的更改。

要强制实用程序构建驱动程序,您需要在运行测试时传递 --rebuild=1 选项。

使用 --rebuild=0 将阻止重建,即使硬件配置与上次运行不同。

```
$ ./ci/blackbox.sh --driver=simx --app=demo --rebuild=1
```

1.1.2 SimX 调试

SimX 循环近似模拟器允许更快地调试 Vortex 内核的执行。

推荐的方法是在运行程序时向 blackbox 工具传递 --debug=<level> 标志以启用调试。

```
// 在 SimX 上以调试模式运行演示程序
$ ./ci/blackbox.sh --driver=simx --app=demo --debug=1
```

在程序执行期间,在当前目录下生成一个调试跟踪 run.log。跟踪包括模拟处理器的重要状态(解码指令、寄存器状态、流水线状态等)。您可以通过更改调试级别来增加跟踪的详细程度。

```
// 使用 SimX 在调试模式下进行详细级别 3 的调试
$ ./ci/blackbox.sh --driver=simx --app=demo --debug=3
```

1.1.3 RTL 调试

要调试处理器 RTL,您需要使用 VLSIM 或 RTLSIM 驱动程序。VLSIM 模拟完整的处理器,包括 AFU 命令处理器(使用 /rtl/afu/opae/vortex_afu.sv 作为顶层模块)。RTLSIM 仅模拟 Vortex 处理器(使用 /rtl/Vortex.v 作为顶层模块)。

推荐的方法是在运行程序时向 blackbox 工具传递 --debug 标志以启用调试。

```
// 在 opae 模拟器上以调试模式运行演示程序
$ TARGET=opaesim ./ci/blackbox.sh --driver=opae --app=demo --debug=1

// 在 rtlsim 上以调试模式运行演示程序
$ ./ci/blackbox.sh --driver=rtlsim --app=demo --debug=1
```

在程序执行期间,在当前目录下生成一个调试跟踪 run.log。跟踪包括模拟处理器的重要状态(内存、缓存、流水线、停顿等)。在程序执行期间,当前目录下还会生成一个波形跟踪 trace.vcd。您可以使用任何可以打开 VCD 文件的工具来可视化波形跟踪(Modelsim、Quartus、Vivado 等)。GTKwave 是一个很棒的开源示波器分析器,也适用于 VCD 文件。

1.1.4 FPGA 调试

直接调试 FPGA 可能是必要的,以调查 RTL 模拟无法捕获的运行时错误。我们为 Vortex 实现了一个内部示波器分析器,当 FPGA 运行时可以使用。要启用 FPGA 示波器分析器,应该使用 SCOPE=1 标志构建 FPGA 比特流。

```
& cd /hw/syn/opae
$ CONFIGS="-DSCOPE=1" TARGET=fpga make
```

在 FPGA 上运行程序时,您需要向 blackbox 工具传递 --scope 标志。

```
// 在启用了示波器的 FPGA 上运行演示程序
$ ./ci/blackbox.sh --driver=fpga --app=demo --scope
```

在程序执行期间,在当前目录下将生成一个波形跟踪 trace.vcd。这个跟踪包括在 /hw/scripts/scope.json 中定义的一组有限的信号。您可以通过更新 JSON 文件来扩展您的信号选择。

1.1.5 分析 Vortex 跟踪日志

当调试 Vortex RTL 或 SimX 模拟器时,如果跟踪变得非常大,阅读跟踪 run.log 文件可能会令人不知所措。

我们在 ./hw/scripts/trace_csv.py 下提供了一个跟踪清理工具,您可以使用它将大型跟踪转换为包含所有执行指令及其源和目标操作数的 CSV 文件。

```
$ ./ci/blackbox.sh --driver=rtlsim --app=demo --debug=3 --log=run_rtlsim.log
$ ./ci/trace_csv.py -trtlsim run_rtlsim.log -otrace_rtlsim.csv

$ ./ci/blackbox.sh --driver=simx --app=demo --debug=3 --log=run_simx.log
$ ./ci/trace_csv.py -tsimx run_simx.log -otrace_simx.csv

$ diff trace_rtlsim.csv trace_simx.csv
```

CSV 跟踪中的第一列是指令的 UUID(通用唯一标识符),内容按 UUID 排序。

您可以使用 UUID 来跟踪在 RTL 硬件或 SimX 模拟器上运行的相同指令。

如果您想通过比较 CSV 跟踪来使用 SimX 调试您的 RTL 硬件,这将非常有效。

二、跑出波形文件和日志文件

我们使用如下命令:

c 复制代码
// 在 rtlsim 上以调试模式运行演示程序
./ci/blackbox.sh --driver=rtlsim --app=demo --debug=1

得到结果如下:

c 复制代码
root@ubuntu:/home/dention/vortex/build# ./ci/blackbox.sh --driver=rtlsim --app=demo --debug=1
CONFIGS=-DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=4 -DNUM_THREADS=4    
running: DEBUG=1 CONFIGS=-DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=4 -DNUM_THREADS=4     make -C ./ci/../runtime/rtlsim
running: make -C ./ci/../tests/regression/demo run-rtlsim > run.log 2>&1
root@ubuntu:/home/dention/vortex/build# ls
blackbox.rtlsim.cache  blackbox.simx.cache  ci  config.mk  hw  kernel  Makefile  run.log  runtime  sim  tests  trace.vcd

果不其然出现trace.vcdrun.log,使用gtkwave打开看看:

c 复制代码
gtkwave -o trace.vcd

终端显示如下内容:

c 复制代码
root@ubuntu:/home/dention/vortex/build# gtkwave -o trace.vcd 
Gtk-Message: 23:19:11.438: Failed to load module "canberra-gtk-module"

GTKWave Analyzer v3.3.86 (w)1999-2017 BSI

FSTLOAD | Processing 11763 facs.
FSTLOAD | Built 4461 signals and 7302 aliases.
FSTLOAD | Building facility hierarchy tree.
FSTLOAD | Sorting facility hierarchy tree.


但可以看到子模块信号还是太少,不利于整体分析。解决方案是明显的,就是改sv代码,把引脚信号全部拉到top模块里面。尽管操作还是复杂,但不失为一种办法 。没啥问题!

另外再看看run.log文件:

内容确实很多,我复制部分内容:

c 复制代码
make: Entering directory '/home/dention/vortex/build/tests/regression/demo'
LD_LIBRARY_PATH=/home/dention/vortex/build/runtime: VORTEX_DRIVER=rtlsim ./demo -n64
open device connection
CONFIGS: num_threads=4, num_warps=4, num_cores=1, num_clusters=1, socket_size=1, local_mem_base=0xffff0000, num_barriers=2
                   1: cluster0-socket0-core0-execute-lsu0-scheduler-core-rsp: valid=1000, sop=1, eop=1, data={0xb2911cd0, 0x2e1ce6f5, 0xc9ea8cb6, 0x9baf9594}, tag=0x2d9806c71a815a3b3921136c4 (#6266371498832)
                   1: cluster0-socket0-core0-execute-lsu0-scheduler-mem-req-rd: valid=1011, addr={0x211b5b19, 0x01ad9b13, 0x0d7bdb09, 0x06a0d7ee}, ibuf_idx=0, batch_idx=0 (#15901476565582)
                   1: cluster0-socket0-core0-execute-lsu0-scheduler-mem-rsp: valid=1000, data={0xb2911cd0, 0x2e1ce6f5, 0xc9ea8cb6, 0x9baf9594}, ibuf_idx=0, batch_idx=0 (#6266371498832)
                   1: cluster0-socket0-core0-execute-lsu0 Rsp: wid=0, PC=0xad1d9c90, tmask=1000, rd=34, sop=1, eop=1, data={0xb2911cd0, 0x2e1ce6f5, 0xc9ea8cb6, 0x9baf9594}, tag=0x2d9806c71a815a3b3921136c4 (#6266371498832)
                   1: cluster0-socket0-core0-lmem wr-req: req_idx=0, addr=0xb01bfa9, tag=0xa9f46272b86, byteen=b, data=0x09a66b5e (#5839596524995)
                   1: cluster0-socket0-core0-lmem rd-rsp: req_idx=0, tag=0x1847b287eaee, data=0x0 (#13348108498295)
                   1: cluster0-socket0-core0-fetch req: wid=3, PC=0x9df71fbe, tmask=0101 (#15048647525781)
                   1: cluster0-socket0-core0-commit: wid=0, PC=0x3f21b19c, ex=LSU, tmask=0111, wb=1, rd=15, sop=1, eop=0, data={0xd6162ae9, 0xfce4f3e5, 0xa39414f9, 0xff93a710} (#14919940279918)
                   1: cluster0-socket0-core0-issue0 wid=2, PC=0xb34b4dc4, ex=FPU, op=FCVT.WU.S, tmask=0101, wb=0, rd=4, rs1_data={0xb9c434c3, 0x821b50e3, 0xbd4ff2d8, 0x497ab619}, rs2_data={0xfbc1199f, 0xbd29f7c5, 0x739a3358, 0x41a322b6}, rs3_data={0xa4e814ee, 0xdce0a093, 0x86310bb9, 0x81ccea89}, fmt=0x0, frm=0x6 (#10157724225657)
                   3: cluster0-socket0-dcache0 core-wr-req: addr=0xe1ba9240, tag=0x21441e1f66c1, req_idx=0, byteen=0000, data=0x3407d50e5adeeaa388a89927590f2118 (#9144111716784)
                   3: cluster0-socket0-core0-lmem rd-rsp: req_idx=0, tag=0xa9c00b84b7a, data=0x0 (#5832571626941)
                   3: cluster0-socket0-core0-coalescer0-out-req-wr: valid=0, addr={0xe1ba924}, atype={111}, byteen={0x0000}, data={0x3407d50e5adeeaa388a89927590f2118}, offset={0, 3, 0, 1}, pmask=0000, tag=0x21441e1f66c1 (#9144111716784)
                   3: cluster0-socket0-core0-commit: wid=0, PC=0xb3ccb642, ex=SFU, tmask=1111, wb=0, rd=53, sop=0, eop=0, data={0xb7bb7551, 0xe62dff9d, 0x9940c52f, 0x4cacda6a} (#11419158434087)
                   3: cluster0-socket0-core0-issue0 wid=0, PC=0xfbbbfaf8, ex=LSU, op=FSD, tmask=1111, wb=1, rd=53, rs1_data={0x5d6bf8a8, 0x1695ab67, 0x705b24e1, 0x271ecdea}, rs2_data={0xd811c13d, 0x59322eb, 0xc4a23e97, 0x30cfe099}, rs3_data={0x58d9ecde, 0x1ff81b1e, 0x177b5869, 0xf02ae9a6}, offset=0x956 (#2532625589879)
                   5: cluster0-socket0-core0-commit: wid=2, PC=0x12ebd040, ex=FPU, tmask=0110, wb=1, rd=12, sop=1, eop=1, data={0xabb3d6c4, 0x43068626, 0x7ea9351f, 0x41cbd8bb} (#14284082376393)
                   5: cluster0-socket0-core0-issue0 wid=0, PC=0x10389b0, ex=FPU, op=FCVT.S.D, tmask=0101, wb=1, rd=39, rs1_data={0x616c205d, 0xf7b84b92, 0xf93a1f0f, 0x94b32b97}, rs2_data={0x8cd065a8, 0xfe10a0d4, 0xcf05a5c1, 0xc4958570}, rs3_data={0xd321a039, 0x19427b9f, 0x3b93af7, 0xeb3fa6cd}, fmt=0x0, frm=0x2 (#17591375243918)
                   7: cluster0-socket0-dcache0 mem-wr-req: addr=0xe1ba9240, tag=0x10a20f0fb3603, byteen=0000000000000000, data=0x980f46c0088357e9ab0567413e8ca313ce6e7ce19d50d1232fd1aca27533540ed5074e1f1a0f0e76491e759dd36e3a6a3407d50e5adeeaa388a89927590f2118 (#9144111716784)
                   7: cluster0-socket0-core0-fetch req: wid=0, PC=0xebe2bc9a, tmask=0001 (#0)
                   9: cluster0-socket0-core0-commit: wid=0, PC=0xad1d9c90, ex=LSU, tmask=1000, wb=0, rd=34, sop=1, eop=1, data={0xd0861f27, 0x8b5a99d7, 0x2f249119, 0x5d86c0b4} (#6266371498832)
[VXDRV] DEV_OPEN: hdevice=0x55e052c6f7c0
[VXDRV] DCR_WRITE: hdevice=0x55e052c6f7c0, addr=0x1, value=0x80000000
                  17: base-dcr: state=STARTUP_ADDR0, data=0x80000000
[VXDRV] DCR_WRITE: hdevice=0x55e052c6f7c0, addr=0x2, value=0x0
                  19: base-dcr: state=STARTUP_ADDR1, data=0x00000000
[VXDRV] DCR_WRITE: hdevice=0x55e052c6f7c0, addr=0x3, value=0x0
                  21: base-dcr: state=STARTUP_ARG0, data=0x00000000
[VXDRV] DCR_WRITE: hdevice=0x55e052c6f7c0, addr=0x4, value=0x0
                  23: base-dcr: state=STARTUP_ARG1, data=0x00000000
[VXDRV] DCR_WRITE: hdevice=0x55e052c6f7c0, addr=0x5, value=0x0
                  25: base-dcr: state=MPM_CLASS, data=0x00000000
[VXDRV] DEV_CAPS: hdevice=0x55e052c6f7c0, caps_id=3, value=1
[VXDRV] DEV_CAPS: hdevice=0x55e052c6f7c0, caps_id=2, value=4
[VXDRV] DEV_CAPS: hdevice=0x55e052c6f7c0, caps_id=1, value=4
data type: float
number of points: 1024
buffer size: 4096 bytes
allocate device memory
[VXDRV] MEM_ALLOC: hdevice=0x55e052c6f7c0, size=4096, flags=0x1, hbuffer=0x55e053017910
[VXDRV] MEM_ADDRESS: hbuffer=0x55e053017910, address=0x10000
[VXDRV] MEM_ALLOC: hdevice=0x55e052c6f7c0, size=4096, flags=0x1, hbuffer=0x55e053017970
[VXDRV] MEM_ADDRESS: hbuffer=0x55e053017970, address=0x11000
[VXDRV] MEM_ALLOC: hdevice=0x55e052c6f7c0, size=4096, flags=0x2, hbuffer=0x55e0530179d0
[VXDRV] MEM_ADDRESS: hbuffer=0x55e0530179d0, address=0x12000
dev_src0=0x10000
dev_src1=0x11000
dev_dst=0x12000
allocate host buffers
upload source buffer0
[VXDRV] COPY_TO_DEV: hbuffer=0x55e053017910, host_addr=0x55e0530179f0, dst_offset=0, size=4096
upload source buffer1
[VXDRV] COPY_TO_DEV: hbuffer=0x55e053017970, host_addr=0x55e053018a00, dst_offset=0, size=4096
upload program
[VXDRV] MEM_RESERVE: hdevice=0x55e052c6f7c0, address=0x80000000, size=29260, flags=0x0, hbuffer=0x55e053025fe0
[VXDRV] MEM_ACCESS: hbuffer=0x55e053025fe0, offset=0, size=29232, flags=1
[VXDRV] MEM_ACCESS: hbuffer=0x55e053025fe0, offset=29232, size=28, flags=3
[VXDRV] COPY_TO_DEV: hbuffer=0x55e053025fe0, host_addr=0x55e05301ecd0, dst_offset=0, size=29232
upload kernel argument
[VXDRV] MEM_ALLOC: hdevice=0x55e052c6f7c0, size=32, flags=0x1, hbuffer=0x55e05301cdd0
[VXDRV] COPY_TO_DEV: hbuffer=0x55e05301cdd0, host_addr=0x55e0528711a0, dst_offset=0, size=32
start device
[VXDRV] START: hdevice=0x55e052c6f7c0, hkernel=0x55e053025fe0, harguments=0x55e05301cdd0
                  27: base-dcr: state=STARTUP_ADDR0, data=0x80000000
                  29: base-dcr: state=STARTUP_ADDR1, data=0x00000000
                  31: base-dcr: state=STARTUP_ARG0, data=0x00013000
                  33: base-dcr: state=STARTUP_ARG1, data=0x00000000
wait for completion
[VXDRV] READY_WAIT: hdevice=0x55e052c6f7c0, timeout=86400000
34: [sim] run()
                  45: cluster0-socket0-core0-fetch req: wid=0, PC=0x80000000, tmask=0001 (#0)
                 559: cluster0-socket0-icache0 core-rd-req: addr=0x80000000, tag=0x0, req_idx=0 (#0)
                 565: cluster0-socket0-icache0 mem-rd-req: addr=0x80000000, tag=0x0 (#0)
                 567: MEM Rd Req: addr=0x80000000, tag=0x0, byteen=0xffffffffffffffff
                 567: l3cache mem-rd-req: addr=0x80000000, tag=0x0 (#0)
                 567: l3cache core-rd-req: addr=0x80000000, tag=0x0, req_idx=0 (#0)
                 567: cluster0-l2cache mem-rd-req: addr=0x80000000, tag=0x0 (#0)
                 567: cluster0-l2cache core-rd-req: addr=0x80000000, tag=0x0, req_idx=0 (#0)
                 607: MEM Rd Rsp: tag=0x0, data=0x14c000ef0002800bfff002930062900b14c3031300000317fc1022f30002800b00100293118000ef0002800bfff002930062900b15c3031300000317fc1022f3
                 607: l3cache mem-rd-rsp: tag=0x0, data=0x14c000ef0002800bfff002930062900b14c3031300000317fc1022f30002800b00100293118000ef0002800bfff002930062900b15c3031300000317fc1022f3 (#0)
                 607: l3cache core-rd-rsp: tag=0x0, req_idx=0, data=0x14c000ef0002800bfff002930062900b14c3031300000317fc1022f30002800b00100293118000ef0002800bfff002930062900b15c3031300000317fc1022f3 (#0)
                 607: cluster0-l2cache mem-rd-rsp: tag=0x0, data=0x14c000ef0002800bfff002930062900b14c3031300000317fc1022f30002800b00100293118000ef0002800bfff002930062900b15c3031300000317fc1022f3 (#0)
                 607: cluster0-l2cache core-rd-rsp: tag=0x0, req_idx=0, data=0x14c000ef0002800bfff002930062900b14c3031300000317fc1022f30002800b00100293118000ef0002800bfff002930062900b15c3031300000317fc1022f3 (#0)
                 609: cluster0-socket0-icache0 mem-rd-rsp: tag=0x0, data=0x14c000ef0002800bfff002930062900b14c3031300000317fc1022f30002800b00100293118000ef0002800bfff002930062900b15c3031300000317fc1022f3 (#0)
                 619: cluster0-socket0-icache0 core-rd-rsp: tag=0x0, req_idx=0, data=0xfc1022f3 (#0)
                 619: cluster0-socket0-core0-fetch rsp: wid=0, PC=0x80000000, tmask=0001, instr=0xfc1022f3 (#0)
                 619: cluster0-socket0-core0-decode: wid=0, PC=0x80000000, instr=0xfc1022f3, ex=SFU, op=CSRRS, tmask=0001, wb=1, rd=5, rs1=0, rs2=0, rs3=0, opds=1100, addr=0xfc1, use_imm=0, imm=0x15 (#0)
                 623: cluster0-socket0-core0-fetch req: wid=0, PC=0x80000004, tmask=0001 (#1)
                 625: cluster0-socket0-icache0 core-rd-req: addr=0x80000004, tag=0x4, req_idx=0 (#1)
                 631: cluster0-socket0-icache0 core-rd-rsp: tag=0x4, req_idx=0, data=0x00000317 (#1)
                 631: cluster0-socket0-core0-fetch rsp: wid=0, PC=0x80000004, tmask=0001, instr=0x317 (#1)
                 631: cluster0-socket0-core0-decode: wid=0, PC=0x80000004, instr=0x317, ex=ALU, op=AUIPC, tmask=0001, wb=1, rd=6, rs1=0, rs2=0, rs3=0, opds=1000, use_PC=1, use_imm=1, imm=0x0 (#1)
                 635: cluster0-socket0-core0-fetch req: wid=0, PC=0x80000008, tmask=0001 (#2)
                 637: cluster0-socket0-icache0 core-rd-req: addr=0x80000008, tag=0x8, req_idx=0 (#2)
                 637: cluster0-socket0-core0-issue0 wid=0, PC=0x80000000, ex=SFU, op=CSRRS, tmask=0001, wb=1, rd=5, rs1_data={0x0, 0x0, 0x0, 0x0}, rs2_data={0x0, 0x0, 0x0, 0x0}, rs3_data={0x0, 0x0, 0x0, 0x0}, addr=0xfc1, use_imm=0, imm=0x15 (#0)
                 643: cluster0-socket0-icache0 core-rd-rsp: tag=0x8, req_idx=0, data=0x15c30313 (#2)
                 643: cluster0-socket0-core0-fetch rsp: wid=0, PC=0x80000008, tmask=0001, instr=0x15c30313 (#2)
                 643: cluster0-socket0-core0-decode: wid=0, PC=0x80000008, instr=0x15c30313, ex=ALU, op=ADDI, tmask=0001, wb=1, rd=6, rs1=6, rs2=0, rs3=0, opds=1100, use_PC=0, use_imm=1, imm=0x15c (#2)
                 647: cluster0-socket0-core0-fetch req: wid=0, PC=0x8000000c, tmask=0001 (#3)
                 649: cluster0-socket0-icache0 core-rd-req: addr=0x8000000c, tag=0xc, req_idx=0 (#3)
                 649: cluster0-socket0-core0-commit: wid=0, PC=0x80000000, ex=SFU, tmask=0001, wb=1, rd=5, sop=1, eop=1, data={0x4, 0x4, 0x4, 0x4} (#0)
                 649: cluster0-socket0-core0-issue0 wid=0, PC=0x80000004, ex=ALU, op=AUIPC, tmask=0001, wb=1, rd=6, rs1_data={0x0, 0x0, 0x0, 0x0}, rs2_data={0x0, 0x0, 0x0, 0x0}, rs3_data={0x0, 0x0, 0x0, 0x0}, use_PC=1, use_imm=1, imm=0x0 (#1)
                 655: cluster0-socket0-icache0 core-rd-rsp: tag=0xc, req_idx=0, data=0x0062900b (#3)
                 655: cluster0-socket0-core0-fetch rsp: wid=0, PC=0x8000000c, tmask=0001, instr=0x62900b (#3)
                 655: cluster0-socket0-core0-decode: wid=0, PC=0x8000000c, instr=0x62900b, ex=SFU, op=WSPAWN, tmask=0001, wb=0, rd=0, rs1=5, rs2=6, rs3=0, opds=0110 (#3)
                 657: cluster0-socket0-core0-commit: wid=0, PC=0x80000004, ex=ALU, tmask=0001, wb=1, rd=6, sop=1, eop=1, data={0x80000004, 0x80000004, 0x80000004, 0x80000004} (#1)
                 673: cluster0-socket0-core0-issue0 wid=0, PC=0x80000008, ex=ALU, op=ADDI, tmask=0001, wb=1, rd=6, rs1_data={0x0, 0x0, 0x0, 0x80000004}, rs2_data={0x0, 0x0, 0x0, 0x0}, rs3_data={0x0, 0x0, 0x0, 0x0}, use_PC=0, use_imm=1, imm=0x15c (#2)
                 681: cluster0-socket0-core0-commit: wid=0, PC=0x80000008, ex=ALU, tmask=0001, wb=1, rd=6, sop=1, eop=1, data={0x15c, 0x15c, 0x15c, 0x80000160} (#2)
                 697: cluster0-socket0-core0-issue0 wid=0, PC=0x8000000c, ex=SFU, op=WSPAWN, tmask=0001, wb=0, rd=0, rs1_data={0x0, 0x0, 0x0, 0x4}, rs2_data={0x0, 0x0, 0x0, 0x80000160}, rs3_data={0x0, 0x0, 0x0, 0x0} (#3)
                 709: cluster0-socket0-core0-commit: wid=0, PC=0x8000000c, ex=SFU, tmask=0001, wb=0, rd=0, sop=1, eop=1, data={0x0, 0x0, 0x0, 0x0} (#3)
                 711: cluster0-socket0-core0-fetch req: wid=0, PC=0x80000010, tmask=0001 (#4)
                 713: cluster0-socket0-icache0 core-rd-req: addr=0x80000010, tag=0x10, req_idx=0 (#4)
                 713: cluster0-socket0-core0-fetch req: wid=1, PC=0x80000160, tmask=0001 (#4294967296)
                 715: cluster0-socket0-icache0 core-rd-req: addr=0x80000160, tag=0x400000001, req_idx=0 (#4294967296)
                 715: cluster0-socket0-core0-fetch req: wid=2, PC=0x80000160, tmask=0001 (#8589934592)
                 717: cluster0-socket0-icache0 core-rd-req: addr=0x80000160, tag=0x800000002, req_idx=0 (#8589934592)
                 717: cluster0-socket0-core0-fetch req: wid=3, PC=0x80000160, tmask=0001 (#12884901888)
                 719: cluster0-socket0-icache0 core-rd-req: addr=0x80000160, tag=0xc00000003, req_idx=0 (#12884901888)
                 719: cluster0-socket0-icache0 core-rd-rsp: tag=0x10, req_idx=0, data=0xfff00293 (#4)
                 719: cluster0-socket0-core0-fetch rsp: wid=0, PC=0x80000010, tmask=0001, instr=0xfff00293 (#4)
                 719: cluster0-socket0-core0-decode: wid=0, PC=0x80000010, instr=0xfff00293, ex=ALU, op=ADDI, tmask=0001, wb=1, rd=5, rs1=0, rs2=0, rs3=0, opds=1100, use_PC=0, use_imm=1, imm=0xffffffff (#4)
                 721: cluster0-socket0-icache0 mem-rd-req: addr=0x80000140, tag=0x1 (#0)
                 723: MEM Rd Req: addr=0x80000140, tag=0x400000000000, byteen=0xffffffffffffffff
                 723: l3cache mem-rd-req: addr=0x80000140, tag=0x400000000000 (#1099511627776)
                 723: l3cache core-rd-req: addr=0x80000140, tag=0x400000000000, req_idx=0 (#1099511627776)
                 723: cluster0-l2cache mem-rd-req: addr=0x80000140, tag=0x400000000000 (#1099511627776)
                 723: cluster0-l2cache core-rd-req: addr=0x80000140, tag=0x400000000000, req_idx=0 (#1099511627776)
                 723: cluster0-socket0-core0-fetch req: wid=0, PC=0x80000014, tmask=0001 (#5)
                 725: cluster0-socket0-icache0 core-rd-req: addr=0x80000014, tag=0x14, req_idx=0 (#5)
                 731: cluster0-socket0-icache0 core-rd-rsp: tag=0x14, req_idx=0, data=0x0002800b (#5)
                 731: cluster0-socket0-core0-fetch rsp: wid=0, PC=0x80000014, tmask=0001, instr=0x2800b (#5)
                 731: cluster0-socket0-core0-decode: wid=0, PC=0x80000014, instr=0x2800b, ex=SFU, op=TMC, tmask=0001, wb=0, rd=0, rs1=5, rs2=0, rs3=0, opds=0100 (#5)
                 737: cluster0-socket0-core0-issue0 wid=0, PC=0x80000010, ex=ALU, op=ADDI, tmask=0001, wb=1, rd=5, rs1_data={0x0, 0x0, 0x0, 0x0}, rs2_data={0x0, 0x0, 0x0, 0x0}, rs3_data={0x0, 0x0, 0x0, 0x0}, use_PC=0, use_imm=1, imm=0xffffffff (#4)
                 745: cluster0-socket0-core0-commit: wid=0, PC=0x80000010, ex=ALU, tmask=0001, wb=1, rd=5, sop=1, eop=1, data={0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff} (#4)
                 761: cluster0-socket0-core0-issue0 wid=0, PC=0x80000014, ex=SFU, op=TMC, tmask=0001, wb=0, rd=0, rs1_data={0x0, 0x0, 0x0, 0xffffffff}, rs2_data={0x0, 0x0, 0x0, 0x0}, rs3_data={0x0, 0x0, 0x0, 0x0} (#5)
                 763: MEM Rd Rsp: tag=0x400000000000, data=0x00c000ef0002800bfff00293000080670000000bfc9ff0ef0002800bfff0029300008067005202330fc2021300007217026282b301c003134061013300d29313
                 763: l3cache mem-rd-rsp: tag=0x400000000000, data=0x00c000ef0002800bfff00293000080670000000bfc9ff0ef0002800bfff0029300008067005202330fc2021300007217026282b301c003134061013300d29313 (#1099511627776)
                 763: l3cache core-rd-rsp: tag=0x400000000000, req_idx=0, data=0x00c000ef0002800bfff00293000080670000000bfc9ff0ef0002800bfff0029300008067005202330fc2021300007217026282b301c003134061013300d29313 (#1099511627776)
                 763: cluster0-l2cache mem-rd-rsp: tag=0x400000000000, data=0x00c000ef0002800bfff00293000080670000000bfc9ff0ef0002800bfff0029300008067005202330fc2021300007217026282b301c003134061013300d29313 (#1099511627776)
                 763: cluster0-l2cache core-rd-rsp: tag=0x400000000000, req_idx=0, data=0x00c000ef0002800bfff00293000080670000000bfc9ff0ef0002800bfff0029300008067005202330fc2021300007217026282b301c003134061013300d29313 (#1099511627776)
                 765: cluster0-socket0-icache0 mem-rd-rsp: tag=0x1, data=0x00c000ef0002800bfff00293000080670000000bfc9ff0ef0002800bfff0029300008067005202330fc2021300007217026282b301c003134061013300d29313 (#0)
                 773: cluster0-socket0-core0-fetch req: wid=0, PC=0x80000018, tmask=1111 (#6)
                 773: cluster0-socket0-core0-commit: wid=0, PC=0x80000014, ex=SFU, tmask=0001, wb=0, rd=0, sop=1, eop=1, data={0x0, 0x0, 0x0, 0x0} (#5)
                 775: cluster0-socket0-icache0 core-rd-req: addr=0x80000018, tag=0x18, req_idx=0 (#6)
                 775: cluster0-socket0-icache0 core-rd-rsp: tag=0x400000001, req_idx=0, data=0xfff00293 (#4294967296)
                 775: cluster0-socket0-core0-fetch rsp: wid=1, PC=0x80000160, tmask=0001, instr=0xfff00293 (#4294967296)
                 775: cluster0-socket0-core0-decode: wid=1, PC=0x80000160, instr=0xfff00293, ex=ALU, op=ADDI, tmask=0001, wb=1, rd=5, rs1=0, rs2=0, rs3=0, opds=1100, use_PC=0, use_imm=1, imm=0xffffffff (#4294967296)

用它提供的命令尝试转化为.csv文件试试:

c 复制代码
./ci/trace_csv.py -trtlsim run.log -otrace_rtlsim.csv

顺利得到.csv文件:

c 复制代码
root@ubuntu:/home/dention/vortex/build# ./ci/trace_csv.py -trtlsim run.log -otrace_rtlsim.csv
root@ubuntu:/home/dention/vortex/build# ls
blackbox.rtlsim.cache  ci         hw      Makefile  runtime  tests             trace.vcd
blackbox.simx.cache    config.mk  kernel  run.log   sim      trace_rtlsim.csv  trace.vcd.fst

还是比较直观的,按照PC指令顺序列出每条具体的指令。

对于opae模式来说,指令差不多:

c 复制代码
root@ubuntu:/home/dention/vortex/build# TARGET=opaesim ./ci/blackbox.sh --driver=opae --app=demo --debug=1
CONFIGS=-DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=4 -DNUM_THREADS=4    
running: DEBUG=1 CONFIGS=-DNUM_CLUSTERS=1 -DNUM_CORES=1 -DNUM_WARPS=4 -DNUM_THREADS=4     make -C ./ci/../runtime/opae
/home/dention/vortex/sim/opaesim/opae_sim.cpp:40: warning: "MEMORY_BANKS" redefined
   40 |     #define MEMORY_BANKS PLATFORM_PARAM_LOCAL_MEMORY_BANKS
      | 
In file included from /home/dention/vortex/sim/common/mem.h:23,
                 from /home/dention/vortex/sim/opaesim/opae_sim.cpp:25:
/home/dention/vortex/build/hw/VX_config.h:727: note: this is the location of the previous definition
  727 | #define MEMORY_BANKS 8
      | 
running: make -C ./ci/../tests/regression/demo run-opae > run.log 2>&1


root@ubuntu:/home/dention/vortex/build# ./ci/trace_csv.py -trtlsim run_opae.log -otrace_opae.csv
root@ubuntu:/home/dention/vortex/build# ls
blackbox.opae.cache    blackbox.simx.cache  config.mk  kernel    run_opae.log    runtime  tests           trace_opae.vcd    trace_rtlsim.vcd
blackbox.rtlsim.cache  ci                   hw         Makefile  run_rtlsim.log  sim      trace_opae.csv  trace_rtlsim.csv  trace.vcd.fst

还剩下一个基于模拟器的simx就不演示了。


总结

不总结了!工具准备好了就开始分析代码吧!

相关推荐
DentionY1 个月前
Vortex GPGPU的github流程跑通与功能模块波形探索
架构开发·profiler·gpu架构设计·波形仿真