<!--#set var="root_directory" value="../../.." --><!--#include virtual="$root_directory/shared/header.shtml"-->
-<h1>Assignment #4</h1>
-<p><em>Due Friday, November 2, 2007</em></p>
+<h1>Assignment #5</h1>
+<p><em>Due Friday, October 30, 2009</em>
<h2>Purpose</h2>
-<p>To learn how to implement truly parallel algorithms.</p>
+<p>Learn how to implement a master-slave parallel algorithm.</p>
-<h2>Setup</h2>
+<p>Note: Please identify all your work.</p>
-<p>This assignment consists in implementing a Monte Carlo integral in
-parallel. The integral to perform is</p>
+<p>This assignment consists in rewriting the code performing the
+Monte-Carlo integral of the Gaussian function (see the web pages) in a
+master-slave algorithm.</p>
-<img width="224" height="39" align="middle" border="0"
- src="img/integral.png"
- alt="$ I = \int dx \int dy (x^2+y^2) e^{ - (x^2+y^2) } $" />
+<p>Write the code so that the process 0 should only administer the
+calculation (i.e., take charge of the interface with the user, decide
+on the # random steps to be taken by each slave node, and perform the
+final Monte-Carlo sums from the sub-sums). The slave processes,
+processes 1 to <code>size-1</code>, should <em>generate</em> the
+random walk steps <em>and</em> perform the Monte-Carlo sub-sums.</p>
-<p>This integral was coded in a parallel Master-Slave model in the
-course notes <a href="<!--#echo
-var="root_directory"-->/content/Monte_Carlo/index.html#Guided">Guided
-Monte Carlo Integral</a>.</p>
+<p>Make sure that your code:</p>
-<p>You are now to code this integral in a balanced model in which you
-will assign a pre-determined amount of work to each processor. In this
-model, all nodes will scan an equal amount of random Monte Carlo steps
-and perform local sums. Process 0 will wrap up the calculation,
-thereby producing a slight load unbalance.</p>
-
-<h2>To do</h2>
-
-<h3>Part A</h3>
-
-<p>Build the code to do the integral. Start from the
-program <a href="<!--#echo
-var="root_directory"-->/content/Monte_Carlo/codes/Metropolis_Gaussian_Integral.c">Metropolis_Gaussian_Integral.c</a>
-as a guide to what is to be done. Your code should have the same
-functionality as this skeleton serial code.</p>
-
-<p>Use a "stride" method to select which Monte Carlo steps to perform
-on each node. Namely, generate the entire sequence of steps on each
-nodes and use only the ones with a stride given by the rank of the
-process. For instance, on a 4 processes run, process 0 will use steps
-0, 4, 8, ...</p>
-
-<p>Use the programs <a href="<!--#echo
-var="root_directory"-->/content/Monte_Carlo/codes/Metropolis_Gaussian_Parallel.c">Metropolis_Gaussian_Parallel.c</a>
-and <a href="<!--#echo
-var="root_directory"-->/content/Monte_Carlo/codes/Metropolis_CS.c">Metropolis_CS.c</a>
-as examples of parallel codes for this problem.</p>
-
-<h3>Part B</h3>
-
-<p>The value of the integral should be independent of the initial
-position used in generating the random walk. To achieve this it is
-often suggested to <em>thermalize</em> the initial position of the
-random walk. This implies run the code over few (often hundreds or
-thousands) random steps <em>for nothing</em>, i.e., without
-accumulating statistics, before accumulating the sums to calculate the
-average of <i>f(x)</i> and its variance.</p>
-
-<p>Adapt your parallel code to perform this
-<em>thermalization</em> of the initial conditions. Your code
-should prompt the user for the number of <em>thermalization</em>
-steps (could be 0!).</p>
+<ul>
+ <li>agrees with the serial code.</li>
+ <li>handles an arbitrary number of nodes.</li>
+ <li>handles an arbitrary number of Monte-Carlo steps.</li>
+ <li>implements the logic of the refinement of the Monte-Carlo sums,
+ e.g., a calculation with two ranges of random steps, say 20,000
+ followed by 30,000, is equivalent to a single calculation with the
+ total # of steps, 50,000 for this case.</li>
+</ul>
<!--#include virtual="$root_directory/shared/footer.shtml"-->
--- /dev/null
+<!--#set var="root_directory" value="../../.." --><!--#include virtual="$root_directory/shared/header.shtml"-->
+
+<h1>Assignment #4</h1>
+<p><em>Due Friday, November 2, 2007</em></p>
+
+<h2>Purpose</h2>
+
+<p>To learn how to implement truly parallel algorithms.</p>
+
+<h2>Setup</h2>
+
+<p>This assignment consists in implementing a Monte Carlo integral in
+parallel. The integral to perform is</p>
+
+<img width="224" height="39" align="middle" border="0"
+ src="img/integral.png"
+ alt="$ I = \int dx \int dy (x^2+y^2) e^{ - (x^2+y^2) } $" />
+
+<p>This integral was coded in a parallel Master-Slave model in the
+course notes <a href="<!--#echo
+var="root_directory"-->/content/Monte_Carlo/index.html#Guided">Guided
+Monte Carlo Integral</a>.</p>
+
+<p>You are now to code this integral in a balanced model in which you
+will assign a pre-determined amount of work to each processor. In this
+model, all nodes will scan an equal amount of random Monte Carlo steps
+and perform local sums. Process 0 will wrap up the calculation,
+thereby producing a slight load unbalance.</p>
+
+<h2>To do</h2>
+
+<h3>Part A</h3>
+
+<p>Build the code to do the integral. Start from the
+program <a href="<!--#echo
+var="root_directory"-->/content/Monte_Carlo/codes/Metropolis_Gaussian_Integral.c">Metropolis_Gaussian_Integral.c</a>
+as a guide to what is to be done. Your code should have the same
+functionality as this skeleton serial code.</p>
+
+<p>Use a "stride" method to select which Monte Carlo steps to perform
+on each node. Namely, generate the entire sequence of steps on each
+nodes and use only the ones with a stride given by the rank of the
+process. For instance, on a 4 processes run, process 0 will use steps
+0, 4, 8, ...</p>
+
+<p>Use the programs <a href="<!--#echo
+var="root_directory"-->/content/Monte_Carlo/codes/Metropolis_Gaussian_Parallel.c">Metropolis_Gaussian_Parallel.c</a>
+and <a href="<!--#echo
+var="root_directory"-->/content/Monte_Carlo/codes/Metropolis_CS.c">Metropolis_CS.c</a>
+as examples of parallel codes for this problem.</p>
+
+<h3>Part B</h3>
+
+<p>The value of the integral should be independent of the initial
+position used in generating the random walk. To achieve this it is
+often suggested to <em>thermalize</em> the initial position of the
+random walk. This implies run the code over few (often hundreds or
+thousands) random steps <em>for nothing</em>, i.e., without
+accumulating statistics, before accumulating the sums to calculate the
+average of <i>f(x)</i> and its variance.</p>
+
+<p>Adapt your parallel code to perform this
+<em>thermalization</em> of the initial conditions. Your code
+should prompt the user for the number of <em>thermalization</em>
+steps (could be 0!).</p>
+
+<!--#include virtual="$root_directory/shared/footer.shtml"-->