Repository navigation
perf: float32 MatMul on the float64 GEMM - #65
Merged
Merged
Conversation
float32 MatMul ran a generic triple loop, 9x slower than our float64 GEMM. It now widens the operands (exact, O(n^2)), runs the packed, cache-blocked SIMD float64 GEMM, and rounds each element once to float32: at least as accurate as a BLAS sgemm accumulating in float32, on every architecture at once. abbench, 5 rounds, pinned core, float32 MatMul 64^2 / 256^2: POWER9 -77% / -87%, Zen 3 -77% / -90%; float64 flat. TestMatMulFloat32: exact on integer-valued operands, float32 precision against the triple loop on random ones, float32 dtype kept. The float32 case leaves the generated matmulStore (dead now). 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
MatMulran a generic triple loop, 9× slower than our own float64 GEMM on a POWER9.Change. float32 now runs on the float64 GEMM:
That is at least as accurate as a BLAS sgemm, which accumulates in float32, and every architecture gets its existing micro-kernel at once. The result keeps the float32 dtype.
Measured with
abbench: alternated, 5 rounds, pinned core.MatMulfloat32 is now within the widening of float64. On the POWER9 that is 86.7 against 54.0 µs at 64², and 2.56 against 2.25 ms at 256². A native float32 GEMM, with twice the lanes per register and half the bytes, is the next step for products; it is recorded in
docs/perf.md.Tests.
TestMatMulFloat32(40×50×30, large enough for the blocked path):The float32 case leaves the generated
matmulStore, where it is now dead. The local coverage gate (covblocks) reports 0 uncovered blocks.A minor release, v0.21.0.
🤖 Generated with Claude Code