| Date | Description |
| 10-Jan-16 | Original posting |
| 17-Jan-16 | Clarification about command line parameter settings (§ 3.3, items (5) and (6)) |
In this assignment you implement the Mandelbrot set computation discussed in class on multiple cores, starting from a provided serial starter code written in C++. Specifically, you'll use C++11 threads to parallelize the code and then conduct experiments, on the Bang cluster, to assess scalability and performance tradeoffs. In the spirit of friendly competition, post your performance results to the A1 Piazza Folder.
The assignment includes a brief report, and the requirements for your report are described at the end of this writeup.
☞ Due Friday 1/22/16 @ 9PM‣ ‣ ‣ Required solution file: pmdb.cpp
This means that the file that contains your solution to the assignment must be turned in by the deadline. It's a good idea to plan to do the assignment well before the deadlines; terminals and tutors can get very busy at the last minute.
In doing this assignment, it's your responsibility to understand the course rules for integrity of scholarship.
You may develop your code anywhere, but you must ensure that it compiles and runs correctly on Bang, because that’s where we’ll be testing it.
All assignments will be turned in using UCSD's GitLab. The turnin procedure is described below in the section "Turning in your assignment". You must follow these steps to get the starter code and to get set up to do assignment 1.
Refer to the link below for instructions on how to obtain the starter code to get started on your assignment
A1 Git Instructions
You have been provided with starter code that implements the serial algorithm. The README file explains the options needed to run the code.
Look over the code so you are familiar with the various modules. The code contains the serial variant which you will use to check correctness of your multithreaded code. This serial variant, in smdb.cpp, calls a low level routine that performs the Mandelbrot set iteration:
ComputeMandelbrotPoint(int x, int y, int dimX, int dimY)
To lessen the risk of error, we recommend that your multithreaded code invokes this same routine to perform the Mandelbrot set computation.
All of your changes will be made to just one file, pmdb.cpp which defines the entry point to a function called Mandelbrot_multiThreaded() that you will implement along with a thread function.
To ensure that your program is correctly graded, do not rely on any changes you have made to any other provided source code files; we will substitute fresh copies when we grade your assignment. Also, don't change the signature of functions defined in pmdb.cpp, as certain provided routines make callbacks to them. It's OK to make changes to provided files besides pmdb.cpp when developing your code, but be sure and refresh them with the provided version before you collect your measurements.
To build your code, use the provided Makefile, as it sets up the appropriate flags for the compiler via an included "arch" file located in $(PUB)/Arch/arch.gnu-c++11.generic. The Makefile produces a target called mdb. Do not change the name of this target. You may add additional source files if you wish, but don't change the names of the any of the provided files.
You may override certain settings, such as compiler optimization, by redefining macros in your Makefile. Within the Makefile, we have provided a commented out line that, if uncommented, will redefine the optimization level. This may come in handy if you want to debug your code using gdb. But don't forget to comment this line out when collecting your timings our your code will run more slowly with optimization turned off!
To compile for debugging with gdb, specify the following argument on the Make command line: dbg=1, i.e.
make dbg=1
Don't forget to do a make clean before rebuilding the code. Otherwise, you may observe anomalous behavior.
The code has various capabilities, which are controlled via command line flags:
-i [number of maximum iterations to compute the Mandelbrot set. Default value: 200] -t [number of threads] -c [chunkSize] -s Run the the provided serial variant instead of the parallel one [default] -x [number of points to compute in the real dimension. Default value: 1024] -y [number of points to compute in the imaginary dimension Default value: 1024] -b [bounding box for the computation. Default extent: [-2.5 : 1, -1 : 1] -p Plot the results with gnuplot, without saving to a png file -v Compare the results of the parallel version with the serial version, enabling you to verify code correctness -o Generate a png file of the computation [output image file name]
For example,
./mdb -i 500 -t 8 -x 512 -y 512 -b -2.0 0.8 -0.5 0.5 -c 32 -o "output"
would compute the Mandelbrot set with 8 threads and a maximum of 500 iterations on a computational grid of size 512 x 512. The bounding box's real dimension range from -2.0 to 0.8, the imaginary dimension from -0.5 to 0.5. The -c parameter specifies that block cyclic partitioning is used with a chunkSize of 32. If (-c) is not specified, BLOCK partitioning is used. The results will be plotted and saved in the image file "output.png" which may be viewed with an image previewer. (Note that the color scheme when outputting to a file is different when using on-line plot mode)
./mdb -s -p
The plotting capability, controlled via the -p flag, uses gnuplot, and may be useful in debugging. It runs on the main thread only and is not multithreaded. You will need to ensure that your code preserves this constraint or unpredictable results may result. The plotter (Plotting.cpp) interfaces with gnuplot, which is free-ware.
To work remotely, you'll need to use the "tunneling" capability of ssh. If you are connecting to bang from a Linux or Darwin platform using ssh, use the -X option:
% ssh -X yourlogin@ccom-bang-login.ucsd.edu
Remote visual display can be slow if you are off campus. If a display window does not appear on your screen, then your ssh display settings are not set correctly.
Any plots you make will persist unless you close the plot window. This behavior comes in handy if you are comparing plots with different command line parameter settings. However, if you attempt to exit from a qlogin (interactive) node without closing all the plot windows, the process will hang until you close all those windows.
We will grade your assignment on bang. Be sure to do your final testing on that machine, to avoid any surprises at turnin time. When grading your assignment, we will substitute all the files that we asked you not to modify (as noted above) with the original copies of the version we provided you. This is why it is important that you do not depend on change you made to those files, as they will not be available during grading. We strongly suggest you perform some basic testing immediately prior to turnin.
We will test your code's correctness and performance. We will test against the public input described here, plus other inputs that will not be made public. Be sure to test against various combinations of the -x -y, -t and -c command line parameters. You need not handle the case where the number of threads doesn't divide the -y parameter and similarly with the -c chunkSize option.
You can catch obvious errors using the graphical output, but use the -s option to compare results exactly. Only an exact test can be guaranteed to verify correctness; the human eye is subjective, and the visual output may not have sufficient resolution to resolve subtle errors. Verify that results are independent of the number of threads.
Use the batch queue on Bang to collect timings.
Instructions for setting up your environment on Bang and for submitting jobs are described HERE.You may run interactively (see instructions provided in the Bang document). But you may find it more convenient to collect your measurements by running non-interactively. As a courtesy to other users, exit the interactive session when you longer need it.
Take timings with the provided timer code (it uses gettimeofday()). Take at least 3 timings for each combination of parameters, and report the minimum timing.
You'll notice that at the end of the run, you'll get a line of output like one of the following , which lists the maximum number of iterations (500), the plotting window (512x512), the running time (0.678493 seconds), whether we are running serially or with multiple threads (S or P), whether we are using BLOCK or BLOCK_CYCLIC decomposition and the bounding box for the computation.
@ 500 512 512 0.678493 S -1.000000 0.800000 -0.500000 0.250000 @ 500 512 512 0.678493 P 4 B -1.000000 0.800000 -0.500000 0.250000 @ 500 512 512 0.678493 P 4 C 32 -1.000000 0.800000 -0.500000 0.250000
The first line is for a serial run, the second for a parallel run on 4 threads with BLOCK decomposition, and the third run is on 4 threads with Cyclic decomposition and a chunk size of 32.
If you are doing several runs, you can quickly search for the string "@ " (starting in column 1) to extract the performance data from your job output files and process it for plotting (likely with a script). Feel free to post your favorite scripts for extracting and plotting data and organizing your runs.
Do not enable plotting (-p) when you are measuring running times for your performance studies, nor output the result to a file using the -o option as doing so could affect your observations.
gcc version 4.8.4 (GCC)
This setting results in a more highly imbalanced workload than the default settings of -b, and will enable you to see a much greater improvement with BLOCK_CYCLIC partitioning than with BLOCK.-x 512 -y 512 -i 10 -b -2.500000 -0.750000 0.000000 1.000000-x 128 -y 128 -i 100 -b -2.500000 -0.750000 0.000000 1.000000
-b -2.5 -0.75 0 1
Run on 2, 4 and 8 cores, with c=1. Compare this with BLOCK decomposition (using the same -b setting), putting the observed running times in a table or plot. Explain your results and compare the trends you observed with the previous experiment (6). To understand the phenomenon that your are observing, you will need to visualize your Mandelbrot sets using the -p or -o option (-p gives an interactive feel, whereas -o is faster but requires that you preview the .png file).
When you have completed the assignment, you must submit it. You will do this by pushing your changes to GitLab. Follow these steps (which are more or less the same as the steps from the "pushing changes to GitLab" section above:
Some of the finer points about this process:
A1-report-baden-powell.pdf
or, if working alone: A1-report-baden.pdf.
You may provide data in tabular form only. If you provide a plot, you must still provide the tabular data as sometimes plots can be hard to read. Be sure to provide a caption for each plot or table that describes the experiment you conducted, e.g. "strong scaling."
Plot your data carefully, plotting only what's necessary to get your points across, and choosing log and linear plots carefully. You must also include any plotted data in tabular form.
Cite any written works or software as appropriate in the text of the report. Citations should include any software you used that was written by someone else, or that was written by you for purposes other than this class.
Your turnin must also include two important documents that accompany the provided code: teameval.txt and DECLARATION.
These documents are required and we will not report a grade for your assignment without them. Be sure to fill in the documents correctly and completely. A 10% penalty will be assessed in cases of missing forms, empty forms, or forms not properly filled out.
There are 25 possible points on the assignment and your grade will depend on 4 factors: performance attained by your code, correctness, well-displayed results and comments. You must not only put comments inside your code, but every time you commit to your repository. There should be a steady stream of comments that enable us to retrace your development steps.
We will grade your code (on bang) using our own Makefile. Our Makefile will compile your code using g++ and and then link it with a test driver. We will use the same compilation flags as in the provided starter code. Our test driver expects your Mandelbrot_multiThreaded function to satisfy the interface specifications as found in the starter code. To get full credit, design, style and comments (including gitlab commit comments) count.
Don't wait until the last minute to attempt a turnin for the first time. Try out the turnin process early on so you are sure that you you are familiar with the process, and that all the required additional files are present.
You will receive 0 points for this assignment if your code does not compile, including cases of non-compilation due to merge conflicts. If you developed your code on another machine you are responsible for properly testing on bang, else you may lose significant credit, possibly all 25 points depending on the circumstances. As mentioned previously, you must ensure that you resolve all of your merge conflicts and that your code compiles and runs correctly IMMEDIATELY BEFORE you push to GitLab.
For this assignment staff will attempt intervene manually to fix problems. However, the policy for such manual intervention is as follows. If any manual intervention is required by staff you will lose at least 2 points. Included are: incorrectly naming your GitLab repository, or misspelling the words FINAL SUBMISSION in the commit message. Lastly, the only files you should be pushing to GitLab are text files: source code and ASCII test files. Do not push large binaries such as the executables or media files, as doing so could lead to problems such as losing the ability to push to GitLab. Staff will not intervene under these circumstances and you you may be unable to complete your assignment by the deadline. If you commit binaries, you are doing so at your own risk.
A. The batch system won't let you submit a batch job form a qlogin node. If you think about the constraint that a user can run either 1 batch job or 1 interactive login node at a time, you'll see why this makes sense. Your batch job wouldn't run until you logged out of the qlogin node.
[Fri Jan 22 11:07:41 PST 2016]