Repository navigation
fix[next-dace]: skip failing inout data instead of whole map in local double buffering - #2941
Merged
edopao merged 5 commits intoOct 8, 2026
Merged
Conversation
… double buffering `_check_if_map_must_be_handled` in `local_double_buffering.py` bailed on the entire map (`return None`) when a single inout data failed the subset compatibility check, instead of skipping just that data like the other two checks in the same loop did (`inout_datas.pop(...); continue`). This suppressed double buffering for all inout datas, including ones that need it to prevent a WAR hazard after `GT4PyMapBufferElimination` inlines the write-back into the Map body. Fix: `return None` → `inout_datas.pop(inout_data_name); continue`. Adds `test_local_double_buffering_war_hazard` in `test_create_local_double_buffering.py` which builds a WAR hazard SDFG, applies `GT4PyMapBufferElimination(assume_pointwise=True)`, then `gt_create_local_double_buffering`, and verifies correct numerical results (reader sees the OLD value of G). This implements the reviewer's preferred approach on PR GridTools#2815 (fixing `gt_create_local_double_buffering` instead of blocking the buffer elimination in `simplify.py`).
2 tasks done
philip-paul-mueller
approved these changes
Oct 8, 2026
philip-paul-mueller
left a comment
Contributor
There was a problem hiding this comment.
Some small comments about the tests, but looks okay.
Contributor
Author
|
cscs-ci run default |
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.
Problem
_check_if_map_must_be_handledinlocal_double_buffering.pybailed on the entire map (return None) whenever a single inout data failed the subset compatibility check (all_inner_subsets[0] == all_inner_subsets[i]). This was inconsistent with the other two checks in the same loop (the "already buffered" check and the "not scalar" check), which correctly didinout_datas.pop(inout_data_name); continueto skip just the failing data.As a result, in a Map with multiple inout datas, if one data had mismatched read/write subsets,
return Nonesuppressed double buffering for all inout datas — including ones that genuinely need it to prevent a write-after-read (WAR) hazard afterGT4PyMapBufferEliminationinlines the write-back into the Map body.Fix
Changed
return None→inout_datas.pop(inout_data_name); continuein_check_if_map_must_be_handled(local_double_buffering.py:418-419), consistent with the two other checks in the same loop.This implements the reviewer's (philip-paul-mueller) preferred approach on PR #2815:
Instead of blocking the buffer elimination in
simplify.py(PR #2815's approach), the fix letsGT4PyMapBufferElimination(assume_pointwise=True)proceed and relies ongt_create_local_double_bufferingto insert a local double buffer that sequences the read before the write.Test
Added
test_local_double_buffering_war_hazardintest_create_local_double_buffering.py:Gon one branch and writesG(via atmpbuffer) on an independent branch:O(i) = G(i) + 1.0andG(i) = 2.0 * A(i).GT4PyMapBufferElimination(assume_pointwise=True)— asserts it fires (inlines the write-back).gt_create_local_double_buffering— asserts it fires (inserts the double buffer).O = G_old + 1.0andG = 2.0 * A(the reader sees the OLD value of G, not the newly written one).QA
test_create_local_double_buffering.py: 6 passed (5 existing + 1 new)test_map_buffer_elimination.py: 10 passedtransformation_tests/directory: 334 passed, 3 xfailedpre-commit run(ruff, mypy, tach, license): cleanuv run mypy src/gt4py/next/program_processors/runners/dace/transformations/local_double_buffering.py: no issuesuv run tach check: all modules validated