A Master For The Monte Carlo Integration


As usually there is more than one way to write the master program and we are going to use the following,

  1. Determine Configuration of virtual machine.
  2. Start as many different slave processes as there are physical machines.
  3. If slave is done collect result and check if there is another task to be calculated for this quadrant,
  4. Continue with step 3 until all tasks for all quadrant are done.
Again we will split up the work in small pieces as we want to keep the program as flexible as possible with respect to the configuration of the parallel machine. Let's say we want to check one million points, then we have to check 250000 points in each quadrant and we will assign 50000 points to each slave.

Explanation: To understand why we use this procedure for the master, think of a virtual machine consisting of two normal, one fast and one slow physical machine. We would give one quadrant to each machine and as soon as the fast machine is done it would help the slow machine finish its part while the other two machines continue their work on their quadrant.
This way we try to minimize the overhead connected with spawning new tasks.

The source code for this program in: C


Previous: Monte Carlo Integration - Parallel Easier Than Sequential
Next: Slaves For Monte Carlo Example
Index: Getting started with PVM