Skip to content

perf: float64 Maximum and Minimum on go-simd/floats v0.26.0 kernels - #128

Merged
tannevaled merged 1 commit into
mainfrom
perf/floats026-maxmin
Nov 15, 2026
Merged

tannevaled merged 1 commit into
mainfrom
perf/floats026-maxmin

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Float64 Maximum and Minimum now run on the go-simd/floats v0.26.0 kernels (go.mod bumped from v0.23.0). kernels.Maximum and kernels.Minimum are thin wrappers over floats.Maximum and floats.Minimum, so every caller changes with them: the same-shape fast path, the scalar and repeated-operand paths and the general broadcast in binOp, and MaximumInto-style forms do not exist. Clip does not use them (it is floats.ClampScalar). Where floats has no vector kernel it is the builtin max/min loop, as before. Other dtypes are unchanged.

Correctness. TestMaximumMinimumFloats compares with the builtin max/min bit for bit (±0 in both orders, ±Inf, subnormals, extremes, random bit patterns) on lengths 0 to 33, ParThreshold - 1, ParThreshold + 37 and 10^5, with out = a and out = b aliasing. NaN results are compared as is-NaN, which is all the old loop guaranteed (the builtin's NaN choice is target-dependent): a NaN in either operand, including a signalling NaN and both operands NaN, gives a NaN. The 100% coverage gate holds locally, and TestPerf in bench/ passes (allocation counts unchanged).

Measured (go test -bench MaxMin, new benchmarks/maxmin_bench_test.go), 10^5 float64 including the result allocation, cfarm420 (AMD EPYC 7773X), GOMAXPROCS=1, taskset -c 9, a test binary of main (2ffe02d) against one of this branch, four interleaved rounds of 1 s, 1-minute load 3.97 at the start and 3.56 at the end:

operation before (µs) after (µs) allocs/op, B/op
Maximum 139–150 76–82 2, 802928 (unchanged)
Minimum 141–151 76–81 2, 802928 (unchanged)

No NumPy ratio is claimed: these are Go against Go, and the table has not been rerun on this change. README and docs/perf.md (Since the table) are updated.

Refs #98
Refs #118

🤖 Generated with Claude Code

Bump go-simd/floats to v0.26.0 and make kernels.Maximum and Minimum its
Maximum and Minimum: a vector kernel where there is one, the builtin
max/min loop elsewhere. Every caller goes through them (same-shape,
scalar, repeated and broadcast operands in binOp); Clip does not use them.
Results are bit for bit the builtin's for numbers and zeros; a NaN gives a
NaN, whose choice is target-dependent, which is all the old loop promised.

Tests: bit identity against the builtin (+-0 in both orders, +-Inf,
subnormals, random), lengths 0-33 and above ParThreshold, out = a and
out = b, NaN results as is-NaN.

On 10^5 float64, cfarm420 one core, with the result allocation: Maximum
139-150 -> 76-82 us, Minimum 141-151 -> 76-81 us; 2 allocs/op and 803 kB
unchanged.

Refs #98
Refs #118

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 7d5904e into main Nov 15, 2026
13 checks passed
@tannevaled
tannevaled deleted the perf/floats026-maxmin branch November 15, 2026 22:56
tannevaled added a commit to go-ndarray/docs that referenced this pull request Nov 15, 2026
Every mirrored page, hugo.yaml (version and baseURL /docs/0.46/) and the
README now point at v0.46.0. Re-synced from the v0.46.0 source, the only
mirrored one that changed since v0.45.0: performance.md (docs/perf.md: float64
Maximum/Minimum on go-simd/floats v0.26.0, 139-151 to 76-82 us per 1e5). The
other pages are only relabelled. The table was not re-measured: the home page
still quotes the one measured at 37c1b86 (185 slower, 54 faster, 17 tied).
performance-history.md is left alone.

Refs go-ndarray/ndarray#128

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled added a commit to go-ndarray/go-ndarray.github.io that referenced this pull request Nov 15, 2026
The card says "library · v0.46.0" and the playground builds against ndarray
v0.46.0; its tests pass. The stats are unchanged: the table was not
re-measured.

Refs go-ndarray/ndarray#128

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant