[WIP] InsertSync: fix multi-buffer sync event selection#176
Closed
TaoTao-real wants to merge 2 commits intozhangstevenunity:mainfrom
Closed
[WIP] InsertSync: fix multi-buffer sync event selection#176TaoTao-real wants to merge 2 commits intozhangstevenunity:mainfrom
TaoTao-real wants to merge 2 commits intozhangstevenunity:mainfrom
Conversation
Multi-buffer (ping-pong) sync currently computes a per-iteration event id selector but still emits set_flag/wait_flag with a fixed EVENT_ID0. This breaks the intended back-edge synchronization for loop-carried UB reuse. Add pto.set_flag_dyn/pto.wait_flag_dyn to carry a dynamic event id SSA value, use them in SyncCodegen for multi-buffer sync, and lower them to emitc call_opaque with the operand in the argument list. Tests: extend sample runner guards and add a minimal python InjectSync sample to ensure generated C++ uses a dynamic event id for PIPE_MTE3->PIPE_MTE2.
Contributor
Author
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.
This fixes a correctness gap in
--enable-insert-syncfor multi-buffer (ping-pong) synchronization on loop back-edges.What was wrong
For some loop-carried UB reuse patterns, InsertSync allocates two event ids (e.g.
EVENT_ID0/1) and even builds an SSA selector (based oniv % 2).However, codegen still emitted
pto.set_flag/pto.wait_flagwith a fixedEVENT_ID0, effectively dropping the selector. This defeats the intended ping-pong behavior and can produce incorrect synchronization.What this PR does
pto.set_flag_dyn/pto.wait_flag_dynops that take the event id as an SSA value.sync->eventIds.size() > 1so the per-iteration selected event id is actually consumed.set_flag/wait_flagcalls with the event id operand properly placed in the argument list.Tests
bash test/samples/runop.sh alltest/samples/InjectSync/test_inject_sync_multibuf_loop.py.PIPE_MTE3 -> PIPE_MTE2multi-buffer sync.