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

copy Kokkos implementation of min/max/clamp #565

Open
BenWibking opened this issue Mar 16, 2024 · 0 comments
Open

copy Kokkos implementation of min/max/clamp #565

BenWibking opened this issue Mar 16, 2024 · 0 comments
Labels
enhancement New feature or request floating-point issue with floating-point roundoff error

Comments

@BenWibking
Copy link
Collaborator

BenWibking commented Mar 16, 2024

Describe the proposal
Different C++ standard library implementations implement std::min, std::max and std::clamp in incompatible ways. We can avoid this by implementing these functions ourselves, e.g. by copying the implementation from Kokkos:
https://github.com/kokkos/kokkos/blob/master/core/src/Kokkos_MinMaxClamp.hpp

Describe alternatives you've considered
We could use the amrex::min and amrex::max implementation, but those actually call the C++ standard library implementation: https://github.com/AMReX-Codes/amrex/blob/3fe7aadc23c94a038b306af54ff732ce5564c3d1/Src/Base/AMReX_Algorithm.H#L23, which leaves us with the same problem as before.

Additional context
There are weird numerical edge cases with comparisons with different compilers and different C++ standard libraries with comparisons of NaN, inf, and denormals.

@BenWibking BenWibking added enhancement New feature or request floating-point issue with floating-point roundoff error labels Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request floating-point issue with floating-point roundoff error
Projects
None yet
Development

No branches or pull requests

1 participant