Repository navigation
Conversation
…pends on the host CPU Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
…eter self-test Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
|
Tested the PR head on Linux x86-64 (WSL2), CPython 3.14.4, CPU only: pass. One gap, non-blocking but worth closing: on x86-64 the new test passes without the fix. Here A host-independent check closes that. Feed def test_created_nan_is_pinned_whatever_the_host_gives(self):
arm_nan = math.copysign(math.nan, 1.0) # what ARM64 creates for 0 * inf
got = si._pin_nan(arm_nan, 0.0, math.inf)
self.assertEqual(struct.pack("<d", got), struct.pack("<Q", 0xFFF8000000000000))
self.assertTrue(math.copysign(1.0, si._pin_nan(arm_nan, arm_nan, 1.0)) > 0) # an incoming NaN is keptWith this PR the first assertion gives |
slopradish
left a comment
There was a problem hiding this comment.
CPU verification: checked out pull/4100/head in an isolated worktree and ran pytest -q tests/semantic/test_interp.py: 36 passed, 93 subtests passed.
The fix is the right shape: instead of depending on the host CPU's NaN sign for operations that create a NaN from non-NaN operands (0*inf, inf-inf, inf+-inf), the interpreter now pins the sign explicitly to the RDNA2-measured value. That removes an x86-vs-ARM divergence in the reference model, which otherwise makes the semantic suite report false translator failures on Apple Silicon.
I checked the two changed files are only the interpreter and its test — no translator semantics are altered, so this cannot mask a real codegen bug. The pinned value matches the measured 0xFE00 / 0xFFC00000 words cited in the PR.
No GPU or game files needed for this review.
…atch a regression too Signed-off-by: Maxime Mansiet <AirKyzzZ@users.noreply.github.com>
|
@slint6614-dev good catch, thanks. Added |
Claimed in the coordination issue as: SHADER-723 (claim, correction)
What and why
test_alu_vop3_mods_hw.pyandtest_alu_sdwa_hw.py(round 42) pass on x86-64 and fail on ARM64: 27 and 2 subtests on an Apple M3 Pro, same commit.spirv_mini_interp.pydoes its float arithmetic with host floats, and when an operation creates a NaN from non-NaN operands (0 * inf, inf - inf, inf + -inf) the sign comes from the CPU. x86-64 gives a negative quiet NaN, which happens to be what RDNA2 gives (the measured0xFE00/0xFFC00000). ARM64 gives a positive one. Every failing word differs only in that sign bit._pin_nannow returns the negative quiet NaN when OpFAdd, OpFSub, OpFMul or the non-finite path offma_f32(product, then sum) creates a NaN. A NaN that comes in through an operand is left alone, and both hosts already propagate it the same way (first NaN operand, quieted). So nothing changes on x86, and ARM gets the same words. The explicitmath.nanreturns elsewhere (_fract, inf/inf in_fdiv, NMin/NMax) were already host-independent and are untouched.The second commit pins it in
test_interp.py: five created-NaN cases expect0xFFC00000, and three propagated ones keep0x7FC00001.Tested
python -m unittest discover -s tests/semantic, CPU only:mainaa2988ccThe failures left are the same tests on both hosts and already claimed: TEST-853 (
test_cmp_class_f64), thetest_loop_ballot_barrierfinding,test_mutations(#3883). The extra x86 error istest_spirv_val_compliance, a tool-path issue on that box. It fails the same way before and after.The new
test_interp.pycases fail 5 subtests on ARM64 without the interpreter change. On x86 they pass either way, since that's the host whose behaviour is being pinned. AI-assisted (Claude Code).Checklist
docs/design.md, with how it was confirmed. (no translator change, test interpreter only)