public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR libstdc++/80506 fix constant used in condition
@ 2017-04-24 14:59 Jonathan Wakely
  2017-04-26  9:19 ` Paolo Carlini
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-24 14:59 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: Vincent Poinot, Paolo Carlini

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

We use the wrong constant for the Marsaglia Tsang algorithm.

	PR libstdc++/80506
	* include/bits/random.tcc (gamma_distribution::operator()): Fix magic
	number used in loop condition.

Tested powerpc64le-linux, committed to trunk.



[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 873 bytes --]

commit aa4da6523b7bfab7ba92c2e9e505155e1ce432a7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Apr 24 13:10:49 2017 +0100

    PR libstdc++/80506 fix constant used in condition
    
    	PR libstdc++/80506
    	* include/bits/random.tcc (gamma_distribution::operator()): Fix magic
    	number used in loop condition.

diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc
index df05ebe..63d1c02 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -2356,7 +2356,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    __v = __v * __v * __v;
 	    __u = __aurng();
 	  }
-	while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n
+	while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
 	       && (std::log(__u) > (0.5 * __n * __n + __a1
 				    * (1.0 - __v + std::log(__v)))));
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] PR libstdc++/80506 fix constant used in condition
  2017-04-24 14:59 [PATCH] PR libstdc++/80506 fix constant used in condition Jonathan Wakely
@ 2017-04-26  9:19 ` Paolo Carlini
  2017-04-26  9:27   ` Paolo Carlini
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Carlini @ 2017-04-26  9:19 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++, gcc-patches; +Cc: Vincent Poinot

Hi,

On 24/04/2017 15:43, Jonathan Wakely wrote:
> We use the wrong constant for the Marsaglia Tsang algorithm.
>
>     PR libstdc++/80506
>     * include/bits/random.tcc (gamma_distribution::operator()): Fix magic
>     number used in loop condition.
>
> Tested powerpc64le-linux, committed to trunk.

Thanks Jon for handling this. It would still be very nice to have a 
testcase...

Cheers,
Paolo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] PR libstdc++/80506 fix constant used in condition
  2017-04-26  9:19 ` Paolo Carlini
@ 2017-04-26  9:27   ` Paolo Carlini
  2017-04-26  9:33     ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Carlini @ 2017-04-26  9:27 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++, gcc-patches; +Cc: Vincent Poinot

.. or maybe using the wrong constant only impacts the performance?!?

Paolo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] PR libstdc++/80506 fix constant used in condition
  2017-04-26  9:27   ` Paolo Carlini
@ 2017-04-26  9:33     ` Jonathan Wakely
  2018-05-06  1:19       ` Ed Smith-Rowland
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2017-04-26  9:33 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: libstdc++, gcc-patches, Vincent Poinot

On 26/04/17 11:14 +0200, Paolo Carlini wrote:
>.. or maybe using the wrong constant only impacts the performance?!?

Yes, I think so. I did some very simple sanity tests and the numbers
were identical before and after.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] PR libstdc++/80506 fix constant used in condition
  2017-04-26  9:33     ` Jonathan Wakely
@ 2018-05-06  1:19       ` Ed Smith-Rowland
  2018-05-07 12:22         ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Ed Smith-Rowland @ 2018-05-06  1:19 UTC (permalink / raw)
  To: Jonathan Wakely, Paolo Carlini; +Cc: libstdc++, gcc-patches, Vincent Poinot

[-- Attachment #1: Type: text/plain, Size: 408 bytes --]

On 04/26/2017 05:16 AM, Jonathan Wakely wrote:
> On 26/04/17 11:14 +0200, Paolo Carlini wrote:
>> .. or maybe using the wrong constant only impacts the performance?!?
>
> Yes, I think so. I did some very simple sanity tests and the numbers
> were identical before and after.
>
>
>
I was backporting this and saw that __generate_impl does this twice more.

For trunk and branch-8 I have these patches.

OK?



[-- Attachment #2: CL_pr80506 --]
[-- Type: text/plain, Size: 192 bytes --]


2018-05-07  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Moar PR libstdc++/80506
	* include/bits/random.tcc (gamma_distribution::__generate_impl()):
	Fix magic number used in loop condition.

[-- Attachment #3: patch_pr80506 --]
[-- Type: text/plain, Size: 816 bytes --]

Index: include/bits/random.tcc
===================================================================
--- include/bits/random.tcc	(revision 259965)
+++ include/bits/random.tcc	(working copy)
@@ -2408,7 +2408,7 @@
 		  __v = __v * __v * __v;
 		  __u = __aurng();
 		}
-	      while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n
+	      while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
 		     && (std::log(__u) > (0.5 * __n * __n + __a1
 					  * (1.0 - __v + std::log(__v)))));
 
@@ -2429,7 +2429,7 @@
 		  __v = __v * __v * __v;
 		  __u = __aurng();
 		}
-	      while (__u > result_type(1.0) - 0.331 * __n * __n * __n * __n
+	      while (__u > result_type(1.0) - 0.0331 * __n * __n * __n * __n
 		     && (std::log(__u) > (0.5 * __n * __n + __a1
 					  * (1.0 - __v + std::log(__v)))));
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] PR libstdc++/80506 fix constant used in condition
  2018-05-06  1:19       ` Ed Smith-Rowland
@ 2018-05-07 12:22         ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2018-05-07 12:22 UTC (permalink / raw)
  To: Ed Smith-Rowland; +Cc: Paolo Carlini, libstdc++, gcc-patches, Vincent Poinot

On 05/05/18 21:19 -0400, Ed Smith-Rowland wrote:
>On 04/26/2017 05:16 AM, Jonathan Wakely wrote:
>>On 26/04/17 11:14 +0200, Paolo Carlini wrote:
>>>.. or maybe using the wrong constant only impacts the performance?!?
>>
>>Yes, I think so. I did some very simple sanity tests and the numbers
>>were identical before and after.
>>
>>
>>
>I was backporting this and saw that __generate_impl does this twice more.
>
>For trunk and branch-8 I have these patches.
>
>OK?

OK, thanks for noticing the additional cases.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-07 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 14:59 [PATCH] PR libstdc++/80506 fix constant used in condition Jonathan Wakely
2017-04-26  9:19 ` Paolo Carlini
2017-04-26  9:27   ` Paolo Carlini
2017-04-26  9:33     ` Jonathan Wakely
2018-05-06  1:19       ` Ed Smith-Rowland
2018-05-07 12:22         ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).