Repository navigation
refactor: MatMul, MatMul32 and the linalg products run on go-blas/blas - #122
Merged
Merged
Conversation
The packed GEMM (gemm.go, gemm_<arch>.go, gemm32_*, gemmua_other, the GEMM micro-kernels of sum_<arch>.s and their generators) moved to github.com/go-blas/blas in go-blas/blas#1, byte for byte. ndarray now calls DgemmStrided / SgemmStrided through internal/blasmm, which reads an operand through its strides (a transposed or a[:, ::2] view is not copied; a broadcast or reversed one is) and picks the float32 path with HasSgemmKernel. Kept here: the dot kernels (moved from gemm_<arch>.go to dot_<arch>.go, unchanged), mat-vec and Dot1D (matvec.go), blocks8, the float32 elementwise and sqrt kernels, max/min, the thread pool and hwcap. sum_<arch>.s is regenerated without the GEMM blocks: every other block is byte-identical. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
v0.2.1 scales C a contiguous run at a time in DgemmStrided/SgemmStrided (go-blas/blas#3): MatMul through v0.2.0 was 1.15 to 1.45x slower than the GEMM it replaces at n = 64..256 because of that loop. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s v0.2.1 TestMatMulLayouts multiplies 16 shapes x 11 x 11 layouts (contiguous, transposed, reversed, broadcast, decimated with an offset, extent-1 axes with garbage strides) in float32 and float64 against a naive loop within a bound, and requires the same bits from the heap and from a NaN-filled Workspace and at GOMAXPROCS 1 and N. TestMatMulConcurrentViews runs 16 goroutines on the same views. -short drops the three largest shapes (0.6 s against 12 s). SECURITY.md's 2026-11-15 entry said go-blas/blas v0.2.0; go.mod pins v0.2.1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… its timeout
The two largest shapes (1.3M and 2.1M multiplications per layout pair) took
the test job past 10 minutes under -race. They are replaced by {100, 40, 70},
which is past the parallel threshold (m*n >= 6000), and the naive reference
runs only in the heap run, the workspace and one-worker runs being compared
with it by hash: 25 s under -race on a loaded machine, 0.6 s with -short.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
tannevaled
added a commit
to go-ndarray/docs
that referenced
this pull request
Nov 15, 2026
Say the GEMM code moved to go-blas/blas byte for byte (no bit-identity claim),
label the perf table as measured at v0.41.0, and mirror SECURITY.md verbatim
("unreleased" in both audit entries, as the source has it).
Refs go-ndarray/ndarray#122
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 blurb listed the float32 RVV kernels (6x16, 8x16); the float64 one is 6x8, as ndarray v0.42.0 README says. The other entries match that README. Refs go-ndarray/ndarray#122 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled
added a commit
to go-ndarray/docs
that referenced
this pull request
Nov 15, 2026
* docs: ndarray v0.42.0 Every mirrored page, hugo.yaml (version and baseURL /docs/0.42/) and the README now point at v0.42.0. roadmap.md (docs/plan-ndarray.md) and security.md (SECURITY.md) are re-synced from v0.42.0, since their sources changed: the GEMM is github.com/go-blas/blas v0.2.1, through internal/blasmm, and the audit log gains the 2026-11-15 entry. The home page says the same. The other mirrored sources (dtypes, linalg, performance, random, accuracy) are unchanged between v0.41.3 and v0.42.0 and are only relabelled. performance-history.md is history and is left alone. Refs go-ndarray/ndarray#122 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs: fix claims in the v0.42.0 bump Say the GEMM code moved to go-blas/blas byte for byte (no bit-identity claim), label the perf table as measured at v0.41.0, and mirror SECURITY.md verbatim ("unreleased" in both audit entries, as the source has it). Refs go-ndarray/ndarray#122 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- 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
* landing: ndarray v0.42.0 The card says "library · v0.42.0". The ndarray blurb, the "Linear algebra" family and the hero text say MatMul and Dot run on go-blas/blas v0.2.1, with the same kernels as before: ndarray stopped carrying its own GEMM in v0.42.0. The SIMD card is about ndarray's own kernels (sum, elementwise, dot), still go-asmgen, and stays as it was. The playground builds against ndarray v0.42.0 (go-blas/blas v0.2.1 comes with it); its tests pass. Refs go-ndarray/ndarray#122 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * landing: correct the float64 RVV micro-kernel size The blurb listed the float32 RVV kernels (6x16, 8x16); the float64 one is 6x8, as ndarray v0.42.0 README says. The other entries match that README. Refs go-ndarray/ndarray#122 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Nov 15, 2026
…udit entries docs/linalg.md and docs/design-linalg.md named the ndarray package's own GEMM; since #122 it is go-blas/blas. SECURITY.md: the go-blas entry is v0.42.0 (#122, commit 208bdac, tag v0.42.0 contains it); the Choice gather entry is v0.40.2 (#115, 8ac94fb, first tag containing it, Refs #103). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Nov 15, 2026
… v0.23.0; Round is half to even, add RoundHalfAway (#123) * perf: float64 Abs, Neg, Square, Floor, Ceil on go-simd/floats v0.23.0 kernels Bump go-simd/floats to v0.23.0 and route the contiguous float64 case of Abs, Neg, Square, Floor and Ceil through its SIMD kernels, still split across cores above kernels.ParThreshold. Results are bit for bit those of math.Abs, -x, x*x, math.Floor and math.Ceil (a signalling NaN may come back quieted). Round is unchanged: it rounds half away from zero, which floats.RoundEven does not. On 10^5 float64, one core of cfarm420: Abs 244-258 -> 70-75 us, Neg 243-249 -> 72-75, Square 243-247 -> 72-80, Floor 432-457 -> 73-81, Ceil 437-464 -> 72-81 (result allocation included). Refs #118 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs: GEMM now in go-blas/blas; release tags for the two unreleased audit entries docs/linalg.md and docs/design-linalg.md named the ndarray package's own GEMM; since #122 it is go-blas/blas. SECURITY.md: the go-blas entry is v0.42.0 (#122, commit 208bdac, tag v0.42.0 contains it); the Choice gather entry is v0.40.2 (#115, 8ac94fb, first tag containing it, Refs #103). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * feat!: Round is half to even (np.round) on the RoundEven kernel; add RoundHalfAway Round now rounds exact halves to the even neighbour on every dtype (float64 on the go-simd/floats RoundEven kernel; float32 and each part of a complex number through math.RoundToEven), as np.round with no decimals. The old half-away-from-zero behaviour (math.Round) is RoundHalfAway, on the scalar path, on the same dtypes. Integers and bools are unchanged by both. There is no decimals variant. Tests: halves and the edge table for both against math.RoundToEven and math.Round; Abs and Neg now compared with strict NaN bits, the others with is-NaN only. On 10^5 float64, cfarm420 one core: Round 325-340 -> 71-80 us; RoundHalfAway (control) 324-345 us. Refs #118 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * docs: exempt Array.RoundHalfAway from the perf table (no NumPy counterpart) TestPerf requires every public function to have a row or an exemption. RoundHalfAway rounds halves away from zero; np.round is half to even, which is Array.Round, so there is nothing to time it against. Refs #118 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 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.
What
MatMul,MatMul32and the linalg products callgo-blas/blas v0.2.1 (
DgemmStrided/SgemmStrided) instead of ndarray's own copy of the same GEMM, so there is oneimplementation again (go-blas/blas#1 moved it byte for byte).
internal/kernels:gemm.go,gemm_<arch>.go,gemm32_*,gemmua_other.go,gemm_generic.go, the GEMM tests (kernels,fences,
packRows8,TestGemmOneWorkerSameBits), the GEMM half of everygenerator in
asmgen/<arch>and of everysum_<arch>.s.internal/blasmm(an operand's row and column strides go togo-blas as they are: a transposed or
a[:, ::2]view is not copied; extent-1axes are normalised; a broadcast or reversed view is copied;
HasSgemmKernel()picks native float32 or the widening path),matvec.goanddot_<arch>.go(the mat-vec and dot code that shared fileswith the GEMM, moved unchanged),
TestMatMulOneWorkerSameBits.max/min, the thread pool,
hwcap(CPU detection of those kernels).docs/plan-ndarray.md.
Proofs
v0.1.0's; every block of both is byte-identical to the old file's, in order,
headers equal, on all six architectures (
hasFMAis in both files on amd64,by design: the dot kernel needs it).
float32; contiguous, transposed A and B, decimated A and B rows, sub-block,
reversed columns; sizes 1x1x1 to 300x301x302), is identical between the base
commit and this branch, on arm64 (Apple) and on amd64 (EPYC 7773X, FMA).
TestAccuracyBoundMatMulincluded; vet onamd64, arm64, 386, arm, loong64, ppc64le, riscv64, s390x; 0 uncovered blocks
on arm64.
Performance
cfarm420 (EPYC 7773X), one core (
GOMAXPROCS=1,taskset -c 9), base binaryagainst branch binary interleaved, 5 rounds, load 2.1 to 2.9, medians. Allocation
counts equal everywhere; bytes equal.
a[:, ::2]n=64 / 256 / 1024The
a[:, ::2]case was 1.5x slower through go-blas v0.2.0 at n=1024 as a copyand 1.15-1.45x slower at small n through its element-wise scaling of C; v0.2.1
(go-blas/blas#3) removed both.
Open defect: n=64 float64 is still 1.06x (1 us) and float32 1.05x slower,
beyond the noise of those runs: it is the entry's own cost (argument checks,
operand normalisation) beside an 17 us product. Not fixed here; it needs a
profile of
DgemmStridedat small sizes.Refs #118, go-blas/blas#1, go-blas/blas#3
🤖 Generated with Claude Code