Repository navigation
fpu/fpnew: complete a lane group only when every lane is done; fix div/sqrt boxing and 0/0 flags - #486
Open
tinebp wants to merge 1 commit into
Open
fpu/fpnew: complete a lane group only when every lane is done; fix div/sqrt boxing and 0/0 flags#486tinebp wants to merge 1 commit into
tinebp wants to merge 1 commit into
Conversation
…v/sqrt boxing and 0/0 flags
VX_fpu_fpnew ran one fpnew_top per lane but took valid, ready, tag and
fflags from lane 0 only. Div/sqrt has operand-dependent latency (special
operands finish early), so lanes finished out of step: the group was
released on lane 0's handshake and the other lanes returned zeros or stale
results, and fflags raised by any lane but lane 0 were lost. Aggregating
the lane valids alone is not enough, because inside one fpnew_top the op
groups have different latencies and can return results in a different
order on different lanes.
Split each lane into two fpnew instances:
- a lockstep instance with ADDMUL/NONCOMP/CONV only. Their latency does not
depend on the data and every lane sees the same handshake, so lane 0's
handshake is exact (a runtime assertion checks it);
- a div/sqrt-only instance. A VX_stream_fork hands each instruction to every
lane exactly once, and a VX_stream_join completes the group when all lanes
have a result. Each lane's divider is in order, so the k-th result of
every lane belongs to the same instruction.
VX_stream_arb merges the two response streams (replacing the response
buffer), and fflags are ORed across the instruction's active lanes, with
the mask carried in the tag.
Two divider bugs found on the way, fixed in the wrapper (the PULP submodule
is untouched):
- at XLEN 64, fpnew's divider ignores NaN-boxing, so an improperly boxed
single operand was used as a number. It now reads as the canonical NaN.
- 0/0 raised NV and DZ together; the spec raises NV only. DZ is cleared
when NV is set.
Two flag and boxing defects outside the FPnew wrapper, found in review:
- with fewer FPU lanes than threads, an instruction runs as lane packets
and VX_fpu_block ORed their flags into one shared register until the
last packet. Packets of different warps' instructions complete
interleaved (the cores have different latencies, and FPnew's div/sqrt
path is merged by priority), so one warp's flags went to another and
were lost from their own. fcsr accrues flags by OR, so each packet now
writes its own flags as it returns; the scoreboard still releases fflags
readers on the last packet, which writes no later than before.
- the STD and DSP backends fed F32 FMA and div/sqrt operands to the units
as raw low words, so an improperly NaN-boxed operand was used as a
number at FLEN 64. fp_unbox_s/fp_unbox_fmt in VX_fpu_pkg substitute the
canonical NaN at those inputs; FLEN 32 builds are unchanged.
New dogfood tests fdiv-special (special and normal divides mixed across
lanes), fp-nanbox (64-bit only: an unboxed operand of sqrt, div and each
FMA operand) and fflags-lanes (flags raised by a single non-zero lane,
masked lanes must not contribute, warps mixing divides and adds). On master
with FPnew (XLEN 64, 8 lanes) the first and last fail with 264 and 388
errors and the div/sqrt rows of fp-nanbox with 342; with the fix they
pass, as do the full dogfood suite, rv64uf/rv64ud and rv32uf on FPnew,
and the new tests on SimX and the DPI, STD and DSP backends at XLEN 32 and
64. fflags-lanes with two FPU lanes for four threads fails 7 lanes on
FPnew with the shared accumulator and passes with per-packet writes (the
STD backend's fixed latencies did not interleave packets in this test).
CI: dogfood-fpnew runs the suite on rtlsim with FPnew at XLEN 32 and 64;
dogfood-fflags-pbw-{std,fpnew} run fflags-lanes with two FPU lanes;
dogfood-nanbox-dsp runs fp-nanbox on DSP at XLEN 64 (STD and FPnew are
covered by the default and FPnew suites). No model_parity case builds
FPnew, and the cycle change is limited to that backend. The dogfood
Makefile now declares its headers, so editing testcases.h rebuilds the
host binary. Beacon (core, XLEN 32, which does not build FPnew): depth,
LUT and FF unchanged.
Fixes #437.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
FPnew drops lanes.
VX_fpu_fpnewran onefpnew_topper lane but took valid, ready, tag and fflags from lane 0. Div/sqrt latency depends on the operands, so lanes finished out of step: other lanes returned stale or zero results, and their flags were lost. Fixes #437.VX_stream_forkandVX_stream_joincomplete a div/sqrt group only when every lane has a result.VX_stream_arbmerges the two paths.Two related defects outside FPnew, found in review:
VX_fpu_blockORed every packet's flags into one shared register until the last packet. Packets of different instructions complete interleaved, so one warp's flags reached another and were lost from their own.fcsraccrues flags by OR, so each packet now writes its own flags as it returns.fp_unbox_sandfp_unbox_fmtinVX_fpu_pkgnow substitute the canonical NaN there. FLEN 32 builds are unchanged.New dogfood tests:
fdiv-special: mixes special and normal divides across lanes.fp-nanbox: unboxed sqrt, div and FMA operands.fflags-lanes: flags raised by single lanes, with lanes masked and warps mixing divides and adds.Impact and evidence
Impact class: R2 (
ci/change_impact.py classify)Contracts touched: none
model_parityperf_gatelogic_gate-Walllint at XLEN 32 and 64 across the standard config matrix, STD, DSP and FPNEW, partial-bandwidth STD and FPNEW, and the DSP split FMA64 poolNew CI cases:
dogfood-fpnewdogfood-fflags-pbw-stdanddogfood-fflags-pbw-fpnewdogfood-nanbox-dspNo test silenced.
No golden data changed.
Cycle movement is FPnew-only, with no parity case for it.
No toolchain pin change.
🤖 Generated with Claude Code