Repository navigation
Commit 26b9b60
committed
GPU: only use GPUdoubleCalc where fast math is off
Metal defaults to fast math, and fast math reassociates GPUdoubleCalcImpl's
compensation terms away: measured on the full propagateTo kernel, the two-float
type then costs 1.57x for exactly the accuracy of a plain float.
The Metal build therefore follows what the OpenCL one already does: fast math
unless GPUCA_DETERMINISTIC_MODE asks for otherwise, and GPUdoubleCalc becomes a
plain float when fast math is on. This also takes back the unconditional
-fno-fast-math added with the type, which is not free as claimed there: on an
ALU-bound kernel it costs the plain float path a factor of two (0.055 ->
0.108 ns/propagate on an M1 Max), and that would have been paid by every Metal
kernel, including the clusterer and the sector tracker, which have no
double-precision intermediates at all.
-fmetal-math-mode=safe would keep the compensation intact for 20% less, but it
makes division and square root approximate and the GPU result then stops
matching the CPU bit-for-bit (79% of covariance elements instead of 100%), which
is the opposite of what deterministic mode is for. -fno-fast-math is also the
exact analogue of the CUDA flags used there, --prec-div --prec-sqrt --fmad false.1 parent 88e8ebc commit 26b9b60
3 files changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
0 commit comments