Repository navigation
perf(gemm): read a row-major B in place on the small-product path - #82
Merged
Merged
Conversation
BLIS's sup kernels pack neither operand: the "rv" kernel advances B by its row stride (b += rs_b, bli_gemmsup_rv_haswell_asm_s6x16m.c line 401). The A-in-place kernels (gemmUA*, amd64 and arm64) now take B's row stride, ldb, and step B by it instead of by the packed panel's width. A packed panel passes its own width, so one kernel serves both. On the serial path (below GemmThreshold), with both operands row-major, packGemmRows packs only the partial last B panel, and gemmBandUA reads the full panels in place. The parallel path still packs B once for all workers. abbench, 10 rounds, one core, against v0.29.0: Zen 3 float32 64² -16%, float64 64² -10%, 256²/1024² unchanged N1 float32 64² -7.3%, the rest unchanged (contended host) Zen 3 float32 64² is now at parity with NumPy (8.02 vs 8.14 µs). Tests: every GEMM case runs with (unpackA, unpackB) = (on, on), (on, off) and (off, off). The fences add a strided B flush against a guard page. A sabotaged kernel that ignores ldb fails 13 tests on arm64 and 9 GEMM tests on amd64. 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.
On the small-product path, a row-major B is now read in place, as BLIS's sup kernels do (
b += rs_b). The A-in-place kernels take B's row strideldb; a packed panel passes its own width. Only the partial last panel is still packed, and the parallel path is unchanged.MatMulvs v0.29.0, abbench 10 rounds, 1 coreZen 3 float32 64² is now at parity with NumPy (8.02 vs 8.14 µs). The N1 host was contended (rows up to ±39%), so its "~" rows mean only that there is no regression.
Tests and checks:
ldbfails 13 tests on arm64 and 9 GEMM tests on amd64 (run on Zen 3).🤖 Generated with Claude Code