CS250 Project 5: Parallel Processing

Due Wednesday, May 11, at 12:00 PM (noon)

Parallel processing is required to fully utilize most modern CPUs. This assignment is intended to give you some practical experience in parallel programming. A program is supplied which calculates the sum of a large list, using only one thread, and displays the amount of time required. Your task is to modify this program so that it can take advantage of multiple cores. Isoptera is available for testing, with 24 real cores (48 apparent cores, due to hyperthreading). However, you can do this assignment on any multi-core computer, including any of the lab computers in MLH.
The program is called p5start.c, and comes with a Makefile. You can download it here. You don't have to use the Makefile, but if you decide to use it, here's how:
  1. Place the Makefile in the same directory as p5start.c
  2. At the command line, type "make".
  3. If make is installed, and so are all the libraries required, the project will build. If not, you will have to install make, required libraries, or both. isoptera and the lab computers are already set up correctly.
Test to see how much improvement is gained by parallel processing. In addition to the source code of your completed program, include a brief report showing the amount of time required for different numbers of processors, and the answers to the following questions:
  1. Does parallel processing speed up processing of short lists? Try a length of 1000 items.
  2. Why do you think a single processor is more than half as fast as two processors?


The pthreads library is not covered at all in the book. The manpages cover the individual functions, and "man pthreads" will provide a summary, but this may not be the most accessible documentation. Here are a couple suggestions:
Complete, but maybe more details than you need: https://computing.llnl.gov/tutorials/pthreads/
Fairly detailed, again more details than you need: http://randu.org/tutorials/threads/
C tutorial, which might answer language questions: http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html