CS 336: Final Project

Final: Tying it all together

In this project, you will be comparing the performance of sequential, p-threads, GPU, and MPI versions of the fish-schooling project. You will also determine how the school size affects the dependence of polarization on r (i.e. does a smaller r cause a polarized school when the school is small?)

  1. Get your fish-schooling code working with MPI. This essentially means turning certain main programs (e.g. sim_stats_nr) into programs using MPI. Not much else needs to change from the sequential version. The Makefile needs to use mpicc as the compiler and you need to remember to run your program with mpirun. I would concentrate on sim_stats_nr.c as the most important main program.
  2. Compare the performance of the four methods (sequential, p-threads, GPU, and MPI) on the fish-schooling simulations. What are the advantages and drawbacks of each? (e.g. limitations on space, speed)? Feel free to talk about the limitations in terms of the hardward we used for this course (e.g. the p-threads version might be the best, except that it allows us to use only 8 processors at a time, whereas other versions allow more). Be sure to back up your statements with data (i.e. don't just say one method is faster - tell me how much faster it). Include a focussed analysis on the performance when the fish school size is 100. Write this up in a document which includes figures and tables (it is up to you to determine which figures and tables you need, but I suggest that one of those tables be a clear comparison of run-times across the four methods). It will probably be helpful to compare performance by comparing the time-per-processor instead of just the overall time. For the GPU, consider the time per multi-processor (there are 7). Please put your graphs and tables in your write-up (that means you should use Word or something like it).
  3. Push your MPI version one step further. Use it to determine at which r the polarization first hits 0.7 (let's call that r-threshold) for a given radius of attraction. I would like to see a graph with r-threshold on the y-axis and the radius of attraction on the x-axis. You may use a fish school size of 100, if you would like. I would look at attraction radii between 3 and 10 (the default value is 7), though it is hard to discern a threshhold for 3 (so maybe give me a range?). It is up to you how to design this code.


Automate your search for r-threshold for each value of the radius of attraction. This is an optimization problem. However, deterministic, local search algorithms won't work, because the function isn't smooth enough. I suggest you make it as smooth as you can by using the same starting configuration for each ocean. Then evaluate it at lots of values of r. Take the lowest value of r for which the polarity is 0.7 (after 3000 steps of simulation). Call it r-threshold.

Writeup and Handin

To hand in your project, you will gather all of the necessary files into a final directory.

  1. Create a file named README.docx for your project write-up. Include a description of the process you used to determine that your code produces correct results. Also include the analysis outlined earlier. The more thorough the analysis, the higher your grade will be.
  2. You should hand in all code necessary to run your solutions. Place all necessary .h, .c, and Makefile files in the final directory. Stephanie will probably want to compile and run the code. It should be possible to do so without looking for any more files. Zip up the directory and mail it to Stephanie.