Bill Allombert on Thu, 25 Jan 2024 10:39:42 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Big GOTCHAs WITH forprime()


On Wed, Jan 24, 2024 at 03:32:23PM -0800, Ilya Zakharevich wrote:
> On Wed, Jan 24, 2024 at 12:07:12PM +0100, Bill Allombert wrote:
> > On Wed, Jan 24, 2024 at 01:08:38AM -0800, Ilya Zakharevich wrote:
> > > Anyway — unless you want (the dubious fun of) running the binary
> > > search yourself — you missed the second part of the bug report
> > >    https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2520#10
> > > which lists the command which fails immediately on my system.
> > 
> > Indeed, but so far nobody else has been able to reproduce this.
> > 
> > On linux:
> > 
> > [190333000000000000.00000000000000000000,190334500000000000.00000000000000000000,10354,97]
> 
> I REALLY wonder what is so wrong with my prose that “nobody else” can
> read it…  Just in case, I repeat the reference for the third time:
> 
>   https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2520#10

Yes, I was running the immediate running version but without
primelimit=400000000000

Now on linux, with GP 2.15.4:

% gp -qf --default primelimit=400000000000
? my((f(s)=forprime(p=s,s+10^8,)),n=98,x=190333*10^12,y=x+2*10^12,t,z,t0);while(n>0,t=getwalltime();n-=1+if(if(1,f(z=(x+3*y)/4);20000<(t0=-(t-(t=getwalltime())))),x=z;4,y=z;0);print([1.*x,1.*y,t0,n]))

[190333000000000000.00000000000000000000, 190334500000000000.00000000000000000000, 10650, 97]
[190334125000000000.00000000000000000000, 190334500000000000.00000000000000000000, 32178, 92]
[190334125000000000.00000000000000000000, 190334406250000000.00000000000000000000, 10259, 91]
[190334125000000000.00000000000000000000, 190334335937500000.00000000000000000000, 10436, 90]
[190334125000000000.00000000000000000000, 190334283203125000.00000000000000000000, 10284, 89]
[190334125000000000.00000000000000000000, 190334243652343750.00000000000000000000, 10629, 88]
[190334125000000000.00000000000000000000, 190334213989257812.50000000000000000000, 10562, 87]

% valgrind gp -qf --default primelimit=400000000000
==135725== Memcheck, a memory error detector
==135725== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==135725== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==135725== Command: gp -qf --default primelimit=400000000000
==135725==
? my((f(s)=forprime(p=s,s+10^8,)),n=98,x=190333*10^12,y=x+2*10^12,t,z,t0);while(n>0,t=getwalltime();n-=1+if(if(1,f(z=(x+3*y)/4);20000<(t0=-(t-(t=getwalltime())))),x=z;4,y=z;0);print([1.*x,1.*y,t0,n]))
[190334500000000000.00000000000000000000, 190335000000000000.00000000000000000000, 93983, 93]
[190334875000000000.00000000000000000000, 190335000000000000.00000000000000000000, 93132, 88]
[190334968750000000.00000000000000000000, 190335000000000000.00000000000000000000, 92726, 83]

Cheers,
Bill.