
Spring ’09: CS415/515 Advanced Parallel Programming 5/21/09
Prof.
Ji
ngke
Li(F
AB
120-06,
[email protected]);
Classes:
TTh
noon-1:50pm
@
F
AB150;
Office
Hours:
TTh
10-11am.
Programming Project #4
(Due Thursday, 6/04/09 @ noon, — Firm Deadline!)
This project is to implement a sorting algorithm and to collect and analyze timing data from its execution.
Description
Your task is to implement a sorting algorithm to sort integer data from an input file into an ascending order
and write to an output file. You have freedom in choosing the algorithm and the platform.
•Algorithm — You may choose any parallel sorting algorithm to implement. If you choose a fine-
grained algorithm, such as parallel bubble sort or odd-even transposition sort, you need to develop a
reasonably good coarse-grained version of it.
•Platform — You may choose to implement your algorithm either on a shared-memory platform or
on a message-passing platform. If you choose the shared-memory platform, you need to implement the
algorithm with both Pthreads and OpenMP, and compare the performances of the two versions. If you
chose the message-passing platform, you only need to implement one MPI version.
•Program — Regardless of your platform choices, the sorting program should be implemented in the
SPMD style. It should take two command-line arguments, i.e. the names of the input and output files,
respectively. The program should reads data from the input file; sort it into an ascending order; and
writes the result to the output file.
•Data File Format — The data to be sorted are four-byte unsigned integers. Both the input and
output files are byte files of the same format: The very first four bytes of an input/output file consists
of an unsigned long integer value representing the number of records in the file. After these four bytes,
records are simply laid out one after another.
•I/O Handling — With all the three tools, Pthreads, OpenMP, and MPI, individual thread/host is
capable of performing file I/O. Therefore, I’ll leave the choices of I/O handling to you. You may decide
to have a single thread/host do the I/O, or you may decide to let everyone do their part. Some of
the considerations are: How to minimize memory buffer size? How to guarantee data ordering in the
output file?
•Timing — Insert timing routines in your program to collect timing data. For MPI programs, use
MPI Wtime() routine; for Pthread/OpenMP programs, use Unix’s gettimeofday() routine. We are
interested in measuring two versions of total elapsed time: (a) one that includes everything, and (b)
one that excludes I/0. Find the right points to insert the timing routine calls for these measurements.
•Execution — Your program should work correctly with any number of threads (or hosts), including
the case of just one thread, and any size of of data file. The workload among the threads need to be
roughly balanced.
•Performance Study — Run your program with different input data sizes, including at least 10,000,
50,000, and 100,000 record cases. For each data size, try the program with different number of
hosts/threads, including at least, 1, 2, 4, and 8.
•Report — Write a summary report covering the following topics:
–The algorithm — What algorithm did you implement? Why did you choose this algorithm?
1