Information

Author(s) Erik-Jan Lingen, Matthias Möller
Deadline No deadline
Submission limit No limitation

Sign in

[MPI] Solution 6 : Random Number Generator

This material is part of the course Practical Introduction to Parallel Programming and meant for educational purposes only.


Task

Implement a parallel program that generates a stream of uniform random numbers within the range \([0,1]\) within each process.

The program should stop if it has found ten numbers that are smaller than \(\epsilon = 1 \cdot 10^{-7}\).

When the program has found ten numbers (or more), the master process (with rank zero) should collect all found numbers and print them to the terminal.

The code below implements a sequential version of the program.

Hints

Use the provided function next_random to generate the stream of random numbers. This function will set a different random seed for each process. Without this, no speedup is possible. Why not?

Use collective MPI functions to determine when the program should stop and to collect the results on the master.

Measure the parallel speedup of your program. What can you do to improve the performance?


Question 1: Random Number Generator
Question 2: Number of MPI processes

Specify the number of MPI processes (1-64) that should be used for running your program (mpirun -np <nproc>)

Question 3: Command Line Argument

Specify the command line arguments that should be passed to your program when it is run. Arguments must be given in quotes and separated by commas. Leave this filed empty if you do not want to specify command line arguments.

Example: "1","int","arg=2" is interpreted as three arguments 1, int, and arg=2.