Parallel Implementation of Multiple-Precision Arithmetic and 2,576,980,370,000 Decimal Digits of Π Calculation

Parallel Implementation of Multiple-Precision Arithmetic and 2,576,980,370,000 Decimal Digits of Π Calculation

View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Tsukuba Repository Parallel implementation of multiple-precision arithmetic and 2,576,980,370,000 decimal digits of π calculation 著者 Takahashi Daisuke journal or Parallel computing publication title volume 36 number 8 page range 439-448 year 2010-08 権利 (C) 2010 Elsevier B.V. URL http://hdl.handle.net/2241/106066 doi: 10.1016/j.parco.2010.02.007 Parallel Implementation of Multiple-Precision Arithmetic and 2; 576; 980; 370; 000 Decimal Digits of π Calculation Daisuke Takahashi Graduate School of Systems and Information Engineering, University of Tsukuba 1-1-1 Tennodai, Tsukuba, Ibaraki 305-8573, Japan Abstract We present efficient parallel algorithms for multiple-precision arithmetic operations of more than several million decimal digits on distributed-memory parallel com- puters. A parallel implementation of floating-point real FFT-based multiplication is used, since the key operation for fast multiple-precision arithmetic is multiplication. The operation for releasing propagated carries and borrows in multiple-precision ad- dition, subtraction and multiplication was also parallelized. More than 2.576 trillion decimal digits of π were computed on 640 nodes of Appro Xtreme-X3 (648 nodes, 147.2 GFlops/node, 95.4 TFlops peak performance) with a computing elapsed time of 73 hours 36 minutes which includes the time required for verification. Key words: multiple-precision arithmetic, fast Fourier transform, distributed-memory parallel computer 1 Introduction Several software packages are available for multiple-precision computation [1{ 4]. At present, GNU MP [3] is probably the most widely used package due to its greater functionality and efficiency. Using GMP 4.2 with sufficient memory, it should be possible to compute up to 41 billion digits [3]. In 2009, Bellard computed π up to about 2.7 trillion digits in about 131 days using an Intel Core i7 PC [5]. However, parallel processing using a distributed-memory parallel computer is required to calculate further digits in a reasonable amount of time. Email address: [email protected] (Daisuke Takahashi). Preprint submitted to Elsevier Science 1 February 2010 Parallel implementation of Karatsuba's multiplication algorithm [6,7] on a distributed-memory parallel computer was proposed [8]. Karatsuba's algo- rithm is known as the O(nlog2 3) multiplication algorithm. However, multiple-precision multiplication of n-digit numbers can be per- formed in O(n log n log log n) operations by using the Sch¨onhage-Strassenal- gorithm [9], which is based on the fast Fourier transform (FFT). In multiple-precision multiplication of more than several thousand decimal dig- its, FFT-based multiplication is the fastest method. FFT-based multiplication algorithms are known to be good candidates for parallel implementation. The Fermat number transform (FNT) for large integer multiplication was performed on the Connection Machine CM-2 [10]. On the other hand, the number theoretic transform (NTT) uses many modulo operations, which are slow due to the integer division process. Thus, floating-point real FFT-based multiplication was used for multiple-precision multiplication on distributed- memory parallel computers. p Parallel computation of 2 up to 1 million decimal digits was performed on a network of workstations [11]. However, multiple-precision parallel division was not presented in this paper, and a parallel version of Karatsuba's multi- plication algorithm was used. Section 2 describes the parallelization of multiple-precision addition, subtrac- tion and multiplication. Section 3 describes the parallelization of multiple- precision division and square root operations. Section 4 presents the experi- mental results. Section 5 describes the calculation of π to 2; 576; 980; 370; 000 decimal digits on a distributed-memory parallel computer. Finally, section 6 presents some concluding remarks. 2 Parallelization of Multiple-Precision Addition, Subtraction, and Multiplication 2.1 Parallelization of Multiple-Precision Addition, Subtraction Let us consider an n-digit number X with radix-B. nX−1 i X = xiB ; (1) i=0 where 0 ≤ xi < B. 2 Algorithm 1 Sequential Addition P P Input: X = n−1 x Bi;Y = n−1 y Bi i=0 i P i=0 i n−1 i Output: Z = X + Y := i=0 ziB 1: c 0 2: for i = 0 to n − 2 do 3: w xi + yi + c 4: c w div B 5: zi w mod B 6: zn−1 xn−1 + yn−1 + c 7: return Z. Fig. 1. Multiple-precision sequential addition In the case of block distribution, the n-digit multiple-precision numbers are distributed across all P processors. The corresponding index at processor m (0 ≤ m ≤ P − 1) is denoted as i (m = bi=dn=P ec) in equation (1). In the case of cyclic distribution, the n-digit multiple-precision numbers are also distributed across all P processors. The corresponding index at processor m (0 ≤ m ≤ P − 1) is denoted as i (m = i mod P ) in equation (1). The arithmetic operation counts for n-digit multiple-precision sequential ad- ditions, subtractions is clearly O(n). Also, the arithmetic operation counts for n-digit multiple-precision sequential multiplication by a single-precision inte- ger is O(n). However, releasing the carries and borrows in these operations is a major factor that can prevent parallelization. For example, a pseudo code of multiple-precision sequential addition is shown in Fig. 1. Here, c is a variable to store the carry, w is a temporary variable and B is the radix of the multiple-precision numbers. We assume that the input data has been normalized from 0 to B − 1 and is stored in arrays X and Y . Since in this program, at line 3, the value of c is used recurrently to deter- mine the value of w, the algorithm can not be parallelized because of data dependency. Fig. 2 shows an algorithm that allows the parallelization of addition by creating a method for the releasing of the carries. We assume that the input data has been normalized from 0 to B − 1 and is stored in arrays X and Y . Multiple-precision addition without the propagation of carries is performed at lines 1 and 2. While the maximum value of zi (0 ≤ i ≤ n − 2) is greater than or equal to B, the carries are computed in lines 5 and 6, then the carries are released in lines 7 to 9. The maximum value can be evaluated in parallel easily. Here, ci (0 ≤ i ≤ n − 1) is a working array to store carries. 3 Algorithm 2 Parallel Addition P P Input: X = n−1 x Bi;Y = n−1 y Bi i=0 i P i=0 i n−1 i Output: Z = X + Y := i=0 ziB 1: for i = 0 to n − 1 do in parallel 2: zi xi + yi 3: while max (zi) ≥ B do 0≤i≤n−2 4: c0 0 5: for i = 0 to n − 2 do in parallel 6: ci+1 zi div B 7: for i = 0 to n − 2 do in parallel 8: zi (zi mod B) + ci 9: zn−1 zn−1 + cn−1 10: return Z. Fig. 2. Multiple-precision parallel addition In line 6, communication is required to send the carries to the neighbor proces- sor. The amount of communication is O(1) in the block distribution, whereas the amount of communication is O(n=P ) in the cyclic distribution on parallel computers that have P processors. In this algorithm, it is necessary to repeat the normalization until all car- ries have been released. For random inputs, this process is performed usu- ally few times. When the propagation of carries repeats, as in the case of 0:99999999 ··· 9 + 0:00000000 ··· 1, we have to use the carry skip method [12]. A pseudo code for multiple-precision parallel addition with the carry skip method is shown in Fig. 3. We assume that the input data has been normalized from 0 to B − 1 and is stored in array X and Y . Here, ci (0 ≤ i ≤ n − 1) is a working array to store carries. Multiple-precision addition without the propagation of carries is performed at lines 1 and 2. Then, incomplete normalization is performed from 0 to B in lines 3 to 9. Note that the while loop in lines 3 to 9 is repeated at most twice. The range for carry skipping is determined in lines 11 to 22. Finally, carry skipping is performed in lines 23 to 26. Because carry skips occur intermittently in the case of 0:998998998 ··· + 0:0100100100 ···, this is the one of the worst case of the carry skip method. For the worst case, the carry look-ahead method is effective. However, the carry look-ahead method requires O(log P ) steps on parallel computers that have P processors. Since we assumed that such a worst case occur rarely, the carry skip method was used for multiple-precision parallel addition and subtraction. 4 Algorithm 3 Parallel Addition with Carry Skip Method P P Input: X = n−1 x Bi;Y = n−1 y Bi i=0 i P i=0 i n−1 i Output: Z = X + Y := i=0 ziB 1: for i = 0 to n − 1 do in parallel 2: zi xi + yi 3: while max (zi) > B do 0≤i≤n−2 4: c0 0 5: for i = 0 to n − 2 do in parallel 6: ci+1 zi div B 7: for i = 0 to n − 2 do in parallel 8: zi (zi mod B) + ci 9: zn−1 zn−1 + cn−1 10: while max (zi) = B do 0≤i≤n−2 11: for i = 0 to n − 1 do in parallel 12: if (zi = B) then 13: pi i 14: else 15: pi n − 1 16: l min (pi) 0≤i≤n−1 17: for i = l + 1 to n − 1 do in parallel 18: if (zi < B − 1) then 19: pi i 20: else 21: pi n − 1 22: m min (pi) l+1≤i≤n−1 23: zl zl − B 24: for i = l + 1 to m − 1 do in parallel 25: zi zi − (B − 1) 26: zm zm + 1 27: return Z.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    20 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us