i[gfx1250] Switch BF16 GEMM LDS loads to ds_read_b256, +0.4 TB/s - #1077
Open
amd-hhashemi wants to merge 1 commit into
Open
i[gfx1250] Switch BF16 GEMM LDS loads to ds_read_b256, +0.4 TB/s#1077amd-hhashemi wants to merge 1 commit into
amd-hhashemi wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to improve gfx1250 BF16/FP16 GEMM performance by changing the LDS operand load path to use wider 256-bit LDS reads (ds_read_b256), adjusting LDS row padding/alignment, and updating the expected DS-read accounting per WMMA K-step.
Changes:
- Increase LDS row padding (
LDS_PAD) to 32 bytes to support 32-byte alignment for intended 256-bit LDS reads. - Switch operand fragment loads from 128-bit LDS reads to a 256-bit LDS read path and update the per-K-step DS-read count.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| wmb = wave_m * warp_tile_m | ||
| wnb = wave_n * warp_tile_n | ||
| lds_load_b128, _ = make_lds_copy_ops(128) | ||
| lds_load_b256, _ = make_lds_copy_ops(256) |
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.
Summary
The BF16 GEMM kernel on gfx1250 reads WMMA operand fragments from LDS using two ds_read_b128 instructions per fragment (16 bytes
each, 32 bytes apart), followed by a shuffle. This halves the effective latency-hiding window per K-step — there are only 2×KS_DS
issue slots between read issuance and the s_wait_dscnt stall, which is shorter than LDS round-trip latency at this tile size,
causing exposed wait cycles visible in ATT traces.
This PR switches to a single ds_read_b256 (32 bytes) per fragment by:
accesses.
batch has to complete before its s_wait_dscnt.
gets K-elements 0–15, kgrp=1 gets K-elements 16–31 (sequential split, verified correct by the WMMA instruction's input layout on
gfx1250).
The TDM prefetch issue() is also moved to before the WMMA K-step loop so the sched_barrier pair doesn't interrupt the expert
scheduler's mid-loop read/WMMA interleaving.
Result
~3% bandwidth improvement on the target shape (M=64, N=65536, K=16384, tiles=64×256×128, warps=1×4, nb=3). Verified correct on
multiple shapes.
Test plan
correctness PASS, BW improvement visible
Technical Details
Test Plan
Test Result
Submission Checklist