Question: Complete the MPI program 'Send-Receive-Checking' to perform the necessary error checking for our previous example 'Send-Receive.c' to ensure that two processes are required for running

Complete the MPI program 'Send-Receive-Checking' to perform the necessary error checking for our previous example 'Send-Receive.c' to ensure that two processes are required for running the program.

#include #include #include

int main(int argc, char* argv[]) { int my_rank, comm_sz; int token = 1; MPI_Init(&argc, &argv);

MPI_Comm_size(MPI_COMM_WORLD, &comm_sz); MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

if ( ) { if (my_rank == 0)

fprintf(stderr, " ");

MPI_Finalize();

return 0; }

if(my_rank == 0) { MPI_Send(&token, 1, MPI_INT, 1, 0, MPI_COMM_WORLD); printf(" Process %d sent token %d to process 1. ", my_rank, token); }

else { MPI_Recv(&token, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); printf("Process %d received token %d from process 0. ", my_rank, token); }

MPI_Finalize();

return 0; }

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!