Skip to content

Latest commit

 

History

History
65 lines (38 loc) · 2.84 KB

README.md

File metadata and controls

65 lines (38 loc) · 2.84 KB

drawing

This program computes the Pi number using different Spigot algorithms. To perform the operations it is used a floating point precision arithmetic library. PiDecimals allows you to use GMP (The GNU Multiple Precision Arithmetic Library) or MPFR (The GNU Multiple Precision Floating-Point Reliable Library) to compute the Pi number with the algorithms supported.

It can be used as a benchmark to compare and test the CPU performance in a single thread way or even with multiple threads. Threads are managed with OpenMP.

drawing

Spigot Algorithms

Currently, PiDecimals allows you to compute Pi using three different algorithms:

  • Bailey-Borwein-Plouffe. The expression is presented below:

$$ \pi = \sum_{n=0}^{\infty}\frac{1}{16^{n}} (\frac{4}{8n + 1} - \frac{2}{8n + 4} - \frac{1}{8n + 5} - \frac{1}{8n + 6}) $$

  • Bellard. The expression is presented as follows:

$$ 64\pi = \sum_{n=0}^{\infty}\frac{-1^{n}}{1024^{n}} (-\frac{32}{4n + 1} - \frac{1}{4n + 3} + \frac{256}{10n + 1} - \frac{64}{10n + 3} - \frac{4}{10n + 5} - \frac{4}{10n + 7} + \frac{1}{10n + 9}) $$

  • Chudnovsky. The expression is shown below:

$$ \frac{426880\sqrt{10005}}{\pi} = \sum_{n=0}^{\infty}\frac{(6n)! (545140134n + 13591409)}{(n!)^{3}(3n)! (-640320)^{3n}} $$

Multiple Precision Floating Point Libraries

Currently, PiDecimals allows yoy to compute Pi using two different floating point arithmetic libraries:

Compilation and Installation

To compile the code succesfully it is necessary to have installed OpenMP, GMP and MPFR library. If you are using a Linux distro it is very likely that you already have these dependencies installed.

To compile the source code use the "compile.sh" located at the root project directory. In the future it is expected to replace the bash script with a Make file.

Launch

When the source code is compiled you are ready to launch:

./PiDecimals.x library algorithm precision num_threads [-csv]
  • library can be 'GMP' or 'MPFR'
  • algorithm is a value between 0 and X. The X value may depend on the library used.
  • precision param is the value of precision you want to use to perform the operations.
  • num_threads param is the number of threads that you want to use to perform the operations.
  • -csv param is optional. If this param is used the program will show the results in csv format.

En example of use could be:

./PiDecimals.x MPFR 1 50000 4 

And the output could be:

drawing