[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2019-02-22 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

--- Comment #7 from Dominique d'Humieres  ---
> I think the current implementation has a decent protection against bad seeds,
> so lets close this as fixed.

The least I can say is that I am not convinced about the "decent protection".

[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2019-02-22 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

Janne Blomqvist  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Janne Blomqvist  ---
I think the current implementation has a decent protection against bad seeds,
so lets close this as fixed.

[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2016-08-22 Thread jb at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

--- Comment #5 from Janne Blomqvist  ---
To be honest, I'm not sure that this test program really tests anything
sensible. There is no rule in the secret black book of PRNG algorithm design,
nor in the Fortran standard, that generating a single value must touch all the
seed variables. That is, you cannot change one element of the seed array,
generate ONE random number, see that the generated number doesn't change, and
conclude that the PRNG is in some kind of pathological state.

One way to test whether the seed is pathological would be to follow section 9.2
in http://vigna.di.unimi.it/ftp/papers/xorshift.pdf . That is, generate a
stream of random numbers, doing a rolling average, and see how quickly the
average converges towards 0.5. If the seed isn't pathological, you should hover
around 0.5 from the start, if it's poor xorshift1024* should converge within a
few hundred iterations.

Now, since https://gcc.gnu.org/viewcvs/gcc?view=revision=239613 the
PRNG should be a little more resistant poor seeds due to laziness or accident,
but there are of course still ways to generate poor seeds for someone
determined to shoot themselves in the foot (left as an exercise for the
reader).

[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2016-08-21 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #4 from Dominique d'Humieres  ---
> Isn't this PR fixed by revision r239356?

Apparently it is not:

program foo

   implicit none

   character(len=40), parameter :: fmt = '(A,33(I0,1X),A,F10.8)'
   integer i, seed_size, date(8)
   integer, allocatable :: new_seed(:), old_seed(:)
   real x

   call random_seed(size=seed_size)
   print *, seed_size

   allocate(new_seed(1:seed_size), old_seed(1:seed_size))
   call random_seed(get=old_seed)
   print *, old_seed

   do i = 1, seed_size
  new_seed = 1
  new_seed(i) = old_seed(i)
  call random_seed(put=new_seed)
  call random_number(x)
  write(*,fmt) 'seeds = [', new_seed, '], x = ', x
   end do

   deallocate(old_seed, new_seed)

end program foo

gives at runtime

  33
  -898577448 -1504036500   921915814  -557971666 -1458124821  1089340892 
-405009840 -1532177545  1874249343 -1565011252   722389807  1033881693  
-61011972  2103950240   262611246 -1017126965  1653648275  1231374486  
500769179   994525438  1527804518   67320104534392906  1157024348
-1609687550  -251439173   9402243666346801834920908   436668423 
-808487283 -1219115328   0
seeds = [-898577448 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 -1504036500 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 ], x = 0.02421916
seeds = [1 1 921915814 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 -557971666 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 -1458124821 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1089340892 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 -405009840 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 -1532177545 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1874249343 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 -1565011252 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 722389807 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1033881693 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 -61011972 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 2103950240 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 262611246 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1017126965 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1653648275 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1231374486 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 500769179 1 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 994525438 1 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1527804518 1 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 673201045 1 1 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 34392906 1 1 1 1 1 1 1 1 1
1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1157024348 1 1 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1609687550 1 1 1 1 1
1 1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -251439173 1 1 1 1 1
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 940224366 1 1 1 1
1 1 ], x = 0.76351053
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 63468018 1 1 1 1
1 ], x = 0.20794845
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 34920908 1 1 1
1 ], x = 0.33147699
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 436668423 1
1 1 ], x = 0.31606442
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -808487283
1 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-1219115328 1 ], x = 0.02421916
seeds = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 ], x
= 0.94173169

i.e., most "random" values are 0.02421916, except when the seed is not 1 in the
elements between 27 and 30, or 33.

[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2016-08-21 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|NEW |WAITING
 CC||jb at gcc dot gnu.org

--- Comment #3 from Dominique d'Humieres  ---
Isn't this PR fixed by revision r239356?

[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2014-02-08 Thread kargl at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

--- Comment #2 from kargl at gcc dot gnu.org ---
Potential patch 

http://gcc.gnu.org/ml/fortran/2014-02/msg00047.html


[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence

2014-01-07 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

Dominique d'Humieres dominiq at lps dot ens.fr changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-01-07
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres dominiq at lps dot ens.fr ---
Still present at r206385. AFAICT [ x 1 1 1 1 1 1 1 1 1 1 1 ] is next
[ x 1 1 1 0 7864504 0 4587601 2097191 3145761 6029545 13238442 ] and
[ 1 1 1 1 1 1 1 1 1 1 1 x ] [ 1 1 1 1 0 7864504 0 4587601 2097191 3145761
6095041 y ].