plctlab/PLCT-Open-Reports

gem5 RISCV-Vector-Engine 运行时部分算子未找到

Closed this issue · 3 comments

仓库 gem5向量扩展
环境 WSL2 Ubuntu20.04
Python Python2.7.18
分支 develop
Commit 692bcd05441baeb49482015f767b61d92eef5dc3

在运行benchmark时(blackscholes_vector.exe),遇到了以下警告:算子的运算单元未找到

warn: CheckedInt already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
warn: Enum already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
warn: ScopedEnum already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 version [DEVELOP-FOR-V20.1]
gem5 compiled Jan  6 2022 17:53:18
gem5 started Jan  7 2022 10:01:00
gem5 executing on DESKTOP-9F2JKA5, pid 1176
command line: /mnt/d/AC/gem5/build/RISCV/gem5.opt /mnt/d/AC/gem5/configs/example/riscv_vector_engine.py '--cmd=/mnt/d/AC/gem5/riscv-vectorized-benchmark-suite/_jacobi-2d/bin/jacobi-2d_vector.exe 1 /mnt/d/AC/gem5/riscv-vectorized-benchmark-suite/_jacobi-2d/input/in_256.input output_vector.txt'

Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (32768 Mbytes) does not match the address range assigned (2048 Mbytes)
warn: Unknown operating system; assuming Linux.
warn: No functional unit for OpClass VectorArith1Src
warn: No functional unit for OpClass VectorArith2Src
warn: No functional unit for OpClass VectorArith3Src
warn: No functional unit for OpClass VectorMaskLogical
warn: No functional unit for OpClass VectorReduction
warn: No functional unit for OpClass VectorConvertIntToFP
warn: No functional unit for OpClass VectorConvertFPToInt
warn: No functional unit for OpClass VectorWConvertFPToInt
warn: No functional unit for OpClass VectorWConvertIntToFP
warn: No functional unit for OpClass VectorWConvertFPToFP
warn: No functional unit for OpClass VectorNConvertFPToInt
warn: No functional unit for OpClass VectorNConvertIntToFP
warn: No functional unit for OpClass VectorNConvertFPToFP
warn: No functional unit for OpClass VectorFPCompare
warn: No functional unit for OpClass VectorIntCompare
warn: No functional unit for OpClass VectorSlideUp
warn: No functional unit for OpClass VectorSlideDown
warn: No functional unit for OpClass VectorToScalar
warn: No functional unit for OpClass VectorMemoryLoad
warn: No functional unit for OpClass VectorMemoryStore
warn: No functional unit for OpClass VectorConfig
0: system.remote_gdb: listening for remote gdb on port 7000

分析运行结束后的stats.txt时,却发现这些算子是有被调用的

system.cpu.op_class_0::VectorArith1Src           1600      0.01%     98.47% # Class of committed instruction
system.cpu.op_class_0::VectorArith2Src         227200      0.96%     99.43% # Class of committed instruction
system.cpu.op_class_0::VectorArith3Src          62400      0.26%     99.69% # Class of committed instruction
system.cpu.op_class_0::VectorMaskLogical            0      0.00%     99.69% # Class of committed instruction
system.cpu.op_class_0::VectorReduction              0      0.00%     99.69% # Class of committed instruction
system.cpu.op_class_0::VectorConvertIntToFP         6400      0.03%     99.72% # Class of committed instruction
system.cpu.op_class_0::VectorConvertFPToInt         9600      0.04%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorWConvertFPToInt            0      0.00%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorWConvertIntToFP            0      0.00%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorWConvertFPToFP            0      0.00%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorNConvertFPToInt            0      0.00%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorNConvertIntToFP            0      0.00%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorNConvertFPToFP            0      0.00%     99.76% # Class of committed instruction
system.cpu.op_class_0::VectorFPCompare          11200      0.05%     99.81% # Class of committed instruction
system.cpu.op_class_0::VectorIntCompare          1600      0.01%     99.82% # Class of committed instruction
system.cpu.op_class_0::VectorSlideUp                0      0.00%     99.82% # Class of committed instruction
system.cpu.op_class_0::VectorSlideDown              0      0.00%     99.82% # Class of committed instruction
system.cpu.op_class_0::VectorToScalar               0      0.00%     99.82% # Class of committed instruction
system.cpu.op_class_0::VectorMemoryLoad          9600      0.04%     99.86% # Class of committed instruction
system.cpu.op_class_0::VectorMemoryStore         1600      0.01%     99.86% # Class of committed instruction
system.cpu.op_class_0::VectorConfig             32000      0.14%    100.00% # Class of committed instruction

请问这些数据是否能表明这些算子是真实被调用的(即是否可靠的?)?并且警告该如何解决(比如:是否需要切换commit?)?

统计的数据真实可靠,Vector Engine在执行过程中,准确地记录了每类运算的实际执行次数。这个Warning对执行结果没有影响,可以正常使用。警告中没有的功能单元都存在于Vector Engine中。

警告原因分析

该警告源自execute.cc#L166。MinorCPU在初始化其execute模块时,检查每个OpClass是否有相应的运算单元与之对应,以保证当前指令集支持的运算类型有相应的运算单元做运算。
如报告中提到的,作者设计的Vector Engine类似于协处理器,其作用对CPU而言与IntAlu这样的功能单元等同,似乎Vector Engine应该被放进OpClass。但是Vector Engine里面也有功能单元,需要依赖OpClass做指令译码、指令分发调度和运行次数统计,这样来看,将Vector Engine中的功能单元放进OpClass里会更合适。原作者也是选择了后者。

另外,Vector Engine中,实际的计算模块与VectorArith1Src这样的运算类型并不一一对应。

警告该如何解决

按照目前Vector Engine的设计,该警告在此commit之后的版本(由PLCT修改维护的)都存在。这个警告不影响使用Vector Engine(可能不太美观)。我们考虑在完整支持RVV1.0之后,做Vector Engine架构调整时再消灭这个警告。

如果很想尽快消灭它

可以在MinorCPU的execute模块的构造函数中做功能单元检查时,额外检查是否Vector Engine存在。当Vector Engine存在时,所有Vector开头的OpClass就有了对应的功能单元,这时候置found_fu=true

目前原作者的仓库只对RVV0.7.1做了支持,如果需要支持RVV1.0的版本,可以考虑使用PLCT维护的仓库。
仓库链接dev分支

看起来已经resolved