fix[next-dace]: do not relocate distributed buffer write back into loop bodies - #2818
Open
edopao wants to merge 2 commits into
Open
fix[next-dace]: do not relocate distributed buffer write back into loop bodies#2818edopao wants to merge 2 commits into
edopao wants to merge 2 commits into
Conversation
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
DistributedBufferRelocatorcan move the final write back of a temporary into a state nested inside aLoopRegion. The write back then executes in every loop iteration on data that the loop has only written partially, racing with the per-iteration partial writes and producing nondeterministic garbage in the unaffected parts of the output.This is what broke the
scantests on therun_dace_stree_*backends in #2690 (e.g. CI run 32715667466): for a scan, the state that (partially) defines the scan temporary is the scan loop body, and the full-array write back after the loop was relocated into it.Enabler: since DaCe 2.0,
SDFG.states()recurses into control-flow scopes (return list(self.all_states())), sofind_upstream_states()now also discovers loop-body states as candidate definition locations — on top-level-only semantics this relocation could never have happened.Fix
Never relocate into a state that is (transitively) nested inside a
LoopRegion:_find_candidates()now skips such definition states via the new_is_inside_loop()helper. Relocation into conditional branches — the use case this pass was designed for — remains legal, as does any relocation into states that are not executed repeatedly.Test
New unit test
test_distributed_buffer_definition_in_loopbuilds the scan-shaped SDFG (per-iteration write oft[k]inside a loop body, full write backt -> bin the state after the loop) and asserts that the write back stays after the loop and that no write to the output is added inside the loop. The test fails without the fix (the pass relocates into the loop body) and passes with it.Validation
transformation_tests/unit suite: 326 passed, 3 xfailed (pre-existing).test_scan.py::test_solve_triagandtest_icon_like_scan.pyacross all fourrun_dace_stree_*backends).