There is a branch of Botany that is concerned with simulating vegetation patterns using computerized models. This has implications for anticipating the effect that climate change will have on vegetation. These models scale in computational complexity with the size of the input terrain, which in some cases can span entire continents. They are therefore prime candidates for acceleration using parallel programming.
One of the most important factors affecting a trees growth is its exposure to sunlight. In this assignment you will efficiently calculate the average sunlight received by trees in a forest (and also record the sunlight exposure of individual trees).
For the purposes of this assignment the landscape is represented by a regular matrix of floating point values. Each value represents the average hours of sunlight per day falling on a 1m x 1m area of the terrain. Not all areas receive the same amount of sunlight because of folds in the landscape (see below).
Figure 1: Average sun exposure during March for a 3km x 3km section of terrain in California. North facing slopes receive less sunlight (and are represented by a darker red in the colour map). South facing slopes tend to receive more sunlight (a bright red or orange in the colour map).
Tree canopies are represented (rather unrealistically) as a square coverage area on the terrain. For the forest you will be provided with the top left (x, y) terrain coordinate of a trees canopy indexed from (0,0) and the extent in meters (e).
Your task is to calculate both the total sunlight exposure for each tree canopy (the sum of the sunlight values within its canopy area) and the mean sunlight exposure for all trees.
The file input format is as follows:
<terrain x size INT> <terrain y size INT>
<avg. hours sunlight at (0,0) FLOAT> <avg. hours sunlight at (0, 1) FLOAT> <avg.
hours sunlight at (xsize-1, ysize-1) FLOAT>
<number of trees INT>
<x corner of tree 0 INT> <y corner of tree 0 INT> <canopy extent of tree 0 INT>
<x corner of tree (numtrees-1) INT> <y corner of tree (numtrees-1) INT> <canopy extent of tree (numtrees-1) INT>
For example, a very small 5m x 5m section of terrain, with 2 trees would be encoded in the input file as:
5 5
4.5 5.5 4 3.5 4 4.5 5 4.5 4 4 5 5 5.5 4.5 5 4 4.5 5 5 4 4 4 4.5 4 3.5
2
- 1 3
- 3 4
Visually this corresponds to:
Note that some trees may extend beyond the edge of the terrain (as is the case above for the light green tree) and these parts of the canopy should be ignored. Trees may also overlap, but for the purposes of this simulation they do not occlude each other.
The file output format is as follows:
<avg. sunlight per tree FLOAT>
<number of trees INT>
<total sunlight tree 0 FLOAT>
<total sunlight tree (numtrees-1) FLOAT>
For the example above this would mean an output of:
34.5
2
43
26
In this assignment you will attempt to parallelize the problem in order to speed it up. You will be required to:
- Use the Java Fork/Join framework to parallelize the sunlight exposure calculations using a divide-and-conquer algorithm.
- Evaluate your program experimentally:
- Using high-precision timing to evaluate the run times of your serial and your parallel method, across a range of input sizes, and
- Experimenting with different parameters to establish the limits at which sequential processing should begin.
- Write a report that lists and explains your findings.
Note that parallel programs need to be both correct and faster than the serial versions.
Therefore, you need to demonstrate both correctness and speedup for your assignment.
Assignment details and requirements
Your program will calculate the sunlight exposure of individual trees in parallel as well as the average sunlight exposure of all trees in the forest.
1.1 Input and Output
Your program must take the following command-line parameters:
<data file name> <output file name>
The format of these files must follow the specification provided above.
We will provide you with a sample input file (on Vula), though you may also create your own using random data.
1.2 Benchmarking
You must time the execution of your parallel sorts across a range of data sizes and number of threads (sequential cutoffs) and report the speedup relative to a serial implementation. The code should be tested on at least two different machine architectures (at least one of which must be a multi-CPU/multi-core machine).
Timing should be done at least 5 times. Use the System.currentTimeMillis method to do the measurements. Timing must be restricted to the sunlight exposure code and must exclude the time to read in the files and other unnecessary operations, as discussed in class. Call System.gc()to minimize the likelihood that the garbage collector will run during your execution (but do not call this within your timing block!).
1.3 Report
You must submit an assignment report in pdf format. Your clear and concise report should contain the following:
- An Introduction, comprising a short description of the aim of the project, the parallel algorithms and their expected speedup/performance.
- A Methods section, giving a description of your approach to the solution, with details on the parallelization. This section must explain how you validated your algorithm (showed that it was correct), as well as how you timed your algorithms with different input, how you measured speedup, the machine architectures you tested the code on and interesting problems/difficulties you encountered.
- A Results and Discussion section, demonstrating the effect of data sizes and numbers of threads and different architectures on parallel speedup. This section should include speedup graphs and a discussion. Graphs should be clear and labelled (title and axes). In the discussion, we expect you to address the following questions:
- Is it worth using parallelization (multithreading) to tackle this problem in Java?
- For what range of data set sizes does your parallel program perform well?
- What is the maximum speedup obtainable with your parallel approach? How close is this speedup to the ideal expected?
- What is an optimal sequential cutoff for this problem? (Note that the optimal sequential cutoff can vary based on dataset size and architecture.)
- What is the optimal number of threads on each architecture?
- A Conclusions (note the plural) section listing the conclusions that you have drawn from this project. What do your results tell you and how significant or reliable are they?
Please do NOT ask the lecturer for the recommended numbers of pages for this report. Say what you need to say: no more, no less.
Reviews
There are no reviews yet.