From: Thomas Koenig <tkoenig@netcologne.de>
To: Paul Richard Thomas <paul.richard.thomas@gmail.com>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, fortran, doc] Explicitly mention undefined overflow
Date: Mon, 20 Mar 2023 08:14:48 +0100 [thread overview]
Message-ID: <83ed6780-22ac-bb57-d80c-c4d3a2c6b773@netcologne.de> (raw)
In-Reply-To: <80e8f406-3e2c-3871-d225-0a74a620c6f6@netcologne.de>
I wrote:
>
>> Yes, that's fine for trunk. I wonder if it is worth being explicit that
>> linear congruential pseudo-random number generators can and do fail at
>> -O3?
>
> I don't think we should put this into the docs, because that can change
> at any time. Maybe into porting_to.html, though (where I have only
> mentioned this as a general issue with linear congruential generators,
> without mentioning specific options. Current text can be seen at
> https://gcc.gnu.org/gcc-13/porting_to.html ).
>
> Hm....
Breaking things actually goes back further than I thought.
Taking the random number generator from rnseed and running
it 10 times with my system gfortran 9.4.0 gets me, at
different levels of optimization:
$ for a in -O0 -O1 -O2; do echo $a; gfortran $a genuni.f90 && ./a.out; done
-O0
0.269411892
0.891386986
0.444042951
0.779210865
0.500058949
0.666437685
0.666963458
0.462416053
0.376364112
2.90278494E-02
-O1
0.269411892
0.891386986
0.444042951
0.779210865
0.500058949
0.666437685
0.666963458
0.462416053
0.376364112
2.90278494E-02
-O2
-0.730588138
0.891386986
-0.555957019
-0.220789105
-0.499941051
0.666437685
-0.333036542
0.462416053
0.376364112
2.90278494E-02
and for current trunk it is
$ for a in -O0 -O1 -O2; do echo $a; gfortran $a genuni.f90 && ./a.out; done
-O0
0.269411892
0.891386986
0.444042951
0.779210865
0.500058949
0.666437685
0.666963458
0.462416053
0.376364112
2.90278494E-02
-O1
0.269411892
0.891386986
0.444042951
0.779210865
0.500058949
0.666437685
0.666963458
0.462416053
0.376364112
2.90278494E-02
-O2
0.211324871
0.211324871
0.211324871
0.211324871
0.211324871
0.211324871
0.211324871
0.211324871
0.211324871
0.211324871
so it the general problem is not restricted to -O3 and not
to current trunk, it depends on the details.
I doubt that the result from 9.4.0 was expected, but rather
nobody noticed. Or, bringing out the pseudo-RNG into a
different setting changed things.
So... any suggestions on how to improve the current wording?
Best regards
Thomas
next prev parent reply other threads:[~2023-03-20 7:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-19 8:32 Thomas Koenig
2023-03-19 13:12 ` Paul Richard Thomas
2023-03-19 17:40 ` Thomas Koenig
2023-03-20 7:14 ` Thomas Koenig [this message]
2023-03-20 21:32 ` Harald Anlauf
2023-03-19 13:15 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83ed6780-22ac-bb57-d80c-c4d3a2c6b773@netcologne.de \
--to=tkoenig@netcologne.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=paul.richard.thomas@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).