GMP logo Computing billions of π digits using GMP

This program, written by Hanhong Xue, can be used to compute tens of billions of digits of π, provided you have enough memory in your system: gmp-chudnovsky.c (last updated 2008-12-05).

For the program to work properly for more than 231 bits (about 600 million digits) you need to to use GMP 4.2 (or later).

Timing results with GMP 4.3:

Number of digits Time (s)
AMD Opteron (K8)
2.2 GHz
Time (s)
AMD Opteron (K10)
2.3 GHz
Time (s)
Intel "Core 2"
2.13 GHz
Time (s)
PowerPC 970
1.6 GHz
Time (s)
Pentium 4
3.2 GHz
100,000 0.04 0.04 0.05 0.15 0.10
1,000,000 0.90 0.77 1.08 2.3 1.77
10,000,000 16.8 13.9 19.7 40.4 31.0
100,000,000 291 246 349 692 542
1,000,000,000 - 4520   -  

Timing results with GMP 4.2.4:

Number of digits Time (s)
AMD Opteron (K8)
2.2 GHz
Time (s)
AMD Opteron (K10)
2.3 GHz
Time (s)
Intel "Core 2"
2.13 GHz
Time (s)
PowerPC 970
1.6 GHz
Time (s)
Pentium 4
3.2 GHz
100,000 0.06 - 0.12 0.17 0.15
1,000,000 1.48 - 2.35 2.92 2.9
10,000,000 26.8 - 42.6 52.5 52.3
100,000,000 467 - 756 902 902
1,000,000,000 - -   -  

How do these numbers compare to other π computing programs out there? It seems gmp-chudnovsky.c with GMP 4.3 is faster than all specialized π 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 4.3, 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 4.x'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. The fabled GMP 5 will allow the patient and wealthy to compute up to at least 1 quintillion (1015) digits, and unlike GMP 4.x, GMP 5 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 Free Software Foundation
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.