Repository navigation
Conversation
Removing the FDIV/FSQRT knobs changes the resolved config, so every perf entry's config_hash moves; the synthesis entries move with the smaller FPU and the 2-lane TFU at 16 threads. Re-recorded with: pytest ci -m perf_gate --update-baselines (all 51 cases) ci/logic_gate.py --update-baseline (core, core_ldst, top_vortex) ci/logic_gate.py --tool beacon_asic --update-baseline (core, top, tfu) ci/asic_gate.py --update-baseline (core, top, tfu) ci/fpga_gate.py --update-baseline (core, top, tfu) gfx, gfxvm and tensor were re-run too; they contain no FPU and their metrics did not move, so they are not re-recorded. Tools: TOOLCHAIN_REV v3.0.4, beacon 134d03b9e, CIRCT 90c5fd313, Yosys 0.69, OpenSTA 3.1.0 (asap7 rvt tt), Vivado 2024.2 (xcu55c). Re-recorded by: agent, authorized by jel221 2026-12-03.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comment:
Commercial GPUs usually don't provide fdiv and sqrt units, they are usually approximations. But just to not break the RISC-V ISA, it is instead implemented as uops. I guess it slightly breaks the ISA in that it is not IEEE compliant, but most GPUs don't provide full IEEE compliant floating point division operators because the hardware for it tends to be too expensive as you'll se e below. So it's up to you, or we can discuss later this week
Moves FP division and sqrt into the TFU as approximations (not IEEE compliant nevessarily). There are two reasons for this. The first reason is just pure area. Beacon doesn't show you a ton of reduction, but the look-up table (not the FPGA resource, the literal look up table for transcendentals) is in BRAM in a real Vivado build, and the amount of flip flop reduction is -30%, which comes out to around 40% reduction on ASIC builds.
The next reason is that it removes the tag and the 2 ops in flight limitation from the FPU. So you can remove this by carrying the tag like any other unit like ALU in the FPU pipeline registers. However, the 17 stages of FDIV and FSQRT makes the area blow up immensely if you do this. So, we make it a pipeline. Because of this, it actually gives you a speedup because FMA is fully pipelined and has better throughput. This is the next PR.
Summary
FDIV and FSQRT (
.Sand.D) no longer have their own hardware. A new uop generator,VX_uop_fdiv, expands each one into TFU reciprocal / reciprocal-square-root micro-ops plus FPU micro-ops (FMUL, FSUB, FSGNJX, F2F). Every micro-op writes onlyrd, so any register aliasing works:rd != rs1rd = rcp(rs2); rd = rs1 * rdrd == rs1 != rs2rd = rcp(rd); rd = rd * rs2; rd = rcp(rd)rd == rs1 == rs2rd = abs(rd); rd = lg2(rd); rd = rd - rd; rd = ex2(rd)(gives NaN for 0, inf, NaN)rd = rsqrt(rs1); rd = rcp(rd).Dcvt.s.d, TFU op,cvt.d.sWhat goes away:
VX_fdivsqrt_unit,VX_fsqrt_unit,VX_fsqrt_unit_rtl, their unit tests and the vendor IP scripts.VX_fdiv_unitstays, because the RTU uses it.VX_CFG_FDIV_LATENCY,VX_CFG_FSQRT_LATENCY,VX_CFG_FDIV_PE_RATIOandVX_CFG_FSQRT_PE_RATIO, including their entries in the GPU profiles.What changes:
VX_CFG_EXT_TFU_ENABLEnow followsVX_CFG_EXT_F_ENABLE, so every F build has a TFU.VX_CFG_NUM_TFU_LANES=max(1, FPU lanes / 8): one TFU lane per 8 FMA lanes. At 16 threads that is 2 lanes, where master's TFU builds had 1.This PR is stacked on #584 (TFU timing fix). Without that fix, the TFU's 21–24-level stages would become the deepest path of every core. The base branch is
fix/tfu-timing; retarget tomasteronce #584 merges.Accuracy
The results are approximations, not correctly rounded. Measured by the new
fdiv_tfutest, for normal inputs with normal results:rd == rs1rd == rs1case can only run reciprocal, multiply, reciprocal, because every micro-op writes onlyrdand the first source is gone after the first step. Getting it to 2 ulp would need a hidden scratch register.0/0raises invalid (NV) in the multiply (0 × inf).Area
FPGA Beacon (U55C):
core, 16 threads × 16 warpstop_vortex, 2 cores × 4 threads × 4 warpsBeacon counts each TFU lane's lookup tables as 4.2k LUTs. Vivado puts them in block RAM: on the
tfuDUT, Beacon reports 5.7k LUTs where Vivado reports about 2k. So the Vivado LUT saving on the core is larger than Beacon's −8%:core, 16 threads × 16 warpstoptfu(16 threads: now 2 lanes)ASIC (ASAP7):
coretoptfu(16 threads: now 2 lanes)The
tfuDUT grows because its 16-thread config now gets 2 lanes. Its Yosys Fmax gain is from #584.Performance
perf_gate(51 rtlsim cases, re-recorded):Microbenchmarks (rtlsim, cycles vs master, measured before the rebase onto #584, which does not change cycles):
In the regression and OpenCL suites, only raycast uses divide and sqrt heavily. The OpenCL kernels cfd, srad, blackscholes and myocyte are divide- or sqrt-dense but are not perf-gated, and their cost has not been measured.
The next PR removes the FPU's 2-in-flight limit, which this PR makes affordable. With it, the app geomean goes to −1.6% / −2.2% at 8 and 32 threads.
Tests
tests/regression/fdiv_tfu: every register aliasing of FDIV and FSQRT, checked against ulp bounds, plus special values.parity-fdiv-tfu: that test at 4 threads (1 TFU lane) and 16 threads (2 lanes).dogfood-7,dogfood-8andparity-raycast-fdiv4. They ranVX_CFG_FDIV_PE_RATIO/VX_CFG_FSQRT_PE_RATIO, which no longer exist.fdivISA test, which checks correctly rounded FDIV/FSQRT results and the DZ flag.Baselines re-recorded
The second commit re-records the golden baselines this change moves. Each was recorded with its update command and is authorized by jel221:
ci/baselines/perf/*.json:pytest ci -m perf_gate --update-baselines. All 51 entries change, because removing the FDIV/FSQRT knobs changes the resolved config that every entry'sconfig_hashcovers.ci/baselines/synthesis/beacon/core.json:ci/logic_gate.py --update-baseline(core,core_ldst,top_vortex).ci/baselines/synthesis/beacon_asic/{core,tfu}.json:ci/logic_gate.py --tool beacon_asic --update-baseline(core,top,tfu).ci/baselines/synthesis/yosys/{core,tfu}.json:ci/asic_gate.py --update-baseline(core,top,tfu).ci/baselines/synthesis/xilinx/{core,tfu}.json:ci/fpga_gate.py --update-baseline(core,top,tfu).gfx,gfxvmandtensorwere re-run too: they contain no core, and their metrics were unchanged, so they are not re-recorded.Impact and evidence
Impact class: R3 (
detector:config-knobs,detector:test-coverage; fromci/change_impact.py)Contracts touched:
VX_config.tomlknobs:VX_CFG_EXT_TFU_ENABLEandVX_CFG_NUM_TFU_LANES.VX_CFG_FDIV_LATENCY,VX_CFG_FSQRT_LATENCY,VX_CFG_FDIV_PE_RATIOandVX_CFG_FSQRT_PE_RATIO.make -C tests/regressionrun-simx and run-rtlsim, and the rv32 ISA suites on both, all pass; every app passes at 4×4, 8×16 and 32×16. After the rebase: the 51perf_gateworkloads pass on rtlsim, as dovecadd(simx) anddemo(rtlsim). The full suite was not re-run locally after the rebase; CI runs it. xrt not run.model_parityparity-fdiv-tfuadded.perf_gate--update-baselines; geomean +0.24%, details abovelogic_gatecore,core_ldst,top_vortex: no deeper unit, max 15 levels as beforefpga_gate/asic_gate)core,top,tfuon Vivado 2024.2 and Yosys/OpenSTA (ASAP7).Dsequences are implemented in RTL and SimX but not run locally; CI's XLEN 64 cells are their first runSelf-check:
ci/precheck.shsummary: precheck: 6 pass, 1 with findings, 0 fail, 0 not run. The finding is advisory C-STY-1 on the untoucheddpi_fdivdeclaration, which sits next to the deleteddpi_fsqrtline. It is left as is to match its neighbours'T* xstyle.Departures from SHOULD rules:
fdivISA test is skipped for that reason.Design note: docs/designs/floating_point_unit.md, updated in this PR.
known_issue:, wider tolerance, smaller args, removed case) without a root-cause plan. ThefdivISA test is skipped and the dogfood flag expectations are relaxed on purpose, because the results are approximations by design. The three removed cases tested knobs that no longer exist.