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.

Timing results (in seconds):



GMP devel 2013-09-28

Number of
digits
AMD
K10 Thuban
3.2 GHz
AMD
Piledriver
4 GHz
Intel
Conroe
2.13 GHz
Intel
Nehalem
2.67 GHz
Intel
Sandybridge
3.3 GHz
Intel
Haswell
2.9 GHz
POWER7-smt4
3.7 GHz
Itanium 2
0.9 GHz
100,000   0.032   0.036 0.025 0.021 0.035    
1,000,000   0.48   0.68 0.43 0.39 0.545    
10,000,000   8.70   11.8 7.28 6.73 9.47    
100,000,000   142   184 117 107 158    
1,000,000,000   2153     1768 1599      

GMP devel 2011-05-10

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
PowerPC 970
1.8 GHz
Itanium 2
0.9 GHz
100,000   0.017       0.02    
1,000,000   0.42       0.42    
10,000,000   7.37       7.55    
100,000,000   124       120    
1,000,000,000   1957            

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
PowerPC 970
1.8 GHz
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
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
Phenom II (K10)
3.2 GHz
Intel
Pentium 4
3.2 GHz
Intel
Core 2
2.13 GHz
Intel
Core i7
2.67 GHz
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            

How do these numbers compare to other π computing programs out there? It seems gmp-chudnovsky.c with GMP 5.0 is faster than all specialised π programs on Athlon, Core 2 and 64-bit Pentium 4, but a tad bit slower on 32-bit Pentium 4.

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 5.0, 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 the FFT multiply code of GMP 5.0's 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. You'll need around 4000 high-end swap disks in order to compute 1 quintillion digits, but surely that will qualify you for a discount ("buy 4000, pay for 3999").



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