Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you write this program MPI Simplest easiest way to read it as possible For p

ID: 3866721 • Letter: C

Question

Can you write this program MPI Simplest easiest way to read it as possible For parallel programming This exercise is from Question 6-5 of the textbook at page 194 Implement the butterfly barrier described in Section 6.1.4, assume the number of processes is a power of 2, e.g.2,4, 8, 16, etc. Investigate the time taken by your butterfly barrier by using the code such as: t1 = MP1wtime(); butterfly barrierO;//call to your butterfly barrier t2 MPIwtime(); printf Elapsed time %d secondsin", 12-tl); - Demonstrate your program in the class on the due date.

Explanation / Answer

#include "mpi.h" #include #include void srandom (unsigned seed); double dboard (int darts); #define DARTS 50000 /* number of throws at dartboard */ #define ROUNDS 100 /* number of times "darts" is iterated */ #define MASTER 0 /* task ID of master task */ int main (int argc, char *argv[]) { double homepi, /* value of pi calculated by current task */ pisum, /* sum of tasks' pi values */ pi, /* average of pi after "darts" is thrown */ avepi; /* average pi value for all iterations */ int taskid, /* task ID - also used as seed number */ numtasks, /* number of tasks */ rc, /* return code */ i; MPI_Status status; /* Obtain number of tasks and task ID */ MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numtasks); MPI_Comm_rank(MPI_COMM_WORLD,&taskid); printf ("MPI task %d has started... ", taskid); /* Set seed for random number generator equal to task ID */ srandom (taskid); avepi = 0; for (i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote