Avoid invalid in AMReX_MFInterp_3D_C.H#5215
Merged
WeiqunZhang merged 3 commits intoAMReX-Codes:developmentfrom Mar 25, 2026
Merged
Avoid invalid in AMReX_MFInterp_3D_C.H#5215WeiqunZhang merged 3 commits intoAMReX-Codes:developmentfrom
WeiqunZhang merged 3 commits intoAMReX-Codes:developmentfrom
Conversation
WeiqunZhang
requested changes
Mar 21, 2026
| // This avoids the invalid signal from being triggered when | ||
| // if-conversion optimization is done, where this code is | ||
| // predictively executed even though dumax is zero. | ||
| dumax = dumax == Real(0.) ? Real(1.) : dumax; |
Member
There was a problem hiding this comment.
Could you add to the comments something like below?
In normal execution, dumax is always positive because at least one of the three terms in its definition is positive, so the following statement is effectively a no-op.
I initially thought the added guard needed to be moved into the if block because dumax is used in the condition and modifying it could change the outcome of the test. I had to go back more than 10 lines to realize that it could never happen.
WeiqunZhang
approved these changes
Mar 25, 2026
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
This PR is here to avoid a false positive invalid flag being raised in `AmrCore/AMReX_MFInterp_3D_C.H. The change ensures that dumax is never zero for the divides. This avoids the invalid signal from being triggered when if-conversion optimization is done, where this code is predictively executed even though dumax is zero.
Several checks demonstrate that the change does not break vectorization. Also, the change should have no effect on results since under normal conditions, the divide by dumax would never happen if dumax is zero.
Additional background
Checklist
The proposed changes: