I am working on a project where we need to parallelize this problem using MPI. So the basic idea is each process will get its share of points, do the test (whether the points are in the circle) then call MPI_Reduce. The root then will get the reduced result and present the final answer.
What I am confused about is what to reduce. Should each process calculate pi, call reduce with the pi and the root just take the average of the reduced pi value ? or Should each process call reduce with the number of hits(successful points inside the circle) and then the root calculates the pi using this result? Hope this was clear. Thanks.
I would definitely do the latter: have each process return the number of hits and have the root function calculate pi using these results. In this manner, you doing the same process as you would if calculating this serially.