Repository navigation
Commit dd0671c
committed
GPU: give Metal an IEEE-754 binary64 in software
Metal Shading Language has no double, and the tracking needs one: the track
parametrisation, the propagator and the material budget all do double
arithmetic. The Metal entry point in dev already includes
GPUCommonDoubleBinary64.h; this adds it.
The class implements binary64 over a 64-bit integer. Round to nearest even,
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. The entry
point aliases the double keyword to the class, so the shared headers go on
saying double, and the header refuses to build where a real double exists.
Abs<double> needs a Metal specialisation of its own, since fabs would
otherwise resolve to metal::fabs(float) through the implicit conversion and
round the mantissa away at 17 call sites, with no error and no warning, among
them the SMatrixGPU pivot selection. A static_assert keeps it that way, since
metal::fabs is not constant-evaluable. SinCosd goes the other way: nothing on
the device path needs it, so math_utils::sincosd is excluded for Metal as it
already is for OpenCL, and the stale GPUCommonDouble.h include goes with it.
The one remaining line is a ternary that needs an explicit value_t to stay
unambiguous once value_t is a class.
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.1 parent f16249a commit dd0671c
5 files changed
Lines changed: 608 additions & 3 deletions
File tree
- Common/MathUtils/include/MathUtils
- DataFormats/Reconstruction/src
- GPU
- Common
- GPUTracking/Base/metal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
Lines changed: 1 addition & 1 deletion
| 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