Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Use OpenMP to implement the histogram program. Have process 0 read in the input data and distribute it among the processes. Also have process 0 print...

1.Use OpenMP to implement the histogram program. Have process 0 read in the input data and distribute it among the processes. Also have process 0 print out the histogram. Present code in a Word document.

2. 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 π 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 = pi / 4

We can use this formula to estimate the value of π with a random number generator:

number in circle = 0;

for (toss = 0; toss < number of tosses; toss++) {

x = random double between −1 and 1;

y = random double between −1 and 1;

distance squared = x∗x + y∗y;

if (distance squared <= 1) number in circle++;

}

pi estimate = 4∗number in circle/((double) number of tosses);

Show OpenMP program that uses a Monte Carlo method to estimate π. Read in the total number of tosses before forking any threads. Use a reduction clause to find the total number of darts hitting inside the circle. Print the result after joining all the threads. You may want to use long long ints for the number of hits in the circle and the number of tosses, since both may have to be very large to get a reasonable estimate of π.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question