In this laboratory you'll experiment with an existing connected component labeling algorithm supplied to you, and enhance it to improve performance. You'll also conduct some parameter studies to understand the performance issues. For this assignment you'll run in single processor mode only. But as you enhance the code, keep in mind that you will parallelize the code in assignment #4.
Refer to the Leighton handout for reference.
A random number generator is included. Note the command line options, which are handled in the source file cmdLine.C. In particular, you can seed the random number generator with an arbitrary value, or you can use the time of day. The program outputs the seed so that you will be able to reproduce a given run.
The code considers points to be adjacent only if they are nearest neighbors on the Manhattan coordinate directions-- left, right, up, and down. This is different from the stencil used in the book, which includes corners. If you like, experiment with the 9-point stencil, but be sure to present results for the Manhattan stencil.
First determine, pc , the critical value of the independent probability p that maximizes the running time. It may be easier to pinpoint pc by looking at tabular data; sample p more closely in the neighborhood of criticality so you can determine pc to 3 decimal places. Include tabular data along with your report, and also plot the running time as a function of p.
Since the initial conditions are randomized you'll need to take steps to ensure that your timings are statistically significant. For each value of p, make several (5 to 10) runs each with a different random number seed. Plot the mean value with a curve, but also plot the maximum and minimum value for each value of p you measured. You should also repeat a few of your runs using the same random number seed, to see if your timings are consistent. To do this, use the -s flag to set the random number seed to the value reported by the reference run you wish to reproduce.
To determine an appropriate value of N, experiment by staring with N=100 and doubling N until the run completes in about 10 seconds at criticality. If you are using Valkyrie observe the following protocol, which may help improve the consistency of your results. If you see that others are on the machine, try to use a node that appears unoccupied. Stick with that node, and make all your timing runs from a single script. This way, if someone sees that the node is busy, they'll stay away for the duration of time that you are performing your runs.
Before you implement the depth first algorithm, attempt to improve the running time of the code provided. To save time, run for a few values of p, but be sure and include a few points in the neighborhood of criticality.
Next, use your code to determine some statistics about the cluster populations. Report the number of clusters as a function of the independent probability p, as well as the mean and standard deviation of cluster size. Generate these statistics for a few different values of N. Do you observe any trends as you vary N?
Your writeup should provide sample output demonstrating correct operation of your code (Note that the code provided will print out the clusters for smaller domains). It should also present a clear evaluation of the performance, including bottlenecks of the implementation, and describe any special coding or tuned parameters. What factors will limit performance as you increase N?
You should also turn in an electronic copy of your report and code.