GMP «Arithmetic without limitations» Computing billions of π digits using GMP


While GMP is a general-purpose library for arithmetic on large numbers, it also works very well for such special tasks as computing a silly number of digits of π. This program, written by Hanhong Xue, is all that's needed.

How do these numbers compare to other π computing programs out there? Many π programs proclaim themselves as "the fastest", but then they are actually several times slower than gmp-chudnovsky.c with the current GMP release. Compare the numbers!

Using GMP, a fast 64-bit computer, and sufficient memory, it should be possible to compute up to 41 billion digits. Unfortunately, the memory requirements are about 8n bytes for computing n digits, which will make most desktop computers unfit for 41 billion digit computations. Memory locality in GMP's FFT multiply code is not good enough for efficient computation with operands on disk.

Attempting computations of more than 41 billion digits will cause overflow in the mpz type. A planned future version of GMP will allow the patient and wealthy to compute up to at least 1 quadrillion (1015) digits, and unlike current GMP, this future GMP will operate fine with operands on disk. One needs around 1000 high-capacity rust swap disks in order to compute 1 quadrillion digits, but hopefully that will qualify for a discount ("buy 1000, pay for 999").

Timing results are in seconds.



GMP devel

Number of
digits
AMD
K10 Thuban
3.2 GHz
AMD
Piledriver
4 GHz
Intel
Conroe/Penryn
3.0 GHz
Intel
Nehalem
2.93 GHz
Intel
Sandybridge
3.4 GHz
Intel
Haswell
4.0 GHz
Intel
Broadwell
3.4 GHz
Intel
Skylake
3.6 GHz
IBM
POWER7-smt4
3.55 GHz
IBM
POWER8-smt4
3.425 GHz
100,000 0.024 0.024 0.032 0.028 0.016 0.016 0.016 0.016 0.028 0.020
1,000,000 0.46 0.48 0.62 0.64 0.41 0.29 0.304 0.28 0.51 0.53
10,000,000 8.24 8.36 10.9 10.8 6.94 4.94 5.15 4.69 8.96 9.06
100,000,000 135 134 177 171 111 79 81 75 144 143
1,000,000,000 2107 2033   2578 1660 1185 1241 1134 2197 2143

GMP 5.0

Number of
digits
AMD
Athlon (K8)
2.2 GHz
AMD
K10 Thuban
3.2 GHz
Intel
Pentium 4
3.4 GHz
Intel
Conroe
2.13 GHz
Intel
Nehalem
2.67 GHz
Intel
Sandybridge
3.3 GHz
IBM
PowerPC 970
1.8 GHz
Intel
Itanium 2
0.9 GHz
100,000   0.03 0.08 0.04 0.03 0.02 0.13 0.09
1,000,000   0.48 1.49 0.89 0.69 0.49 1.73 1.67
10,000,000   8.2 26.3 16.4 12.0 8.22 30.8 29.3
100,000,000   134 430 269 191 131 497 494
1,000,000,000   2097 6656   2896      



GMP 4.3

Number of
digits
AMD
Athlon (K8)
2.2 GHz
AMD
K10 Thuban
3.2 GHz
Intel
Pentium 4
3.2 GHz
Intel
Conroe
2.13 GHz
Intel
Nehalem
2.67 GHz
IBM
PowerPC 970
1.6 GHz
100,000 0.04 0.03 0.10 0.05 0.04 0.15
1,000,000 0.90 0.56 1.77 1.08 0.81 2.3
10,000,000 16.8 9.7 31.0 19.7 14.5 40.4
100,000,000 291 166 542 349 247 692
1,000,000,000         4069  



GMP 4.2

Number of
digits
AMD
Athlon (K8)
2.2 GHz
AMD
K10 Thuban)
3.2 GHz
Intel
Pentium 4
3.2 GHz
Intel
Conroe
2.13 GHz
Intel
Nehalem
2.67 GHz
IBM
PowerPC 970
1.6 GHz
100,000 0.06   0.15 0.12   0.17
1,000,000 1.48   2.9 2.35   2.92
10,000,000 26.8   52.3 42.6   52.5
100,000,000 467   902 756   902
1,000,000,000            



Please send comments about this page to gmp-discuss at gmplib.org
Copyright 2000-2016 Free Software Foundation
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.