fix(emitc): drain MTE before pto.comm.tnotify lowering#718
Merged
Conversation
TNOTIFY_IMPL writes the signal on the scalar pipe and only issues pipe_barrier(PIPE_ALL) *after* the store. Prior pto.tload / pto.tstore ops (local or peer-addressed) can still be in flight on MTE2/MTE3 when the signal lands, breaking the notify/wait handshake -- the receiver's TWAIT returns before the data is visible. Emit pipe_barrier(PIPE_ALL) right before the pto::comm::TNOTIFY call in PTOToEmitC so the lowering itself honors the contract, with no caller-side workaround required. - lib/PTO/Transforms/PTOToEmitC.cpp: add emitTNotifyMteDrain helper and call it from PTOSignalCommToEmitC for the TNotifyOp branch only (TWAIT/TTEST do not need the extra drain). - test/lit/pto/issue711_tnotify_mte_drain.pto: regression covering tstore->tnotify, tload->tnotify, and confirming twait does not get the new drain. - docs/PTO_IR_manual.md: document the lowering ordering guarantee. Fixes #711 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request addresses Issue #711 by ensuring that the lowering of pto.comm.tnotify drains MTE-side pipes before emitting the pto::comm::TNOTIFY call. This is achieved by inserting a pipe_barrier(PIPE_ALL) immediately before the call, preventing race conditions where a signal store on the scalar pipe could overtake in-flight pto.tload or pto.tstore operations. The changes include updates to the IR manual, the EmitC lowering implementation, and a new regression test suite. There are no review comments to address.
Codex Review该评论由 review 机器人自动更新。
SummaryReview failed at stage Findings未生成结构化 findings,因为 review 过程提前失败。 Log Tail |
A5 板测成功
|
A3 板测失败
失败用例
|
A3 板测失败详情:PR #718down_proj_residual
out_proj_residual
syncall_binding
tprefetch_async_binding
|
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
pto.comm.tnotifylowering currently emitspto::comm::TNOTIFY(...)with no MTE-side drain. Inside the runtime,TNOTIFY_IMPLwrites the signal on the scalar pipe and only issuespipe_barrier(PIPE_ALL)after the store. Any priorpto.tload/pto.tstore(local or peer-addressed) can still be in flight on MTE2/MTE3 when the signal lands, so the receiver's matchingTWAITreturns before the data is visible -- breaking the notify/wait contract.This change inserts
pipe_barrier(PIPE_ALL)immediately before the generatedpto::comm::TNOTIFY(...)so the lowering itself honors the contract and callers do not need any manual sync.Changes
lib/PTO/Transforms/PTOToEmitC.cpp: addemitTNotifyMteDrainhelper and invoke it fromPTOSignalCommToEmitCon theTNotifyOpbranch only (TWAIT/TTEST do not need the drain).test/lit/pto/issue711_tnotify_mte_drain.pto: new regression coveringtstore -> tnotify,tload -> tnotify, and assertingtwaitdoes not receive an extra drain.docs/PTO_IR_manual.md: document the lowering ordering guarantee underpto.comm.tnotify.Fixes #711
Test plan
ninja -C build-main-wsl tools/ptoas/ptoas(clean build with the new helper).build-main-wsl/tools/ptoas/ptoas --pto-arch=a3 test/lit/pto/issue711_tnotify_mte_drain.pto -o -showspipe_barrier(PIPE_ALL);directly beforepto::comm::TNOTIFY(...)in the emitted EmitC.llvm-lit -svonissue711_tnotify_mte_drain.pto,comm_p2p_emitc.pto, andcomm_collective_emitc.pto-- all pass.ninja check-pto-- only the two pre-existing untracked-branch failures remain (graph_sync_solver_section_scope.pto,multi_buffer_gss_dyn_event_id.pto); confirmed they also fail against pristinelib/PTO/Transforms/PTOToEmitC.cppfrommain.Notes
🤖 Generated with Claude Code