Homework Two
Due : Tuesday November 10, 2009
Assignment:
- 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.
-
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,
-
Modify the code to run similar tests using dynamic and guided scheduling.
-
List the various run times and comment on the results.
Note: when timing the output remember not to print anything while timing.
- 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.
-
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,
-
List the various run times and comment on the results.
-
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