Question: A. You are to write a parallel program using MPI in which the mean value of a Matrix is to be calculated. The full matrix

A. You are to write a parallel program using MPI in which the mean value of a Matrix is to be calculated. The full matrix is residing in the memory of process 0, and the mean value need to be calculated and made available at all executing processes. Do not write the program but state the sequence of all MPI calls needed in your program in the sequence by which they should appear. You do not have to write the full call with all of its parameters, just the name of the call.

B.

i) Does the following code have a deadlock? _____________

Why? _______________________ (4 pts)

ii) If you answer is Yes, then rewrite the code using the same MPI calls below to fix the problem.

MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

if (myrank == 0) {

MPI_Send(a, 10, MPI_INT, 1, 1, MPI_COMM_WORLD);

MPI_Send(b, 10, MPI_INT, 1, 2, MPI_COMM_WORLD);

}

else if (myrank == 1) {

MPI_Recv(b, 10, MPI_INT, 0, 2, MPI_COMM_WORLD);

MPI_Recv(a, 10, MPI_INT, 0, 1, MPI_COMM_WORLD);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!