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
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
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