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

2020-10-06 Thread Daniel Lemire via Gcc-patches
ise, it is algorithmically correct. On Mon, Oct 5, 2020 at 7:40 PM Jonathan Wakely wrote: > On 06/10/20 00:25 +0100, Jonathan Wakely wrote: > >I'm sorry it's taken a year to review this properly. Comments below ... > > > >On 27/09/19 14:18 -0400, Daniel Lemire wrote: &g

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

2020-10-06 Thread Daniel Lemire via Gcc-patches
> > >The condition above checks that __urngrange == 2**64-1 which means > >that U::max() - U::min() is the maximum 64-bit value, which means > >means U::max()==2**64-1 and U::min()==0. So if U::min() is 0 we don't > >need to subtract it. > That sounds correct.

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

2019-09-27 Thread Daniel Lemire
(This is a revised patch proposal. I am revising both the description and the code itself.) Even on recent processors, integer division is relatively expensive. The current implementation of std::uniform_int_distribution typically requires two divisions by invocation: // downscaling

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

2019-09-08 Thread Daniel Lemire
Even on recent processors, integer division is relatively expensive. The current implementation of std::uniform_int_distribution typically requires two divisions by invocation: // downscaling const __uctype __uerange = __urange + 1; // __urange can be zero const __uctype _