Consider the following MPI code. Does it compile and run correctly? Correct the code if necessary. Explain what the two functions MPI_Comm_rank and MPI_Comm_size do.
Q4. (a) Consider the following MPI code. Does it compile and run correctly? Correct the code if necessary. Explain what the two functions MPI_Comm_rank and MPI_Comm_size do.
#include "mpi.h"
#include <stdio.h>
int main( int argc, char *argv[] ) {
int rank, size;
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
MPI_Comm_size( MPI_COMM_WORLD, &size );
printf( "I am %d of %d\n", rank, size );
MPI_Finalize();
return 0;
}
(b) Explain the difference between blocking and non-blocking communication. Explain clearly the two functions in MPI for blocking communication and the parameters they require.