Homework Two

Due : Tuesday November 10, 2009

Assignment:

  1. Use OpenMP to parallelize the algorithm described in Programming with OpenMP for calculating pi by integration 4/1+x*x from 0 to 1 using 10,000,000 steps.
    1. Run the code sequentially and using OpenMP on 1, 2, 3, 4, and 8 threads and time the results, on both dune.midearth.cs.kent.edu and neptune.cs.kent.edu,
    2. Modify the code to run similar tests using dynamic and guided scheduling.
    3. List the various run times and comment on the results.

    Note: when timing the output remember not to print anything while timing.
  2. Write code to use the Monte Carlo method to compute pi, described in Programming with OpenMP, and parallelize it using OpenMP. Note that this will need to generate sequences of random numbers. Recall that any library calls you use must be thread safe, and that you must be careful to generate independent random sequences rather than the same ones in the different threads to maintain validity of the algorithm.
    1. Run the code sequentially and using OpenMP on 1, 2, 3, 4, and 8 threads on dune.midearth.cs.kent.edu and time the results,
    2. List the various run times and comment on the results.
  3. Integer sorting is a class of sorting where the keys are integers. The range of key values is often smaller that the number of keys, and in this case the sorting can be accomplished using an array of "buckets" in which to count keys.
    This link gives pseudo-code for a bucket sort code for sorting the array key into key2.
    Implement it in C and parallelize the code using OpenMP regions.

This assignment is an individual assignment, to be done on your own without help from other students in the class. However, you may use any materials from any written resource, including web resources.
Some hints on compiling, running and timing OpenMP programs are in hints.txt