Repository navigation
fix(shader): take v_sin_f32 and v_cos_f32 from an exact series where the driver's result is more than 4 ulp off - #3770
Merged
Conversation
…the driver's result is more than 4 ulp off
Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
|
Measured on the HW oracle (gfx1035, IEEE=0, f32 denormals flushed) over 243,092 inputs in [2^-13, 0.5] turns plus ±3000 ulp around 1/8, 1/4, 3/8, 1/2 and 0.1 and negatives: the series is within 2 ulp of the true sine/cosine (also with Added on your branch:
Merging once CI is green. |
9 tasks done
9 tasks done
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.
What
agc_driver_sin_cos_near_zerofails on Intel UHD Graphics (CML GT2, Mesa 26.2.3) in every run:Lane 24 is 0.1 of a turn (sin 36°). It is outside the 2^-12 near-zero range that #2380 linearizes, so the result is the driver's
GLSLstd450Sin, 27 ulp from the hardware value on this GPU. The same failure was reported in a comment on #2114.This applies the scheme
EmitFPLog2already uses: keep the driver's value unless it is more than 4 ulp from an exact series, and take the series then.EmitTrigCycleF32is exact, so the reduction to [0, 1/8] of a turn uses only Sterbenz subtractions (0.5 - a, 0.25 - a), which are exact.SinTurnSeriesandCosTurnSeriesevaluate sin(2πx) and cos(2πx) as Taylor series in turns, with f32 coefficients of (2π)^n/n!, by FMA Horner steps marked NoContraction. Over [0, 1/8] they stay within 2 ulp (sin) and 1 ulp (cos) of the true value; at lane 24 the series gives 0x3f167918, 1 ulp from the hardware.Tested
Arch Linux (kernel 6.18.54-lts), GCC 16.2.1, Release,
BUILD_TESTING=ON,maina11c8f7. One laptop with two GPUs, picked withANYPS5_GPU: GeForce GTX 1650 Ti (NVIDIA 615.71.09) and Intel UHD (CML GT2, Mesa 26.2.3).mainagc_driver_sin_cos_near_zero, Intelagc_driver_sin_cos_near_zero, NVIDIAFull ctest, 832 tests per GPU, with and without the change:
agc_driver_sin_cos_near_zero, which now passes. The rest fail onmaintoo:agc_driver_emulated_color_compare(fix(shader): allow constant-zero sRGB comparisons #3532),agc_driver_flat_storetimeout (Intel Mesa < 26.2: flat_store and masked_global_store (earlier flat_loads_x2_x3) fail to compile (SIMD32 scratch over 256 KiB) because each inlined BDA lookup records faults from 16 sites; fix branch ready #2972),agc_driver_gated_dispatch_captureand_short_timeout(agc_driver_gated_dispatch_capture hangs the GPU on Intel UHD 620 (i915 preemption timeout) #3345),agc_driver_vop1_float_unary(Intel UHD 770: vop1_float_unary, sdwa_float_selectors, vopc_compare and buffer_unaligned_base fail #2114).main; onlyagc_driver_emulated_color_compare(fix(shader): allow constant-zero sRGB comparisons #3532).Windows and AMD: not tested.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)