CS475 Fall 2008 - Homework 2

Parallel Program for Sieve of Eratosthenes


Objectives

The objective of this homework is to start with a straightforward parallel implementation and progressively tune it and measure the performance gains as you go along. You will consider three specific optimizations, viz., (i) avoiding communication (almost) completely by duplicating the work of determining of the primes up to sqrt(n) on each processor; (ii) then improving the sequential part through tiling; and (iii) allocating memory for only the odd numbers. These programs are cumulative, each version building on the other. This is a long homework, so please get started early.

Problem Statement

For this homework, you will need to write analyze and report on three programs (all derived from a single, common starting point that is provided here). This program uses the memory allocation/data distribution strategy discussed in class (and also allocates two extra chars of memory to make the indexing logic simpler (the index into the array IS the integer that the location represents: marked[i] represents the status of i.
  1. Your first program should be (nearly) communication-free. Each processor should independently first compute all the primes up to sqrt(n), and then use these primes to mark off their share of the array of n integers. It will need to allocate a local auxiliary array to store these primes.
  2. Your second program should include the previous optimization and also reorder the loops on each processor for improved locality. You should experiment with the block size, b, and report how/why you chose the one you did.
  3. Your third program should further optimize this by allocating memory for only odd numbers. Hypothesize about the improvement you can get from the modification, and your experimental data should study if/how the hypothesis is validated.
You may use LAM MPI on the linux machines for the initial design, development and debugging of the programs. Your performance measurements for the comparisons should be done on bassi at NERSC.

Your code should conform to the following:

What/When/How to Submit:

Good luck and have fun!