Skip to content

[surface model] first implementation of mixed precision

Severin Diederichs requested to merge mixed_precision_raytracing into surface_model

This MR proposes a first version of running in mixed precision for the surface model.

This is done in the following way:

The solid conversion is now fully done in the compiled vecgeom::Precision. In the initialization of the surface data and the masks the data is casted to Real_t. Note that in the creation of the surface data there was a storage and an input template parameter but it was not used. Now, the structs have a storage precision Real_t and an input precision Real_i and the data is casted accordingly at initialization. The precision of the surface model for the Raytracer can be chosen in testRaytracing.h. To allow for the comparison with the fully double-precision solid model, another array of points and directions is created in the testRaytracing both for host and device and then used accordingly.

Running in mixed precision currently is 60% slower than in double precision on GPU (RTX 3080), probably due to huge amount of casts when doing transformations as they are fully in the compiled vecgeom::Precision. They will also need to be templated. Currently, for simple geometries, the raytracing works in mixed precision. More complex shapes give traverse errors. Handling of traverse errors needs to be improved, currently the Real_t of the raytracing is used to determine the tolerance. Note that shapes like the torus, Arb4 or even cones might need to be reconsidered if they can be done in single precision (for torus the answer is clearly no). This needs to be improved.

The MR fixes a bunch of errors and warnings when compiling vecgeom fully in single precision, however many warnings still remain and would require further cleaning. Note that running in full single precision is almost 3x faster on the RTX 3080, but gives significant amount of traverse errors.

The tradeoff between doing as many calculations as possible in single precision to improve the speed of GPU, while retaining high accuracy, remains to be investigated.

Merge request reports