Lecture 12 Monte Carlo methods in parallel computing - PowerPoint PPT Presentation

About This Presentation
Title:

Lecture 12 Monte Carlo methods in parallel computing

Description:

Monte Carlo methods are often used in. simulating physical and mathematical systems. ... Set SumG = 0.0. Do While i N. Pick two random numbers xi and yi. If ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 13
Provided by: xw
Category:

less

Transcript and Presenter's Notes

Title: Lecture 12 Monte Carlo methods in parallel computing


1
Lecture 12 Monte Carlo methods in parallel
computing
  • Parallel Computing
  • Fall 2008

2
What is Monte Carlo?
  • Monte Carlo methods are a class of computational
    algorithms that rely on repeated random sampling
    to compute their results.
  • Monte Carlo methods are often used in
  • simulating physical and mathematical systems.
  • studying systems with a large number of coupled
    degrees of freedom, such as fluids, disordered
    materials, strongly coupled solids, and cellular
    structures (see cellular Potts model).
  • modeling phenomena with significant uncertainty
    in inputs, such as the calculation of risk in
    business.
  • Mathematics e.g. evaluation of definite
    integrals
  • Monte Carlo methods tend to be used when it is
    infeasible or impossible to compute an exact
    result with a deterministic algorithm (that is,
    intractable problems ).
  • Monte Carlo Algorithm is a randomized algorithm
    that may produce incorrect results, but with
    bounded error probability.

3
Applications of Monte Carlo
  • Radiation transport Operations research
  • Nuclear criticality Design of nuclear reactors
  • Design of nuclear weapons Statistical physics
  • Phase transitions Wetting and growth of thin
    films
  • Atomic wave functions and eigenvalues
  • Intranuclear cascade reactions Thermodynamic
    properties
  • Long chain coiling polymers Reaction kinetics
  • Partial differential equations Large sets of
    linear equations
  • Numerical integration Uncertainty analysis
  • Development of statistical tests Cell population
    studies
  • Combinatorial problems Search and optimization
  • Signal detection WarGames

4
Example 1 - Monte Carlo Integration to Estimate Pi
  • A simple example to illustrate Monte Carlo
    principals
  • Accelerate convergence using variance reduction
    techniques
  • Use if expectation values
  • Importance sampling
  • Adapt to a parallel environment

5
Monte Carlo Estimate of Pi
6
Serial Monte Carlo Algoritm for Pi
  • Read N
  • Set SumG 0.0
  • Do While i lt N
  • Pick two random numbers xi and yi
  • If (xixi yiyi 1)
  • then SumG SumG 1
  • Endif
  • Enddo
  • Gbar SumG / N
  • SigGbar Sqrt(Gbar - Gbar2)
  • Print N, Gbar, SigGbar

7
Parallelization of Monte Carlo Integration
  • If message passing time is negligible
  • For same run time, error decreases by factor of
    Sqrt(p)
  • For same accuracy, run time improves by a factor
    of p
  • Should use same random number generator on each
    node (easy for homogeneous architecture)

8
Monte Carlo Estimates of Pi
  • Number of Batch CPU Standard True
  • Processors Size Time(sec) Deviation Error
  • --------------------------------------------------
    ------
  • 1 100,000 0.625 0.005 0.0018
  • 2 50,000 0.25 0.005 0.0037
  • 4 25,000 0.81 0.005 0.0061
  • --------------------------------------------------
    ------

9
Monte Carlo Estimates of Pi
  • 1. Creating the random number generators
  • for ( int i0 i lt num_dimension i) //
    create r.n. generator
  • // the seeds are different for the processors
  • seed (myRank 1) 100 i 10 1
  • if ( seed 0 )
  • randi new RandomStream(RANDOMIZE)
  • else
  • randi new RandomStream( seed )

10
Monte Carlo Estimates of Pi
  • 2. Each processors will run num_random / numProcs
    random walks
  • for ( imyRank i lt num_random inumProcs )
    // N random walks
  • 2a. Generating random numbers
  • for ( int i10 i1 lt num_dimension i1)
  • rani1 randi1- gt next()
  • 2b. Calculating for integration
  • if ( inBoundary( ran, num_dimension ) )
  • myPi f( ran, num_dimension ) pdf( ran,
    num_dimension )
  • count

11
Monte Carlo Estimates of Pi
  • 3. Calculating Pi from each processor
  • myPi 4 myPi / num_random
  • MPI_Reduce(myPi, pi, 1, MPI_DOUBLE, MPI_SUM,
    0, MPI_COMM_WORLD)
  • 4. Output the results and standard deviation,
    sigma
  • if (myRank 0)
  • cout ltlt "pi is " ltlt pi ltlt " sigma " ltlt 4
    sqrt( (pi/4 - (pi/4)(pi/4)) / num_random) ltlt "
    Error " ltlt abs(pi - PI25DT) ltlt endl

12
End
  • Thank you!
Write a Comment
User Comments (0)
About PowerShow.com