Examples in MPI/C

- Example-1
- Brief description:
Using Monte Carlo methods, two things are computed:
- Pi as the area of a circle of radius 1 in a 2-D space.
- The volume of a d-dimensional hypersphere of radius
1. The dimension is between 1 and 10.
So essentially the program performs 4 steps:
- Compute the volume of the unit sphere, in a random
manner, and given the dimension, few darts are thrown at an area
between 0 and 1.
- Determine the frequency of those darts that fell within
this area and those falling outside it. Then, within each processor
given this frequency and the number of tries, the average is computed.
- After computing the average or mean, the overall volume
of the sphere is easily computed. Essentially, we multiply this
average by 2^(dim) giving us the overall volume.
- Given the average, sphere darts, and per processor tries,
we compute the standard deviation.
- The source code: here is the program for
this method. Here is also another source
( the header) computing Pi using Monte
Carlo method.
- Example-2
- Brief description:
Using Simpson's rule we compute the value of Pi. When using this
approach and integrating on a multiprocessor, the logical thing to do
would be to partition the interval to subintervals and make each
processor run on one of these subintervals. In turn, each processor
applies Simpson's rule to its own interval, again, partitioning it
into subintervals of equal number to the one above it, etc. Among the
processors, one takes charge of receiving and adding up the results.
- The source code is available
here.
- Example-3
- Brief description:
This program implements the concurrent wave equation described
in Chapter 5 of Fox et al., 1988, Solving Problems on Concurrent
Processors, vol 1.
A vibrating string is decomposed into points. Each processor is
responsible for updating the amplitude of a number of points over
time. At each iteration, each processor exchanges boundary
points with nearest neighbors.
Note: This version uses low level sends and receives to exchange
boundary points.
- The source code is available here.
- Example-4
- Brief description:
This is another version implementing the concurrent wave
equation described in Chapter 5 of Fox et al., 1988, Solving
Problems on Concurrent Processors, vol 1.
- The source code is available here.
- Example-5
- Brief description:
Another version implementing the concurrent wave
equation described in Chapter 5 of Fox et al., 1988, Solving
Problems on Concurrent Processors, vol 1.
Note: This version illustrates the use of persistent
communication.
- The source code is available here.
- Example-6
- Brief description:
This program uses a finite difference scheme to solve
Laplace's equation for a square matrix distributed over a square
(logical) processor topology. A complete description of the
algorithm is found in Fox, et al "Solving problems on concurrent
Processors, Volume 1: General Techniques and Regular Problems,
Prentice Hall, Englewood Cliffs, New Jersey.
- The source code is available here.
- Example-7
- Brief description:
Another version of the red/black SOR solution to Laplaces'
Equation.
- The source code is available here.
- Example-8
- Brief description:
Another simple implementation of the Nbody problem. This uses the
simple but highly suboptimal n^2 algorithm, and does not take
advantage of symmetry. The time integrator is a simple leapfrog scheme.
- The source code can be found
here.
- Example-9
- Brief description:
An example of a set of routines to circulate data around in a ring.
- The source code is here.
- Example-10
- Brief description:
This is an example of particles interaction. To make it simple, it is
assumed that every process is responsible for the same
number of particles. Also, every process initializes positions and
mass of particles it is responsible for.
- The source code is here.
Saleh Elmohamed
Last modified: Sun Feb 22 04:14:48 EST 1998