Optimize x86 BF16 GEMM micro kernels: replace vpalignr with vpshufd and add instruction scheduling#6673
Merged
Merged
Conversation
…nd add instruction scheduling On AMD Zen 5, the vpalignr instruction generated by GCC for _mm*_alignr_epi8(x,x,N) conflicts with vdpbf16ps for execution port resources, causing ~16% performance loss on the 16x16 micro kernel compared to Clang (which auto-replaces vpalignr with equivalent shuffles). Replace all _mm*_alignr_epi8(x,x,8) with _mm*_shuffle_epi32(x, _MM_PERM_BADC) and _mm*_alignr_epi8(x,x,4) with _mm*_shuffle_epi32(x, _MM_PERM_ADCB) in the AVX512BF16 kernel sections, which generate vpshufd instructions using different execution ports. Also apply interleaved instruction scheduling for the 16x16 kernel to further overlap shuffle and dpbf16ps computation latency.
Member
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6673 +/- ##
========================================
Coverage 93.98% 93.99%
========================================
Files 926 926
Lines 298707 298127 -580
========================================
- Hits 280736 280218 -518
+ Misses 17971 17909 -62 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 AMD Zen 5, the vpalignr instruction generated by GCC for _mm*_alignr_epi8(x,x,N) conflicts with vdpbf16ps for execution port resources, causing ~16% performance loss on the 16x16 micro kernel compared to Clang (which auto-replaces vpalignr with equivalent shuffles). Replace all _mm*_alignr_epi8(x,x,8) with _mm*_shuffle_epi32(x, _MM_PERM_BADC) and _mm*_alignr_epi8(x,x,4) with _mm*_shuffle_epi32(x, _MM_PERM_ADCB) in the AVX512BF16 kernel sections, which generate vpshufd instructions using different execution ports. Also apply interleaved instruction scheduling for the 16x16 kernel to further overlap shuffle and dpbf16ps computation latency.
glm-5.1
36.9M input, 168.5k output, 36.3M cache read, 0 cache write