Skip to content

Update RandomGenerator to not use uniform_real_dist

Ivan Zhechev requested to merge ijan1/PSRayTracing:clang_fix into master

Fix for issue #85

Clang's codegen leaves uninlined calls to logl when using uniform_real_distribution, which leads to worse performance, sometimes up to 2x.

Hence, I have changed _GeneralizedRandomGenerator to generate its own floating-point numbers from a PRNG which can provide 64-bit integers.

The default PRNGs were changed to mt19937_64 and pcg64, it's possible to use a 32-bit version and use bitmasks to create a 64-bit number yourself, which is probably a bit faster, but I haven't benchmarked it.

Clang 17.0.6 unpatched Clang 17.0.6 patched Performance improvement
11.776 5.209 2.26
11.725 5.211 2.25
11.721 5.216 2.24
11.775 5.212 2.25
11.773 5.214 2.25
11.872 5.211 2.27
11.723 5.258 2.22
11.771 5.216 2.25
11.767 5.212 2.25
11.72 5.211 2.24

Merge request reports