
When run on our 16 cores, we observe a speedup of 14.2x. Present in the Engines’ working directory. The pi files via ftp the first time you run it, if they are not Up IPython, enable matplotlib, and type run parallelpi.py. With the file parallelpi.py in your current working directory, open The code to run this calculation in parallel is contained inĮxamples/parallel/parallelpi.py. We will also use the plot_two_digit_freqs() function to plot the """ allfreqs = np.zeros_like(freqlist) for f in freqlist: allfreqs += f return allfreqs """ d = txt_file_to_digits(filename) freqs = two_digit_freqs(d) return freqs def reduce_freqs(freqlist): """ Add up a list of freq counts to get the total counts. To perform thisĬalculation, we will need two top-level functions from pidigits.py,Ĭompute_two_digit_freqs() and reduce_freqs(): Step the counts from each engine will be added up. The overall idea of the calculation is simple: each IPython engine willĬompute the two digit counts for the digits in a single file. The result using a 2D matrix in Matplotlib. Will calculate the frequencies of all 2 digits sequences (00-99) and then plot To make things a little more interesting we A total of 15 of these files will be used, for a Theseįor the parallel calculation, we have copied these files to the local hardĭrives of the compute nodes. Will use pre-computed digit of pi from the website of Professor Yasumasa Parallel calculation #Ĭalculating many digits of pi is a challenging computational problem in itself.īecause we want to focus on the distribution of digits in this example, we That brings us to the parallel calculation.


It is clear that to reduce the relative fluctuations in the counts, we need

Statistical fluctuations are still rather large: The resulting plot of the single digit counts shows that each digit occursĪpproximately 1,000 times, but that with only 10,000 digits the evalf ( 10000 ) In : digits = ( d for d in str ( pi )) # create a sequence of digits In : freqs = one_digit_freqs ( digits ) In : plot_one_digit_freqs ( freqs ) Out:
