Question
In C++: Exercise 1. [ 8 points] Write either a single program or two separate C/C++ programs that use(s) MPI blocking and non-blocking commands MPI_Send,
In C++:
Exercise 1. [ 8 points] Write either a single program or two separate C/C++ programs that use(s) MPI blocking and non-blocking commands MPI_Send, MPI_Rcvd, MPI_Isend and MPI_Ircvd to exchange one double value between process with rank 0 and process with rank 1. Calculate the execution time using MPI_Wtime to compute the execution time and write it down in the table below as follows:
Execution Time | |
A single transmission using blocking communication | |
A single transmission using non blocking communication | |
Two transmissions (round trip) using blocking communication | |
Two transmissions (round trip) using non blocking communication |
Exercise 2. [ 4 points] Modify the ring example given in class to calculate the execution time using MPI_Wtime of the transmission of the value 5 from process with rank 0 to process with rank 1, etc. until the value 5 is received back at the process with rank 0. Use only blocking communication. Launch the execution of the program with a varied number of parallel processes (mpirun -n 10 ./a.out to launch the executable a.out for 10 processes) and write down the execution time of the ring example as follows:
Ring Example:
int token;
if (rank != 0) {
MPI_Recv(&token, 1, MPI_INT, (rank - 1) % size, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("Process %d received token %d from process %d ", rank, token, (rank - 1) % size);
} else {
// Set the token's value if you are process 0
token = -1;
}
MPI_Send(&token, 1, MPI_INT, (rank + 1) % size, 0, MPI_COMM_WORLD);
// Now process 0 can receive from the last process.
if (rank == 0) {
MPI_Recv(&token, 1, MPI_INT, size - 1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
printf("Process %d received token %d from process %d ", rank, token, size - 1);
}
Execution Time | |
Ring with 4 nodes | |
Ring with 8 nodes | |
Ring with 10 nodes | |
Ring with 12 nodes |
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started