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

Update autodiff::dual to give the same results as amrex::Real #1612

Merged
merged 4 commits into from
Jul 17, 2024

Conversation

yut23
Copy link
Collaborator

@yut23 yut23 commented Jul 15, 2024

In my testing with converting the aprox* rates to use autodiff, I found a lot of instances where code templated with autodiff::dual would give slightly different values than the same code templated with amrex::Real. It turns out to be due to some optimizations autodiff makes to speed up evaluation, which this PR disables to avoid any weird inconsistencies in the future.

yut23 added 3 commits July 15, 2024 19:12
If AUTODIFF_STRICT_ASSOCIATIVITY is defined before including autodiff
headers, optimizations that break the left-to-right associativity of +
and * operators will be disabled. This uses more intermediate temporary
assignments, but should produce the exact same values between identical
code that uses `autodiff::dual` in place of `double`.

From yut23/autodiff@d7e3e99
@zingale
Copy link
Member

zingale commented Jul 16, 2024

this is upstreamed here: autodiff/autodiff#352

@zingale
Copy link
Member

zingale commented Jul 16, 2024

@zingale
Copy link
Member

zingale commented Jul 17, 2024

all of the test_rhs diffs are roundoff error level

@zingale zingale merged commit a5d2e29 into AMReX-Astro:development Jul 17, 2024
28 checks passed
@yut23 yut23 deleted the fix-autodiff-evaluation-order branch July 17, 2024 21:07
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