Oliver Bandel on Sat, 13 Jan 2024 02:25:57 +0100


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

Re: Big GOTCHAs WITH forprime()


Hi Ilya,

Quoting  Ilya Zakharevich <nospam-abuse@ilyaz.org> (snt: 2024-01-12 23:27 +0100 CET) (rcv: 2024-01-12 23:28 +0100 CET):
[...]
>   (Moreover, it segfaults… — reported, see
>       https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2520
>    .)

How do you meaure the time in your two short examples at the top?
A complete code, that shows it, would be nice.

Regarding your crash: I could not confirm it on my (quite old) laptop.

Here is what I got, after I ran your code example for a while (which I
then terminated):

================================================================================
  GP/PARI Version 2.15.4,
  amd64 linux,  64-bit version
  threading engine: pthread
--------------------------------------------------------------------------------
parisizemax = 80003072, primelimit = 500000, nbthreads = 8
? 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, 14699, 97]
[190333000000000000.00000000000000000000, 190334125000000000.00000000000000000000, 14667, 96]
[190333000000000000.00000000000000000000, 190333843750000000.00000000000000000000, 15026, 95]
[190333000000000000.00000000000000000000, 190333632812500000.00000000000000000000, 14670, 94]
[190333000000000000.00000000000000000000, 190333474609375000.00000000000000000000, 14567, 93]
[190333000000000000.00000000000000000000, 190333355957031250.00000000000000000000, 14769, 92]
[190333000000000000.00000000000000000000, 190333266967773437.50000000000000000000, 14781, 91]
[190333000000000000.00000000000000000000, 190333200225830078.12500000000000000000, 14654, 90]
[190333000000000000.00000000000000000000, 190333150169372558.59375000000000000000, 14998, 89]
[190333000000000000.00000000000000000000, 190333112627029418.94531250000000000000, 14691, 88]
[190333000000000000.00000000000000000000, 190333084470272064.20898437500000000000, 14629, 87]
[190333000000000000.00000000000000000000, 190333063352704048.15673828125000000000, 14948, 86]
[190333000000000000.00000000000000000000, 190333047514528036.11755371093750000000, 14831, 85]
[190333000000000000.00000000000000000000, 190333035635896027.08816528320312500000, 14967, 84]
[190333000000000000.00000000000000000000, 190333026726922020.31612396240234375000, 14581, 83]
[190333000000000000.00000000000000000000, 190333020045191515.23709297180175781250, 15460, 82]
[190333000000000000.00000000000000000000, 190333015033893636.42781972885131835938, 16344, 81]
[190333000000000000.00000000000000000000, 190333011275420227.32086479663848876953, 16563, 80]
[190333000000000000.00000000000000000000, 190333008456565170.49064859747886657715, 16830, 79]
[190333000000000000.00000000000000000000, 190333006342423877.86798644810914993286, 16383, 78]
[190333000000000000.00000000000000000000, 190333004756817908.40098983608186244965, 16481, 77]
[190333000000000000.00000000000000000000, 190333003567613431.30074237706139683723, 17195, 76]
[190333000000000000.00000000000000000000, 190333002675710073.47555678279604762793, 16936, 75]
[190333000000000000.00000000000000000000, 190333002006782555.10666758709703572094, 16802, 74]
[190333000000000000.00000000000000000000, 190333001505086916.33000069032277679071, 16883, 73]
[190333000000000000.00000000000000000000, 190333001128815187.24750051774208259303, 17013, 72]
[190333000000000000.00000000000000000000, 190333000846611390.43562538830656194477, 17317, 71]
[190333000000000000.00000000000000000000, 190333000634958542.82671904122992145858, 16994, 70]
[190333000000000000.00000000000000000000, 190333000476218907.12003928092244109394, 17014, 69]
[190333000000000000.00000000000000000000, 190333000357164180.34002946069183082045, 17395, 68]
[190333000000000000.00000000000000000000, 190333000267873135.25502209551887311534, 17394, 67]
[190333000000000000.00000000000000000000, 190333000200904851.44126657163915483650, 17605, 66]
[190333000000000000.00000000000000000000, 190333000150678638.58094992872936612738, 17705, 65]
[190333000000000000.00000000000000000000, 190333000113008978.93571244654702459553, 18433, 64]
[190333000000000000.00000000000000000000, 190333000084756734.20178433491026844665, 18821, 63]
[190333000000000000.00000000000000000000, 190333000063567550.65133825118270133499, 18649, 62]
[190333000000000000.00000000000000000000, 190333000047675662.98850368838702600124, 18356, 61]
[190333000000000000.00000000000000000000, 190333000035756747.24137776629026950093, 18365, 60]
[190333000000000000.00000000000000000000, 190333000026817560.43103332471770212570, 18054, 59]
[190333000000000000.00000000000000000000, 190333000020113170.32327499353827659427, 18493, 58]
[190333000000000000.00000000000000000000, 190333000015084877.74245624515370744571, 18236, 57]
[190333000000000000.00000000000000000000, 190333000011313658.30684218386528058428, 18054, 56]
[190333000000000000.00000000000000000000, 190333000008485243.73013163789896043821, 19491, 55]
[190333000006363932.79759872842422032866, 190333000008485243.73013163789896043821, 22019, 50]
[190333000006363932.79759872842422032866, 190333000007954915.99699841053027541082, 19633, 49]
[190333000006363932.79759872842422032866, 190333000007557170.19714849000376164028, 19783, 48]
[190333000007258860.84726104960887631237, 190333000007557170.19714849000376164028, 20094, 43]
[190333000007258860.84726104960887631237, 190333000007482592.85967662990504030830, 19683, 42]
[190333000007258860.84726104960887631237, 190333000007426659.85657273483099930932, 19150, 41]
^C  ***   at top-level: ...twalltime();n-=1+if(if(1,f(z=(x+3*y)/4);20000<
  ***                                             ^---------------------
  ***   in function f: forprime(p=s,s+10^8,)
  ***                  ^---------------------
  ***   user interrupt after 14min, 211 ms cpu time, 14min, 1,915 ms real time
  ***   Break loop: <Return> to continue; 'break' to go back to GP prompt
break>
================================================================================

Maybe that helps somehow.


Ciao,
  Oliver