-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug[next]: Fix shift / remap lowering (#1231)
While working on something else I recognized a rather sneaky bug in the lowering of shifts from FOAST to ITIR. Contrary to the rest of the lowering we were not wrapping the shifts inside a lifted stencil, which can lead to bugs in user code. This is particularly devastating when executing with the gtfn backend in Release Mode, as you might just run into a segfault or incorrect results. I am actually rather surprised this did not surface earlier somewhere as something like this ```python @field_operator(backend=fieldview_backend) def composed_shift_unstructured_intermediate_result( inp: Field[[Vertex], float64] ) -> Field[[Cell], float64]: tmp = inp(E2V[0]) return tmp(C2E[0]) ``` lowers to the (incorrect) ITIR: ``` λ(inp) → ·(λ(tmp__0) → ⟪C2Eₒ, 0ₒ⟫(tmp__0))(⟪E2Vₒ, 0ₒ⟫(inp)) ``` (Note how the ordering of the shifts is wrong). I had found this bug much earlier while working on (#965), but sadly the change went lost while merging (was very easy to overlook so @havogt and me bost missed it). What I did not recognize back then was that this bug could actually be triggered. I assumed it only occurred for expression like `field(E2V[0])(C2E[0])` which were not allowed (for unrelated reasons). For completeness this PR also adds support for such expressions.
- Loading branch information
1 parent
cb76afa
commit 4998dec
Showing
8 changed files
with
148 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.