GMP logo Computing billions of π digits using GMP

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

Timing results:

GMP 5.0

Number of
digits
AMD
Athlon (K8)
2.2 GHz
AMD
Phenom II (K10)
3.2 GHz
Intel
Pentium 4
3.4 GHz
Intel
Core 2
2.13 GHz
Intel
Core i7
2.67 GHz
PowerPC 970
1.6 GHz
100,000   0.03 0.08 0.04 0.03 0.13
1,000,000   0.48 1.49 0.89 0.69 2.01
10,000,000   8.2 26.3 16.4 12.0 35.3
100,000,000   134 430 269 191 576
1,000,000,000     6656   2896  


GMP 4.3

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.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@gmplib.org
Copyright 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.