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.

Note: All Intel processors below are affected by the security bugs Meltdown, Spectre, Foreshadow, and MDS. Skylake is further affected by the security bug Jcc. With proper workarounds, the performance of the Intel processors would be considerably lower!



GMP devel

Number of
digits
AMD
K10 Thuban
Phenom II
1090T
AMD
Piledriver
FX-8350
AMD
Zen1
Ryzen
2700X
AMD
Zen2
Ryzen
3700X
Intel
Penryn
Xeon
E3110
Intel
Nehalem
Xeon
X3470
Intel
Sandybridge
Xeon
E3-1270
Intel
Haswell
Xeon
E3-1271v3
Intel
Broadwell
Xeon
E3-1285Lv4
Intel
Skylake
Xeon
E3-1270v5
IBM
POWER7
IBM
POWER8
IBM
POWER9
3800 MHz
100,000 0.024 0.024 0.015 0.012 0.034 0.037 0.026 0.016 0.016 0.016 0.028 0.020 0.014
1,000,000 0.46 0.48 0.25 0.21 0.61 0.61 0.37 0.29 0.27 0.27 0.51 0.53 0.31
10,000,000 8.24 8.36 4.33 3.70 11.0 10.8 6.25 4.94 4.61 4.38 8.96 9.06 5.17
100,000,000 135 134 69 59 177 170 99 78 72 70 144 143 80
1,000,000,000 2107 2033 1057 876   2540 1489 1179 1107 1079 2197 2143 1228



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