We use the trapezoid method to calculate the following integral:
which is the integral of 4/(1+x^2) for x from 0 to 1.
Calculate PI in 2 ways with MPI:
- MPI_Reduce
- MPI_SendRecv
Automatically:
- Execute the script
run.sh
Manually:
$ cmake . & make
$ mpirun -n 4 hello_word
$ mpirun -n 4 calculate_pi
In calculate_pi.cpp
, you can choose the way to calculate PI with Macros:
USE_MPI_REDUCE
USE_MPI_SEND_RECV
NoeWang at Shanghai Jiao Tong University