Monte carlo in parallel computing
2016-08-23
0 0 0
no vote
Other
Earn points
Part 3 : Program to estimate the value of PI using Monte Carlo
In this program we are estimating the value of PI
The input for this program is number of processes and the number of tosses.
Out of these tosses we check how many are inside the circle through which we estimate the value of pi.
We define Monte Carlo function for generating random values for tosses and for calculating the number of tosses result in hitting the circle for each process
Process 0 reads the total number of tosses and broadcasts it to other processes
Other processes take this value and each process calls the Monte Carlo function to generate random points which is the value assigned to the tosses and number_in_circle is calculated which
checks how many points are inside the circle and also find the pi estimate.
finally the local variable number_in_circle from each process is reduced by process 0 to 1 Global sum.
Command to run : mpirun -np (number of processes)
c
Related Source Codes
PClite
0
0
no vote
generic embeded FTP Client
0
0
no vote
UDP Test Demo
0
0
no vote
TMS320F28335 DSP transmits data to EEPROM through
0
0
no vote
TMS320F28335 CAN communication source code
0
0
no vote
No comment