Repository navigation
perf: float32 Max/Min read float32 directly; SSE2 and NEON kernels - #64
Merged
Merged
Conversation
float32 Max/Min converted the whole array to float64 and reduced that: on a POWER9 they were 11.9-15x slower than NumPy. kernels.Max32/Min32 now read the float32 elements, with four chains of Go's max/min (the value is the same: the conversion is exact), and run vector kernels on amd64 (MAXPS/MINPS + CMPPS-unordered NaN mask; a zero result goes to the scalar loop for its sign, the v0.19.1 rule) and arm64 (NEON VFMAX/VFMIN .S4, NaN-propagating, -0 below +0). abbench, alternated, pinned core, float32 Max 2^14 / 2^20: Zen 3 -92% / -88%, Neoverse N1 -95% / -93%, POWER9 (Go loop) -42% / -34%; float64 controls flat. Tested bit for bit against one sequential pass of Go's max/min, with NaN, real signed zeros and infinities at every position to length 70; a sabotaged kernel fails it on both architectures; fenced. 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
Max/Minconverted the whole array to a new float64 array and reduced that. On a POWER9 they were 11.9–15× slower than NumPy.Changes
kernels.Max32/Min32read the float32 elements directly, with four independent chains of Go'smax/min. The value is the same as before, since float32 → float64 is exact.MAXPS/MINPS, 16 floats per iteration, with aCMPPS-unordered NaN mask. MAXPS/MINPS return their source operand on a zero tie, so a zero result goes back to the scalar loop for its sign. That is the rule v0.19.1 introduced for float64.VFMAX/VFMINon.S4, which propagate NaN and order −0 below +0 themselves.Measured with
abbench: alternated, 6 rounds, pinned core.Maxfloat32
Maxis now faster than float64 on both kernel architectures, since it reads half the bytes.Tests
max/min, with NaN, real signed zeros (math.Copysign(0, -1)) and infinities at every position, for every length up to 70.VFMINinmax32NEON, oneMINPSinmax32SSE2) fails it, on Apple M and on Zen 3.covblocks) reports 0 uncovered blocks.Not in this PR (recorded in
docs/perf.md):VFMAXSBmode 1): waiting for a z machine to test on.A minor release, v0.20.0.
🤖 Generated with Claude Code