jsoftware / jsource

J engine source mirror
Other
645 stars 91 forks source link

vectorised rng, if it can be done fast #165

Open moon-chilled opened 1 year ago

moon-chilled commented 1 year ago

(Generating random numbers has been a bottleneck in a couple of test setups.)

Managing k parallel random states is no big deal, but doing the range reduction is annoying, as vector multiplication support is ehhhh. It occurs to me that, pre-avx512, you can get a 52-bit high multiply out of a float multiply if you direct the rounding mode towards 0 or -inf (and deal with the artifacts of the virtual bit). Probably the interval from 2^53 to 2^63 is not so important.