Commit d969d6e
authored
CMake:
## Summary
Add new general compiler flag for fast-math optimizations.
https://en.wikipedia.org/wiki/Floating-point_arithmetic#%22Fast_math%22_optimization
**This PR does not yet change any defaults (see details below).**
Close #1769
## Proposed Breaking Change
By default, AMReX turned fast-math OFF for all backends (serial,
CPU/OpenMP, SYCL GPU, HIP GPU) besides:
- CUDA GPUs (both GNUmake & CMake)
- a single, legacy [cray compiler in
GNUmake](https://github.com/AMReX-Codes/amrex/blob/25.07/Tools/GNUMake/comps/cray.mak)
I propose to amend this PR to:
- remove the `AMReX_CUDA_FASTMATH` flag (default: ON)
- alternatively: fade it out and set its default value to
`AMReX_FASTMATH`
- turn `AMReX_FASTMATH` to `OFF` by default for all backends.
Contrary to turning it `ON` by default, users of most backends will not
be surprised by a sudden change in numerical results.
### Breaking:
- Users that support fast-math, which might be many will see a sudden
drop of performance on CUDA GPUs.
### Recommended migration:
- If you already benchmarked correctness on CUDA GPUs, I recommend to
intentionally set in your projects `-DAMReX_FASTMATH=ON` for all
backends, to get the performance benefits on CPUs, Intel and AMD GPUs as
well.
## Additional background
As HPC team, we should strive to make our numerics as robust as possible
under fast-math optimizations. Without those, your compiler will barely
auto-vectorize, will not replace simple optimizations like `x / 2.` with
`x * 0.5` and many other optimizations that rely on agressive
re-ordering.
Fast-math floating point math is an important aspect to consider and
support for significant performance improvements on all modern
architectures.
## Checklist
The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [x] add new capabilities to AMReX
- [x] changes answers in the test suite to more than roundoff level
- [x] are likely to significantly affect the results of downstream AMReX
users
- [x] include documentation in the code and/or rst files, if appropriateAMReX_FASTMATH (#4545)1 parent 37cf3e9 commit d969d6e
File tree
7 files changed
+49
-2
lines changed- Docs/sphinx_documentation/source
- Tools/CMake
7 files changed
+49
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
| 447 | + | |
446 | 448 | | |
447 | 449 | | |
448 | 450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
256 | 268 | | |
257 | 269 | | |
258 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
| |||
350 | 355 | | |
351 | 356 | | |
352 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
353 | 363 | | |
354 | 364 | | |
355 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
| |||
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
149 | 165 | | |
150 | 166 | | |
151 | 167 | | |
152 | 168 | | |
153 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
154 | 175 | | |
155 | 176 | | |
156 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
0 commit comments