Repository navigation
Commit 554ec70
committed
GPU: give Metal an IEEE-754 binary64 in software
Metal Shading Language has no double at all, and the tracking needs one in a
handful of places: the track parametrisation, the propagator and the material
budget all carry double members and do double arithmetic.
GPUCommonDoubleBinary64.h implements binary64 on top of a 64-bit integer. Round
to nearest even only, with subnormals, infinities and NaNs, and NaN propagation
in the ARM64 order, so an Apple host is a bit-exact reference down to the
payload. Addition, subtraction, multiplication, division and the conversions to
and from float and the 32-bit integers are exact; sin and cos are fdlibm's and
land within 2 ulp of libm. There is no fused multiply-add and no square root.
GPUCommonMath's own double helpers cannot serve the class: SinCosd's OpenCL arm
passes the cosine by pointer where MSL takes a thread reference, so it does not
compile, and Abs<double> is worse because it does -- fabs resolves to
metal::fabs(float) through the implicit conversion, with no error and no warning,
rounding the mantissa away at 17 call sites including the SMatrixGPU pivot
selection and the Kalman guards against Almost0 and Almost1. Both are defined for
Metal in GPUCommonDouble.h instead, and a static_assert there turns the silent
case into a compile error, since metal::fabs is not constant-evaluable.
The Metal entry point aliases the double keyword to the class, so the shared
headers go on saying double and no call site changes. The header refuses to
build anywhere else, since every other backend has a real double.
It costs of the order of a hundred times plain float on an M-series GPU, which
the tracking can afford because double is a small fraction of its floating point
work. In exchange a Metal build reproduces the CPU result bit for bit wherever
it uses only the exact operations.1 parent f16249a commit 554ec70
4 files changed
Lines changed: 618 additions & 2 deletions
File tree
- DataFormats/Reconstruction/src
- GPU
- Common
- GPUTracking/Base/metal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
641 | | - | |
| 641 | + | |
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
| |||
0 commit comments