linalg/mmm: L3-resident outer tier for the single-thread block walk#2350
Open
czoli1976 wants to merge 2 commits into
Open
linalg/mmm: L3-resident outer tier for the single-thread block walk#2350czoli1976 wants to merge 2 commits into
czoli1976 wants to merge 2 commits into
Conversation
Contributor
Author
Contributor
Author
Contributor
Author
|
To set expectations: Expect gain on Cortex-A7X (A72…A78 / A710 / A715 — big cores) and any other Big Boy CPU (not on A5x as no L3 Cache over there) |
The single-thread MMM block-budget probed L2 with detection logic inlined in frame/mmm/mod.rs, reusable nowhere and limited to macOS/Linux L2. Move it into a cache module that exposes L1d/L2/L3 through one memoised probe (macOS/iOS via sysctlbyname, Linux/Android via /sys, Windows via wmic) and have the block budget read it. The existing L2 budget is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…walk The single-thread tile walk blocked one level, sizing panel blocks to L2 only; at large k a grid that exceeds L2 still re-fetches shared A/B panels from DRAM as it sweeps. Wrap the L2 inner block in an outer super-block sized to L3 (from the crate::cache probe) so a group of inner blocks stays L3-resident across the sweep. The outer tier engages only when an L3 larger than L2 is detected; otherwise the edge is the whole grid and the walk is identical to before. Still pure tile reordering, so bit-exact with the naive loop. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
61d01bc to
d30c3de
Compare
Collaborator
|
Rebased! |
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.

Stacked on #2349 (the reusable
cachemodule). GitHub can't target a fork branch as the base, so this PR is opened againstmainand currently shows both commits — the first is #2349's cache module, the second (linalg/mmm: add an L3-resident outer tier…) is the actual content here. Once #2349 merges I'll rebase and the diff will drop to the single L3 commit. Please review only the top commit; merge #2349 first.Adds a second cache-blocking tier to the single-thread MMM tile walk: the existing L2-resident inner block is wrapped in an outer super-block sized to L3, so a group of inner blocks stays L3-resident as the walk sweeps the grid (instead of re-fetching shared A/B panels from DRAM at large k).
The outer tier engages only when
cache::cache_info()reports an L3 larger than L2; otherwise the outer edge spans the whole grid and the walk is byte-for-byte the current single-tier loop. Either way it's pure tile reordering — each tile still computes its own full-k reduction into a disjoint output region — so it stays bit-exact with the naive loop. The nesting is extracted intofor_each_blocked_tileand unit-tested (visits every tile exactly once across single-tier / two-tier / degenerate edges; the no-L3 path matches the original order exactly).Not yet benchmarked — hence draft. Apple Silicon doesn't expose
hw.l3cachesize, so the outer tier is a guaranteed no-op on the hardware I can test; it only engages on x86/Linux boxes that report L3 via/sys. It's regression-safe by construction (no-op without L3, bit-exact with it), but the speedup claim needs an A/B on an L3-reporting machine at a large-k shape (grid > L2, super-block ⊂ L3).Verified on Apple M-series: full
tract-linalgsuite green (incl. the real blocked-path bit-exactness tests + the new nesting tests),cargo fmt --allclean, no new clippy findings.Citation for standard multi-level cache-blocked GEMM: