re https://gmplib.org/pi-with-gmp

Dennis Clarke dclarke at blastwave.org
Wed Nov 18 02:32:30 UTC 2020


see https://gmplib.org/pi-with-gmp

This looks like fun but I don't see where you are getting those numbers
from.  On a not_at_all_impressive ppc64 boxen I see :

enceladus$ uname -a
Linux enceladus 5.10.0-rc1-genunix #1 SMP Wed Oct 28 07:14:15 GMT 2020
ppc64 GNU/Linux
enceladus$
enceladus$
enceladus$ CC=/usr/bin/gcc
export CC
enceladus$ CFLAGS='-std=iso9899:1999 -pedantic -pedantic-errors
-fno-builtin -g -m64 -mcpu=970 -mno-altivec -mno-isel -mno-vsx
-mno-crypto -mno-htm -mno-quad-memory-atomic -mfull-toc -mno-multiple
-mupdate -mno-avoid-indexed-addresses -ffp-contract=off -mno-mulhw
-mno-dlmzb -mno-bit-align -mno-strict-align -mbig -mregnames -mno-recip
-fno-unsafe-math-optimizations -Wl,-rpath=/opt/bw/lib,--enable-new-dtags'
enceladus$ export CFLAGS
enceladus$
enceladus$ CPPFLAGS='-D_TS_ERRNO -D_POSIX_PTHREAD_SEMANTICS
-D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=600'
enceladus$ export CPPFLAGS
enceladus$
enceladus$ $CC $CFLAGS $CPPFLAGS -I/opt/bw/include -c -o
gmp-chudnovsky.o gmp-chudnovsky.c
enceladus$ $CC $CFLAGS $CPPFLAGS -L/opt/bw/lib -o gmp-chudnovsky
gmp-chudnovsky.o -lgmp -lm
enceladus$
enceladus$ ldd gmp-chudnovsky
        linux-vdso64.so.1 (0x00007fff7e810000)
        libgmp.so.10 => /opt/bw/lib/libgmp.so.10 (0x00007fff7e6e0000)
        libm.so.6 => /lib/powerpc64-linux-gnu/libm.so.6 (0x00007fff7e5e0000)
        libc.so.6 => /lib/powerpc64-linux-gnu/libc.so.6 (0x00007fff7e3b0000)
        /lib64/ld64.so.1 (0x00007fff7e830000)
enceladus$
enceladus$ /usr/bin/time -p ./gmp-chudnovsky
#terms=7, depth=4
sieve   time =  0.000
.......

bs      time =  0.000
   gcd  time =  0.000
div     time =  0.000
sqrt    time =  0.000
mul     time =  0.000
total   time =  0.000
   P size=124 digits (1.240000)
   Q size=117 digits (1.170000)
real 0.00
user 0.00
sys 0.00
enceladus$
enceladus$
enceladus$ /usr/bin/time -p ./gmp-chudnovsky 10000
#terms=705, depth=11
sieve   time =  0.000
..................................................

bs      time =  0.030
   gcd  time =  0.000
div     time =  0.012
sqrt    time =  0.004
mul     time =  0.008
total   time =  0.054
   P size=14315 digits (1.431500)
   Q size=14308 digits (1.430800)
real 0.05
user 0.05
sys 0.00
enceladus$
enceladus$ /usr/bin/time -p ./gmp-chudnovsky 100000
#terms=7051, depth=14
sieve   time =  0.000
..................................................

bs      time =  0.887
   gcd  time =  0.000
div     time =  0.264
sqrt    time =  0.140
mul     time =  0.103
total   time =  1.398
   P size=145244 digits (1.452440)
   Q size=145237 digits (1.452370)
real 1.41
user 1.40
sys 0.00
enceladus$
enceladus$ /usr/bin/time -p ./gmp-chudnovsky 1000000
#terms=70513, depth=18
sieve   time =  0.025
..................................................

bs      time = 20.498
   gcd  time =  0.000
div     time =  3.902
sqrt    time =  2.112
mul     time =  1.530
total   time = 28.082
   P size=1455608 digits (1.455608)
   Q size=1455601 digits (1.455601)
real 28.15
user 28.08
sys 0.06
enceladus$
enceladus$ /usr/bin/time -p ./gmp-chudnovsky 10000000
#terms=705136, depth=21
sieve   time =  0.433
...................................................

bs      time = 412.109
   gcd  time =  0.000
div     time = 62.066
sqrt    time = 33.747
mul     time = 20.973
total   time = 529.489
   P size=14561191 digits (1.456119)
   Q size=14561184 digits (1.456118)
real 530.42
user 529.49
sys 0.96
enceladus$

No idea what all those numbers mean. Personally I think I can get pi to
as many lovely digits as I want with a call to mpfr_const_pi() and we
are done. Sorry, that is mpfr but at least I skip over chudnovsky. So is
there a way to run this test code gmp-chudnovsky.c on the oldest and the
most slow machines you can not imagine and report stats?

-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional


More information about the gmp-discuss mailing list