Information

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

Sign in

[MPI] Solution 2 : Pass Data (blocking point-to-point communication)

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


Task

Implement an MPI program in which a single integer is passed around all processes using blocking point-to-point communication.

That is, the process with rank zero assigns the initial value to the integer. It then passes the integer to the process with rank one.

This process, in turn, passes the integer to the process with rank two.

This continues until the process with rank \((p - 1)\), with \(p\) the number of processes. This last process passes the integer back to the process with rank zero.

Finally, the process with rank zero prints the integer to the terminal and the program ends.

Test the program with one and more processes.

Hints

Use the functions MPI_Send and MPI_Recv to pass the integer from one process to the next.

Use the function MPI_Comm_rank to determine from which process the integer is to be received, and to which process the integer is to be sent.

Use the function MPI_Comm_size to determine the total number of processes.


Question 1: Pass Data
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.