Reduce sin polynomial degree - #10819
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_952536329
branch
from
July 23, 2026 17:04
8a30b97 to
135bcd1
Compare
5 (fp32) and 9 (fp64) was overkill, it actually slightly reduces error to drop down one degree, and of course this improves performance. This change also adds some missing test and benchmark coverage. The test coverage isn't really necessary, because there is no architecture-specific behavior that is not covered by at least one architecture. But I think we should add these tests for completeness. Other minor fixes in this change: - Add missing plot lines for multiples of epsilon on the sin approximations - Add IWYU pragmas for gnu_vector to silence warnings Benchmarks: ``` name time/op time/op vs base bench_reference/sine_float/m:1/n:4096/real_time 50.08µ ± 4% 48.55µ ± 11% ~ (p=0.180 n=6) bench_reference/sine_double/m:1/n:4096/real_time 147.0µ ± 3% 149.2µ ± 6% ~ (p=0.394 n=6) bench_reference/cosine_float/m:1/n:4096/real_time 50.92µ ± 5% 53.09µ ± 10% ~ (p=0.485 n=6) bench_reference/cosine_double/m:1/n:4096/real_time 148.3µ ± 3% 146.6µ ± 3% ~ (p=0.485 n=6) bench/cosine_fp32_avx512/m:1/n:4096/real_time 1.796µ ± 5% 1.707µ ± 2% -4.93% (p=0.002 n=6) bench/cosine_fp64_avx512/m:1/n:4096/real_time 13.72µ ± 1% 13.37µ ± 1% -2.53% (p=0.002 n=6) bench/sine_fp32_avx512/m:1/n:4096/real_time 1.731µ ± 2% 1.620µ ± 1% -6.43% (p=0.002 n=6) bench/sine_fp64_avx512/m:1/n:4096/real_time 13.67µ ± 1% 13.24µ ± 3% -3.18% (p=0.002 n=6) bench/cosine_fp32_avx2_fma3/m:1/n:4096/real_time 2.645µ ± 5% 2.513µ ± 4% -5.00% (p=0.009 n=6) bench/cosine_fp64_avx2_fma3/m:1/n:4096/real_time 9.510µ ± 19% 10.409µ ± 5% ~ (p=0.065 n=6) bench/sine_fp32_avx2_fma3/m:1/n:4096/real_time 2.766µ ± 6% 2.470µ ± 4% -10.71% (p=0.002 n=6) bench/sine_fp64_avx2_fma3/m:1/n:4096/real_time 9.140µ ± 3% 10.041µ ± 4% +9.86% (p=0.002 n=6) bench/cosine_fp32_fma3/m:1/n:4096/real_time 3.489µ ± 4% 3.331µ ± 4% -4.54% (p=0.002 n=6) bench/cosine_fp64_fma3/m:1/n:4096/real_time 10.77µ ± 4% 11.75µ ± 3% +9.03% (p=0.002 n=6) bench/sine_fp32_fma3/m:1/n:4096/real_time 3.262µ ± 5% 3.276µ ± 5% ~ (p=0.937 n=6) bench/sine_fp64_fma3/m:1/n:4096/real_time 9.986µ ± 3% 10.275µ ± 7% ~ (p=0.180 n=6) bench/cosine_fp32_avx2/m:1/n:4096/real_time 4.251µ ± 2% 3.927µ ± 4% -7.62% (p=0.002 n=6) bench/cosine_fp64_avx2/m:1/n:4096/real_time 15.53µ ± 8% 17.05µ ± 3% +9.75% (p=0.004 n=6) bench/sine_fp32_avx2/m:1/n:4096/real_time 4.238µ ± 3% 4.064µ ± 4% -4.10% (p=0.004 n=6) bench/sine_fp64_avx2/m:1/n:4096/real_time 15.06µ ± 3% 16.69µ ± 6% +10.81% (p=0.002 n=6) bench/cosine_fp32_avx/m:1/n:4096/real_time 6.647µ ± 3% 5.981µ ± 4% -10.02% (p=0.002 n=6) bench/cosine_fp64_avx/m:1/n:4096/real_time 18.07µ ± 3% 16.89µ ± 3% -6.48% (p=0.002 n=6) bench/sine_fp32_avx/m:1/n:4096/real_time 5.621µ ± 3% 5.237µ ± 7% -6.83% (p=0.004 n=6) bench/sine_fp64_avx/m:1/n:4096/real_time 17.44µ ± 1% 17.00µ ± 3% -2.55% (p=0.015 n=6) bench/cosine_fp32_sse41/m:1/n:4096/real_time 11.68µ ± 2% 10.58µ ± 3% -9.44% (p=0.002 n=6) bench/cosine_fp64_sse41/m:1/n:4096/real_time 33.61µ ± 2% 31.63µ ± 4% -5.88% (p=0.002 n=6) bench/sine_fp32_sse41/m:1/n:4096/real_time 11.15µ ± 4% 10.01µ ± 2% -10.18% (p=0.002 n=6) bench/sine_fp64_sse41/m:1/n:4096/real_time 36.07µ ± 3% 31.63µ ± 4% -12.31% (p=0.002 n=6) bench/cosine_fp32_sse2/m:1/n:4096/real_time 12.06µ ± 6% 10.62µ ± 4% -11.94% (p=0.002 n=6) bench/cosine_fp64_sse2/m:1/n:4096/real_time 36.62µ ± 4% 34.48µ ± 2% -5.83% (p=0.002 n=6) bench/sine_fp32_sse2/m:1/n:4096/real_time 13.10µ ± 5% 11.53µ ± 3% -11.98% (p=0.002 n=6) bench/sine_fp64_sse2/m:1/n:4096/real_time 36.74µ ± 3% 34.86µ ± 5% -5.13% (p=0.002 n=6) bench/cosine_fp32_sse2_fma/m:1/n:4096/real_time 107.84µ ± 2% 96.53µ ± 0% -10.49% (p=0.002 n=6) bench/sine_fp32_sse2_fma/m:1/n:4096/real_time 107.89µ ± 2% 96.86µ ± 2% -10.23% (p=0.002 n=6) geomean 13.74µ 13.24µ -3.60% ``` PiperOrigin-RevId: 952840776
copybara-service
Bot
force-pushed
the
test_952536329
branch
from
July 23, 2026 17:40
135bcd1 to
c18ab58
Compare
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.
Reduce sin polynomial degree
5 (fp32) and 9 (fp64) was overkill, it actually slightly reduces error to drop down one degree, and of course this improves performance.
This change also adds some missing test and benchmark coverage. The test coverage isn't really necessary, because there is no architecture-specific behavior that is not covered by at least one architecture. But I think we should add these tests for completeness.
Other minor fixes in this change:
Benchmarks: