Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix[next][dace]: Fix array subset on the branches of if-expressions #1912

Merged
merged 16 commits into from
Mar 21, 2025

Conversation

edopao
Copy link
Contributor

@edopao edopao commented Mar 13, 2025

The issue was discovered by Philip (@philip-paul-mueller).

The lowering of if-expressions has to ensure that all branches (e.g. if/then states) write the same subset to the result array. This was not the case in baseline when one the branches contained a simple expression such as {dwdx, dwdy}. The bug was that the full shape of the global fields was copied into the result array, although the result array was allocated on a sub-domain. This caused an out-of-bound write and a segfault.

@edopao edopao changed the title fix[next][dace]: Set both source and destination subset for array-to-array memlet copy fix[next][dace]: Fix array subset on the branches of if-expressions Mar 14, 2025
else:
# TODO(edopao): this is a workaround for some IR nodes where the inferred
# domain on a tuple of fields is not a tuple, see `test_execution.py::test_ternary_operator_tuple()`
domain_tree = gtx_utils.tree_map(lambda _: node.annex.domain)(symbol_tree)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tehrengruber I am using a workaround because domain inference does not create a tuple, as expected, in test_execution.py::test_ternary_operator_tuple()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As agreed, I am going to use an API to correctly retrieve the annex domain when it is available.

Copy link
Contributor

@philip-paul-mueller philip-paul-mueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some things that should be changed (especially the sharing of some variables used as subset) but there is nothing big.
However, we should wait for the feedback of Till.

@edopao edopao force-pushed the gtir-dace-array_memlet branch from dbe2ffc to bf48f00 Compare March 21, 2025 06:43
Copy link
Contributor

@philip-paul-mueller philip-paul-mueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my side it looks okay, but I would wait for Till's feedback.

@edopao
Copy link
Contributor Author

edopao commented Mar 21, 2025

From my side it looks okay, but I would wait for Till's feedback.

Thanks for the review. I have already discussed the domain inference problems with Till, there will be some utility functions to get the tuple domain (and the domain range in general, which might be useful in multiple places of the SDFG lowering).

@edopao edopao merged commit db566d6 into GridTools:main Mar 21, 2025
28 checks passed
@edopao edopao deleted the gtir-dace-array_memlet branch March 21, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants