Assignment 3/4

Shared-memory and cluster parallelism:
  1. Assignment 3: implement a shared memory version of the program below
  2. Assignment 4: implement a clustered version running on two or more machines.
  3. Collect performance data across problem sizes.
  4. Plot your results as a set of graphs and place on a web page.

The program

Consider a rectangular piece of alloy, twice as wide as high, consisting of three different metals, each with different thermal characteristics. For each region of the alloy, there is a fixed amount (expressed in terms of a percentage) of each of the three base metals. The top left corner (at the mesh element at index [0,0]) is heated at $S$ degrees Celsius and the bottom right corner (index [width - 1,height - 1]) is heated at $T$ degrees Celsius. The temperature at these points is constant and does not change.

Your assignment is to calculate the final temperature for each region on the piece of alloy. The new temperature for a given region of the alloy is calculated using the formula

\begin{displaymath}temp = \sum_{m = 1}^{3} C_m * \left(\sum_{n \in N} temp_n *
p^{m}_{n}\right) / \vert N\vert\end{displaymath}

where $m$ represents each of the three base metals, $C_m$ is the thermal constant for metal $m$, $N$ is the set representing the neighbouring regions, $temp_n$ is the temperature of the neighbouring region, $p^{m}_{n}$ is the percentage of metal $m$ in neighbour $n$, and $\vert N\vert$ is the number of neighbouring regions. This computation must be repeated until the temperatures converge to a final value or a reasonable maximum number of iterations is reached.

Your program should use either a cyclic-barrier/mesh or fork/join computation tree design. Use as many threads as CPUs, on two different multiprocessors.

The values for $S$, $T$, $C_1$, $C_2$, $C_3$, the dimensions of the mesh, and the threshold should be parameters to the program. Note however, that many values of $C_1$, $C_2$, $C_3$ do not converge well. Use values of 1.0 for all three for your final test/demo.

Use long values, not floating point for thermal quantities, where Long.MAX_VALUE represents the maximum supported temperature. This will require some adaptation and thought about scaling.

The percentage of each metal in the alloy at each region can be the output of a random number generator.

Your program should graphically display the results by drawing a grid of points with intensities or colors indicating temperature. (Alternatively, you can just output them to a file and use something like gnuplot to display them.)

Acknowledgment: This assignment was adapted from a study by Steve MacDonald.