Repository navigation
MUFU + Zfhmin - #432
MUFU + Zfhmin#432
Conversation
The MUFU and Zfhmin config keys change the resolved config hash, which marked every perf_gate baseline stale. Cycles are unchanged within 1.2% except sgemm-nt4 (+3.0%) and sgemv (nt4 +34.6%, nt16 +5.2%); sgemv already measures the new values on master (316432 instrs / 1175175 cycles at nt4), so its old baseline predates a master change.
The previous refresh was measured with a local toolchain that compiles kernels differently from vortex-toolchain-prebuilt v3.0.1. Measured with the pinned toolchain, every cycle and instruction count equals master's; only the config hashes change.
|
My feedback: 1- make sure your AI agent always reads AGENTS.md, docs/coding_guidelines_cpp.md, docs/coding_guidelines_verilog.md and the SimX channel rule in docs/designs/simobject.md before writing code or executing a code review before commit!!!!! 2- MUFU should not use a dedicated execution unit - very expensive!!! - move MUFU into SFU like all other hardware extensions - will slightly reduce its performance, but it is ok Below is Claude Opus 5.5 review: Bugs (first pass, none verified) |
- MUFU is now an SFU processing element (SFU op 0xF): the SFU's lanes are serialized onto VX_CFG_NUM_MUFU_LANES datapath lanes (default 1). The dedicated execution unit, its dispatch/commit paths and MPM class are removed. SimX models it as a helper owned by SfuUnit. - VX_MUFU_LATENCY is a fixed constant in VX_types.toml, not a config knob. - Table ROM via a new hw/rtl/libs/VX_rom (contents as a parameter), since VX_sp_ram's init file is compiled out on the ASIC paths. - Fixes: SimX CSR writes per SFU packet; F32 NaN-box check on fp32 sources of the STD/DSP converter with FLEN=64; vx_sqrtf_fast returns a signed zero for subnormal input and +inf for +inf; F-only decode rejects FCVT forms involving D; SimX LH-to-float raw bits only under Zfhmin; MUFU test checks every op for any -r; SimX trace prints MUFU.<fn>; NaN-boxing helpers shared in sw/common/nan_box.h, consistent on RV32. - Zfhmin requires F (build-time error). - CI: 16-thread parity case; mufu DUT added to the Yosys catalog with an asic_gate baseline; fpga_gate mufu baseline re-recorded for the new DUT (fpga_gate.py --update-baseline, Vivado 2024.2); perf baselines re-recorded for the new config hash with the pinned toolchain (cycle counts unchanged). - Style: braces, 2-space indent, one parameter per line, begin/end, library priority encoder for the first active CSR lane, no cross-layer comments.
The SFU's response switch already buffers each PE's results, so the MUFU serializer's own two-slot output buffer was a second copy of a full 16-lane result. Removing it drops MUFU's result latency by one cycle (SimX matches) with no throughput loss, including with one MUFU lane per SFU lane. Re-recorded mufu baselines (fpga_gate/asic_gate --update-baseline): Xilinx 2030 LUT / 1105 FF (was 2624 / 2278), Yosys 2073 um^2 (was 2701).
The xilinx DUT flow compiles every file on the include path, so the fpu DUT's BASE_INC brings in hw/rtl/VX_cluster.sv, which imports VX_tlb_pkg. fpu_PKG never listed the package, and synthesis stops with: ERROR: [Synth 8-36] 'VX_tlb_pkg' is not declared [.../VX_cluster.sv:1] The mufu DUT lists it for the same reason.
Brings in master's Rv64 fixes (#427), the single-packet dispatch fix (#428), MUFU + Zfhmin (#432) and the RTU performance counters with the perf-counter fixes (#435). Conflicts keep the branch's structure where it reorganized the code: - Cache bank and MSHR: the branch already carries #427's AMO write-back queue and commit-busy checks; its back-to-back fill path (no fill_inflight stall) and lazy-fetch queue stay. - SFU: master's MUFU PE moves into VX_sfu_block, next to the RTU PE, and SimX's SFU dispatches MUFU ops per block through send_out. - Host performance-counter reads: the branch's VX_csr_mpm already serves every counter master's VX_csr_data block reads. - AFU/xrtsim memory ports, device caps (socket size), hardware profiles, changelog and command-processor docs: the branch's. - SimX memory and local-memory perf counters now run from device reset, as master fixed them and as the RTL counts. - The regression list gains mufu and zfhmin; the Xilinx DUT catalog gains mufu. The perf baselines keep the branch's recorded values; they are re-recorded on the merged tree by perf_gate --update-baselines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MUFU: special-function unit
0x5B, R-type):funct7 = 0,funct3= format (FP32 only),rs2= function: 0rcp, 1rsqrt, 2ex2, 3lg2, 4sinpi, 5cospi, 6tanh.rd/rs1are FP registers. Intrinsics insw/kernel/include/vx_mufu.h(vx_rcpf,vx_ex2f, ...) plus fast-math helpers (vx_expf_fast,vx_sigmoidf_fast,vx_geluf_fast, ...).EX_MUFU.VX_CFG_NUM_MUFU_BLOCKS = 1,VX_CFG_NUM_MUFU_LANES = 1(one lane was as fast as two on FlashAttention),VX_CFG_MUFU_LATENCY = 7..approxlevel); exact cases preserved.VX_mufu_unit_top, xcu55c, 16 threads): 375 MHz, 1,227 LUT, 1,153 FF, 57 LUTRAM, 1 BRAM, 3 DSP. New fpga_gate build and baseline.VX_CFG_EXT_MUFU_ENABLE(off by default); capability bitVX_ISA_EXT_MUFU(MISA_EXT bit 12); counters in MPM class 17.hw/rtl/mufu/; SimXsim/simx/mufu_unit.*; shared bit-exact golden modelsw/common/mufu.*; table generatorhw/scripts/gen_mufu_tables.py.Zfhmin (standard RISC-V)
flh,fsh,fmv.x.h,fmv.h.x,fcvt.h.s,fcvt.s.h, plusfcvt.h.d/fcvt.d.hon RV64. All rounding modes, IEEE flags, NaN-boxing. GateVX_CFG_EXT_ZFHMIN_ENABLE(off by default); capability bit 13;_zfhminadded to-march.docs/designs/floating_point_unit.md.Fixes included
VX_csr_unit.sv); a CSR write in divergent code wrote a stale value. Now the first active lane; SimX matches.fcvt.s.dnarrowing (STD/DSP): overflow now respects the rounding mode; a rounding carry into overflow raises OF; underflow uses after-rounding tininess; a subnormal rounding up to the smallest normal is no longer flushed to 0.Verification
hw/unittest/mufu_unit(RTL vs golden model),tests/regression/mufuon simx/rtlsim/xrt, RV32/RV64, simx/rtlsim parity cases.tests/regression/zfhmin, bit-exact with flags against softfloat across all rounding modes (widening exhaustive), on simx and rtlsim with the DPI, STD and DSP FPUs;fcvt_unitunit test extended with fp16; parity within 0.07%.rv32uf/rv64udpass on DPI and STD; every FPU backend builds on RV32/RV64.