Assignment 3/4
Shared-memory and cluster parallelism:
- Assignment 3: implement a shared memory version of the program below
- Assignment 4: implement a clustered version running on two or
more machines.
- Collect performance data across problem sizes.
- 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
degrees
Celsius and the bottom right corner (index [width - 1,height - 1]) is
heated at
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
where
represents each of the three base metals,
is the thermal constant for metal
,
is the set
representing the neighbouring regions,
is the temperature of
the neighbouring region,
is the percentage of metal
in
neighbour
, and
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
,
,
,
,
, the dimensions of the mesh, and the threshold should be parameters to the
program. Note however, that many values of
,
,
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.