Question: 2 questions A) Explain the difference(s) between the MPI_BCast(...) function and my-bcast() function B) Which one is more efficient? How would you demonstrate that one
2 questions
A) Explain the difference(s) between the MPI_BCast(...) function and my-bcast() function
B) Which one is more efficient? How would you demonstrate that one implementation is more efficient that the other one? Explain your answer
void my_bcast(void* data, int count, MPI_Datatype datatype, int root, MPI_Comm communicator) { int world_rank; MPI_Comm_rank(communicator, &world_rank); int world_size; MPI_Comm_size(communicator, &world_size); if (world_rank == root) { // If we are the root process, send our data to everyone int i; for (i = 0; i < world_size; i++) { if (i != world_rank) { MPI_Send(data, count, datatype, i, 0, communicator); } } } else { // If we are a receiver process, receive the data from the root MPI_Recv (data, count, datatype, root, 0, communicator, MPI_STATUS_IGNORE); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
