Repository navigation
x86: claim affine2p output lines with PREFETCHW; drop input prefetches - #52
Merged
Merged
Conversation
On a Xeon Gold 6150 (Skylake-SP), gap-affine 2-piece high-memory CIGAR was store-buffer bound: the AVX2 kernel's five output stores go to fresh lines, whose ownership requests (RFOs) missed L2 ~1.8x as often as in C's kernel, leaving 4.67 G cycles of store-buffer-full stalls against C's 0.38 G. The kernel now issues PREFETCHW on its five outputs 32 diagonals (two lines) ahead, and all x86 input prefetches are removed (the hardware prefetcher covers those sequential streams; they did not help in A/B). 32 beat 64 and 128 diagonals. Xeon, time vs before: affine2p CIGAR 0.88x, banded 0.65x, 10 kb 0.89x, score 0.93x, BiWFA 0.95x; store-buffer stalls 4.63 G -> 0.43 G cycles. EPYC 7713: 2-6% faster on most affine2p cases, the rest within noise. ARM is unchanged. Output identical in every A/B case on both machines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
16 of 22 tasks
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.
Part of #31. Closes the Xeon (Skylake-SP) affine2p CIGAR gap.
Problem
After #49, the Xeon Gold 6150 was the only machine where gap-affine 2-piece high-memory CIGAR wasn't faster than C:
Cause
Measured with
perfon the Xeon, posted in #31.Change
PREFETCHWon its five output arrays, 32 diagonals (two cache lines) ahead. Prefetch addresses usewrapping_offset.aligner.rsand the in-kernel ones inaffine.rs/affine2p.rs. The hardware prefetcher already covers these sequential streams.Results
A/B at
45f419e, best of 3. Time relative tomain; 32, 64 and 128 are the prefetch distance in diagonals:Testing
mainin all 16 A/B cases across both machines (six builds each). Under Rosetta, the AVX2 build matches C on affine2p high, BiWFA and med, and gap-affine high.cargo test --release: 271 passed.cargo clippy --all-targets -D warnings: clean on ARM, x86-64 and x86-64-v3.docs/performance.mdstays pinned tofc51088, so its Xeon numbers predate this change. The next refresh of the README table would pick it up.🤖 Generated with Claude Code