[PATCH, libstdc++] Improve the performance of std::uniform_int_distribution (fewer divisions)

Jonathan Wakely jwakely@redhat.com
Fri Oct 9 13:17:56 GMT 2020


On 06/10/20 15:55 -0400, Daniel Lemire via Libstdc++ wrote:
>The updated patch looks good to me. It is indeed cleaner to have a separate
>(static) function.
>
>It might be nice to add a comment to explain the _S_nd function maybe with
>a comment like "returns a random value in [0,__range)
>without any bias" (or something to that effect).
>
>Otherwise, it is algorithmically correct.

Here's what I've just committed and pushed to the master branch.

As expected, this shows significant improvements for some (but not
all) of the cases in the new test I added earlier today,
testsuite/performance/26_numerics/random_dist.cc

Thanks again for the patch.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 3280 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201009/43b00e5b/attachment.bin>


More information about the Libstdc++ mailing list