public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, fortran] PR 77261 gfortran.dg/random_3.f90 failure
@ 2016-08-23 13:41 Janne Blomqvist
  2016-08-29  7:05 ` Janne Blomqvist
  0 siblings, 1 reply; 3+ messages in thread
From: Janne Blomqvist @ 2016-08-23 13:41 UTC (permalink / raw)
  To: Fortran List, GCC Patches

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

Hi,

the attached patch fixes PR 77261. The problem is that with the new
PRNG, the random sequence for real(16) and lesser kinds is not the
same. And then on targets that have real(16) but not real(10) the
testcase fails. Fixed by essentially running the tests only when
real(10) is available.

Regtested on x86_64-pc-linux-gnu, Ok for trunk?

2016-08-23  Janne Blomqvist  <jb@gcc.gnu.org>

    PR fortran/77261
    * gfortran.dg/random_3.f90: Run testcase only when real(10) is
    available.


-- 
Janne Blomqvist

[-- Attachment #2: pr77261-random-3.diff --]
[-- Type: text/plain, Size: 1966 bytes --]

diff --git a/gcc/testsuite/gfortran.dg/random_3.f90 b/gcc/testsuite/gfortran.dg/random_3.f90
index 8e087c4..0491000 100644
--- a/gcc/testsuite/gfortran.dg/random_3.f90
+++ b/gcc/testsuite/gfortran.dg/random_3.f90
@@ -1,10 +1,10 @@
 ! { dg-do run }
 ! { dg-require-effective-target fortran_large_real }
-! Check that the random_seed for real(10) or real(16) exists and that
-! real(8) and real(10) or real(16) random number generators
+! Check that the random_seed for real(10) exists and that
+! real(8) and real(10) random number generators
 ! return the same sequence of values.
 ! Mostly copied from random_2.f90
-program random_4
+program random_3
   integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
 
   integer, dimension(:), allocatable :: seed
@@ -13,17 +13,23 @@ program random_4
   real, parameter :: delta = 1.d-10
   integer n
 
-  call random_seed (size=n)
-  allocate (seed(n))
-  call random_seed (get=seed)
-  ! Test both array valued and scalar routines.
-  call random_number(r8)
-  call random_number (r8(10))
+  ! Run the test only if real(10) is available. With the current
+  ! xorshift1024* PRNG the real(16) generator uses two uint64_t values
+  ! for every real(16) value generated, and hence the sequences won't
+  ! be the same as with real(4,8,10).
+  if (k == 10) then
+     call random_seed (size=n)
+     allocate (seed(n))
+     call random_seed (get=seed)
+     ! Test both array valued and scalar routines.
+     call random_number(r8)
+     call random_number (r8(10))
 
-  ! Reset the seed and get the real(8) values.
-  call random_seed (put=seed)
-  call random_number(r10)
-  call random_number (r10(10))
+     ! Reset the seed and get the real(8) values.
+     call random_seed (put=seed)
+     call random_number(r10)
+     call random_number (r10(10))
 
-  if (any ((r8 - r10) .gt. delta)) call abort
-end program random_4
+     if (any ((r8 - r10) .gt. delta)) call abort
+  end if
+end program random_3

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

* Re: [PATCH, fortran] PR 77261 gfortran.dg/random_3.f90 failure
  2016-08-23 13:41 [PATCH, fortran] PR 77261 gfortran.dg/random_3.f90 failure Janne Blomqvist
@ 2016-08-29  7:05 ` Janne Blomqvist
  2016-08-29  7:59   ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Janne Blomqvist @ 2016-08-29  7:05 UTC (permalink / raw)
  To: Fortran List, GCC Patches

PING?

FWIW, Rainer Orth confirmed that the fixed testcase now passes on Solaris/SPARC.

On Tue, Aug 23, 2016 at 4:40 PM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> Hi,
>
> the attached patch fixes PR 77261. The problem is that with the new
> PRNG, the random sequence for real(16) and lesser kinds is not the
> same. And then on targets that have real(16) but not real(10) the
> testcase fails. Fixed by essentially running the tests only when
> real(10) is available.
>
> Regtested on x86_64-pc-linux-gnu, Ok for trunk?
>
> 2016-08-23  Janne Blomqvist  <jb@gcc.gnu.org>
>
>     PR fortran/77261
>     * gfortran.dg/random_3.f90: Run testcase only when real(10) is
>     available.
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist

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

* Re: [PATCH, fortran] PR 77261 gfortran.dg/random_3.f90 failure
  2016-08-29  7:05 ` Janne Blomqvist
@ 2016-08-29  7:59   ` Paul Richard Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Richard Thomas @ 2016-08-29  7:59 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: Fortran List, GCC Patches

Dear Janne,

That's fine for trunk.

Thanks for the patch.

Paul

On 29 August 2016 at 09:05, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
> PING?
>
> FWIW, Rainer Orth confirmed that the fixed testcase now passes on Solaris/SPARC.
>
> On Tue, Aug 23, 2016 at 4:40 PM, Janne Blomqvist
> <blomqvist.janne@gmail.com> wrote:
>> Hi,
>>
>> the attached patch fixes PR 77261. The problem is that with the new
>> PRNG, the random sequence for real(16) and lesser kinds is not the
>> same. And then on targets that have real(16) but not real(10) the
>> testcase fails. Fixed by essentially running the tests only when
>> real(10) is available.
>>
>> Regtested on x86_64-pc-linux-gnu, Ok for trunk?
>>
>> 2016-08-23  Janne Blomqvist  <jb@gcc.gnu.org>
>>
>>     PR fortran/77261
>>     * gfortran.dg/random_3.f90: Run testcase only when real(10) is
>>     available.
>>
>>
>> --
>> Janne Blomqvist
>
>
>
> --
> Janne Blomqvist



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein

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

end of thread, other threads:[~2016-08-29  7:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-23 13:41 [PATCH, fortran] PR 77261 gfortran.dg/random_3.f90 failure Janne Blomqvist
2016-08-29  7:05 ` Janne Blomqvist
2016-08-29  7:59   ` Paul Richard Thomas

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).