Consider themakepi.cppprogramfrom program 1 and linked in various places on this web site. Convert it to use MPI instead of Pthreads. Use Programming Assignment as a guide for further instructions.Suppose we toss darts randomly at a square dartboard, whose bullseye is at the
origin, and whose sides are 2 feet in length. Suppose also that thereâs a circle
inscribed in the square dartboard. The radius of the circle is 1 foot, and itâs area
is p square feet. If the points that are hit by the darts are uniformly distributed
(and we always hit the square), then the number of darts that hit inside the circle
should approximately satisfy the equation
number in circle
total number of tosses
=
p
4
,
since the ratio of the area of the circle to the area of the square is p/4.
We can use this formula to estimate the value of p with a random number
generator:
number in circle = 0;
for (toss = 0; toss
x = random double between -1 and 1;
y = random double between -1 and 1;
distance squared = x*x + y*y;
if (distance squared
}
pi estimate = 4*number in circle/((double) number of tosses);No report is necessary.
Other Requirements
- Use command-lineargumentsto determine the global number ofiterationsto be processed. The number of processes should be determined by mpirun or mpiexec.
- Name your main programprog03.cpp. You can leave it in yourhomedirectory (or a subdirectory), where I will examine it. Otherwise, you can upload a copy of the program in a zip file, if you wish.
In your comment block to begin your main program, other than the function of the program and the variable dictionary, include a set of comments of the following format. It is very important for you to include your name, the compiler you used, the due date, and the program identity: