Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-10-14 Thread Jonathan Wakely
On 02/09/16 20:53 +0200, Eelis wrote: On 2016-09-02 20:20, Eelis van der Weegen wrote: On 2016-08-31 14:45, Jonathan Wakely wrote: Is this significantly faster than just using uniform_int_distribution<_IntType>{0, __bound - 1}(__g) so we don't need to duplicate the logic? (And people maintainin

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-02 Thread Eelis
On 2016-09-02 20:20, Eelis van der Weegen wrote: On 2016-08-31 14:45, Jonathan Wakely wrote: Is this significantly faster than just using uniform_int_distribution<_IntType>{0, __bound - 1}(__g) so we don't need to duplicate the logic? (And people maintaining the code won't reconvince themselves

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-02 Thread Eelis van der Weegen
On 2016-08-31 14:45, Jonathan Wakely wrote: Is this significantly faster than just using uniform_int_distribution<_IntType>{0, __bound - 1}(__g) so we don't need to duplicate the logic? (And people maintaining the code won't reconvince themselves it's correct every time they look at it :-) [..]

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-01 Thread Jonathan Wakely
On 01/09/16 17:31 +0200, Eelis van der Weegen wrote: On 2016-09-01 17:14, Jonathan Wakely wrote: On 31/08/16 13:45 +0100, Jonathan Wakely wrote: On 03/05/16 16:42 +0200, Eelis van der Weegen wrote: Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:3

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-01 Thread Jonathan Wakely
On 01/09/16 17:27 +0200, Marc Glisse wrote: On Thu, 1 Sep 2016, Jonathan Wakely wrote: + const __uc_type __comp_range = __swap_range * (__swap_range + 1); If __swap_range is 3, then __comp_range is 10 and ??? Bah :-) Thanks. I guess I read the code correctly the other day at leas

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-01 Thread Eelis van der Weegen
On 2016-09-01 17:14, Jonathan Wakely wrote: On 31/08/16 13:45 +0100, Jonathan Wakely wrote: On 03/05/16 16:42 +0200, Eelis van der Weegen wrote: Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:38, Jonathan Wakely wrote: ENOPATCH On 1 May 2016 at

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-01 Thread Marc Glisse
On Thu, 1 Sep 2016, Jonathan Wakely wrote: + const __uc_type __comp_range = __swap_range * (__swap_range + 1); If __swap_range is 3, then __comp_range is 10 and ??? -- Marc Glisse

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-09-01 Thread Jonathan Wakely
On 31/08/16 13:45 +0100, Jonathan Wakely wrote: On 03/05/16 16:42 +0200, Eelis van der Weegen wrote: Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:38, Jonathan Wakely wrote: ENOPATCH On 1 May 2016 at 15:21, Eelis wrote: Sorry, forgot to includ

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-08-31 Thread Jonathan Wakely
On 03/05/16 16:42 +0200, Eelis van der Weegen wrote: Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:38, Jonathan Wakely wrote: ENOPATCH On 1 May 2016 at 15:21, Eelis wrote: Sorry, forgot to include the libstdc++ list. On 2016-05-01 16:18, Eelis

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-05-25 Thread Eelis
On 2016-05-01 16:18, Eelis wrote: The attached patch optimizes std::shuffle for the very common case where the generator range is large enough that a single invocation can produce two swap positions. This reduces the runtime of the following testcase by 37% on my machine: Gentle ping. :) Did

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-05-03 Thread Eelis van der Weegen
Ah, thanks, I forgot to re-attach when I sent to include the libstdc++ list. On 2016-05-03 14:38, Jonathan Wakely wrote: ENOPATCH On 1 May 2016 at 15:21, Eelis wrote: Sorry, forgot to include the libstdc++ list. On 2016-05-01 16:18, Eelis wrote: Hi, The attached patch optimizes std::shuff

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-05-03 Thread Jonathan Wakely
ENOPATCH On 1 May 2016 at 15:21, Eelis wrote: > Sorry, forgot to include the libstdc++ list. > > On 2016-05-01 16:18, Eelis wrote: >> >> Hi, >> >> The attached patch optimizes std::shuffle for the very common case >> where the generator range is large enough that a single invocation >> can produc

Re: [patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-05-01 Thread Eelis
Sorry, forgot to include the libstdc++ list. On 2016-05-01 16:18, Eelis wrote: Hi, The attached patch optimizes std::shuffle for the very common case where the generator range is large enough that a single invocation can produce two swap positions. This reduces the runtime of the following tes

[patch, libstdc++] std::shuffle: Generate two swap positions at a time if possible

2016-05-01 Thread Eelis
Hi, The attached patch optimizes std::shuffle for the very common case where the generator range is large enough that a single invocation can produce two swap positions. This reduces the runtime of the following testcase by 37% on my machine: int main() { std::mt