Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement portable assumptions with AMREX_ASSUME (#3770)
## Summary This PR implements portable assumptions by defining a new `AMREX_ASSUME(assumption)` macro. In case the C++23 attribute [`[[assume(ASSUMPTION)]]`](https://en.cppreference.com/w/cpp/language/attributes/assume) is available, the macro simply becomes this attribute. Otherwise it becomes a builtin function, depending on the compiler. The macro is intended to be used as follows: ``` float f_test(float p) { AMREX_ASSUME(p >= 0); return std::clamp(p, 0.0f, 1.0f); } ``` ## Additional background Please use this link to test this implementation with the Compiler Explorer: https://godbolt.org/z/1Tz7v7v45 ## Checklist The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [X] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
- Loading branch information