[Codegen][GPU]Fixing barrier placement for 3+ stages pipelining - #22725
Merged
jerryyin merged 1 commit intoNov 24, 2025
Merged
Conversation
Signed-off-by: jerryyin <zhuoryin@amd.com>
jerryyin
requested review from
Groverkss,
MaheshRavishankar,
kuhar and
qedawkins
as code owners
November 21, 2025 15:26
nirvedhmeshram
approved these changes
Nov 21, 2025
nirvedhmeshram
left a comment
Contributor
There was a problem hiding this comment.
Makes sense, LGTM!
jerryyin
deleted the
users/zyin/refactor-pipeliner-using-upstream-v4-barrier
branch
November 24, 2025 15:16
bangtianliu
pushed a commit
to bangtianliu/iree
that referenced
this pull request
Nov 25, 2025
…-org#22725) In this PR, I created a new function insertBarriersInRange() that enforces shared-memory ordering by tracking two flags (needBarrierBeforeRead, needBarrierBeforeWrite) as it scans a block. This replaces the old barrier insertion routine as more shared read/write can be pushed to prologue and epilogue with 3+ stages of pipelining. Detailed description (copied from comments): Inserts synchronization barriers before shared memory accesses in the given range using a running `SharedBarrierState`. Conceptually, we track whether the next shared read (or write) must be preceded by a barrier, and only emit one when that flag is set. For example, 1) if the iteration sequence observes a shared read (R) followed by another read, nothing is inserted; the state only toggles `needBarrierBeforeWrite`, so the next shared write (W) will emit a barrier before it. 2) if the iteration sequence observes a shared write first toggles `needBarrierBeforeRead`, so the following read receives the barrier. This keeps the minimum number of synchronizations while still enforcing the R↔W ordering required by the pipelined schedule. Notes that all existing unit tests already have good coverage of barrier placement so this PR doesn't need one. The new functionalities will later be covered when 3 stage pipeline is added. Signed-off-by: jerryyin <zhuoryin@amd.com>
pstarkcdpr
pushed a commit
to pstarkcdpr/iree
that referenced
this pull request
Nov 28, 2025
…-org#22725) In this PR, I created a new function insertBarriersInRange() that enforces shared-memory ordering by tracking two flags (needBarrierBeforeRead, needBarrierBeforeWrite) as it scans a block. This replaces the old barrier insertion routine as more shared read/write can be pushed to prologue and epilogue with 3+ stages of pipelining. Detailed description (copied from comments): Inserts synchronization barriers before shared memory accesses in the given range using a running `SharedBarrierState`. Conceptually, we track whether the next shared read (or write) must be preceded by a barrier, and only emit one when that flag is set. For example, 1) if the iteration sequence observes a shared read (R) followed by another read, nothing is inserted; the state only toggles `needBarrierBeforeWrite`, so the next shared write (W) will emit a barrier before it. 2) if the iteration sequence observes a shared write first toggles `needBarrierBeforeRead`, so the following read receives the barrier. This keeps the minimum number of synchronizations while still enforcing the R↔W ordering required by the pipelined schedule. Notes that all existing unit tests already have good coverage of barrier placement so this PR doesn't need one. The new functionalities will later be covered when 3 stage pipeline is added. Signed-off-by: jerryyin <zhuoryin@amd.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.
In this PR, I created a new function insertBarriersInRange() that enforces shared-memory ordering by tracking two flags (needBarrierBeforeRead, needBarrierBeforeWrite) as it scans a block. This replaces the old barrier insertion routine as more shared read/write can be pushed to prologue and epilogue with 3+ stages of pipelining.
Detailed description (copied from comments):
Inserts synchronization barriers before shared memory accesses in the given range using a running
SharedBarrierState. Conceptually, we track whether the next shared read (or write) must be preceded by a barrier, and only emit one when that flag is set. For example,needBarrierBeforeWrite, so the next shared write (W) will emit a barrier before it.needBarrierBeforeRead, so the following read receives the barrier.This keeps the minimum number of synchronizations while still enforcing the R↔W ordering required by the pipelined schedule.
Notes that all existing unit tests already have good coverage of barrier placement so this PR doesn't need one. The new functionalities will later be covered when 3 stage pipeline is added.