Repository navigation
perf: float32 Exp and Log on the float64 kernels (2-3.5x faster) - #86
Merged
Merged
Conversation
float32 Exp and Log called math.Exp/math.Log per element, 6-14x slower than NumPy on one Zen 3 core. They now run this package's float64 kernels (the Arm optimized-routines ports) 256 elements at a time through a stack buffer, rounding each result once: within 0.5 + 2^-29 float32 ULP, no allocation. abbench, 8 rounds, one Zen 3 core: Exp 297 -> 84 us and Log 198 -> 99 us at 16 Ki; Exp 18.8 -> 5.2 ms and Log 12.4 -> 6.1 ms at 1 Mi. Still about 3x slower than NumPy's float32 SIMD, recorded as an open defect in docs/perf.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
float32
ExpandLogcalledmath.Exp/math.Logper element: 6–14× slower than NumPy on one Zen 3 core. They now run this package's float64 kernels (the Arm optimized-routines ports, 0.504 ULP in float64), 256 elements at a time through a stack buffer, with no allocation. Each result is rounded once, so it is within 0.5 + 2⁻²⁹ float32 ULP.Exp, 16 KiLog, 16 KiExp, 1 MiLog, 1 MiThese are +255% / +102% / +265% / +109% in throughput, all at p = 0.000.
Still 3× slower than NumPy, whose float32 kernels are SIMD (
simd_exp_f32,simd_log_f32). docs/perf.md records this as an open defect, and porting those kernels is the next step.Tests (
via64_test.go):float32(math.Exp/Log(x))within 1 ULP, and equal on at least 99.9% of 100 000 inputs;exp(89)gives +Inf), the subnormals, and log of a negative number;The new
BenchmarkDTypeExpLoguses the same operand as the NumPy reference script. SECURITY.md has the audit entry.🤖 Generated with Claude Code