Question: Select all correct outcomes when the program below is executed using 4 processes. You can assume that the program is syntactically correct ( no error

Select all correct outcomes when the program below is executed using 4 processes. You can assume that the program is syntactically correct (no error at compilation), but no communication correctness is guaranteed. READ THE CODE CAREFULLY!!!
The syntax for MPI_Send and MPI_Recv are as follow:
int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
int MPI_Recv( void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
==========CODE BEGINS==========
#include
#include
#include
int main(int argc, char** argv)
{
int my_rank;
int size;
int tag=0;
int buf;
MPI_Status status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
/* set up data */
buf = my_rank;
printf("Process %2d has original value %2d
",my_rank,buf);
if (my_rank ==0){
MPI_Recv(&buf,1,MPI_INT,1,0,MPI_COMM_WORLD,&status);
MPI_Send(&buf,1,MPI_INT,1,0,MPI_COMM_WORLD);
}
if (my_rank ==1){
MPI_Send(&buf,1,MPI_INT,0,tag,MPI_COMM_WORLD);
MPI_Recv(&buf,1,MPI_INT,0,tag,MPI_COMM_WORLD,&status);
}
printf("Process %2d now has value %2d
",my_rank,buf);
MPI_Finalize();
}/* end main */
==========CODE ENDS==========
The program runs and exits normally.
The program crashes as there are more processes than the number of processes being used in the code.
The "now has value" statements show 1s for both process 0 and 1
The "now has value" statements show 0s for both process 0 and 1

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!