MC
MPI version of a Monte Carlo Quadrature Program


MC is a program which should use MPI to speed up its estimate of an integral of the form

Integral ( unit hypercube ) F(X1,X2,...,XD) dx
However, the code you will see here is only a sequential version!

The program uses the Monte Carlo method, so it simply picks SAMPLE_NUM points at random in the unit hypercube, evaluates F at each point and takes the average.

You are to convert the program by adding the appropriate MPI calls ... and include statements ... anything else you need! You might want to define a few extra variables, to differentiate between "local" and "global" variables. In other words, each process will define an estimate of the integral, and then a total estimate will be made. The original variable was called Q but now it might help to distinguish between Q_local and Q_global.

Warning: you are working with a random number generator, which requires the use of a "seed" value. In parallel processing, you need to be careful to ensure that the multiple processes "share" the random number generator correctly. You don't want each process to compute the same string of random values!

Source Code:

Completed Source Code:

Here are "completed" versions of the programs.

Script for Execution on the FSU HPC Cluster:

Before using MPI on the FSU_HPC cluster, you must first set up the appropriate environment. You can do this by typing

        module load gnu-openmpi
      

Once you have set up the environment, you should compile your program, using one of the following:

to create your executable program. Now you can use the msub command to submit a script to run your program.


Last revised on 28 August 2012.