YCP Logo Assignment 4: Parallel Quick Sort

Due: Friday, Apr 15th by 11:59 PM

Getting Started

Download CS365_Assign4.zip. Import it into your Eclipse workspace (File->Import...->General->Existing projects into workspace->Archive File). You will see a project called CS365_Assign4 in the Package Explorer.

Your Task

You have two tasks:

Implement parallel quick sort

Your task is to implement a parallel version of quick sort using the Java fork/join framework. The parallelQuickSort static method in the Sort class should use your parallel quick sort implementation to sort the int array passed as its parameter.

You can use the parallel merge sort implementation in Lecture 18 as a starting point.

You can use the SortTest JUnit class to test your implementation.

Benchmark

Benchmark your parallel quick sort implementation using 1, 2, and 4 work pool threads (CPU cores). For each number of threads, measure the amount of time needed to support increasing array sizes: I suggest starting at 4,000,000 elements and going up to 20,000,000 elements.

Use the cluster head node to run your benchmark. Export your Eclipse project to a zip file and copy it to your account on the head node. Unzip it. Then, from the top-level directory of the project, run the command

ant

This will compile the program. To run the main method of the Benchmark class, run the command

(cd bin && java -classpath .:../jsr166y.jar edu.ycp.cs365.forkjoin.Benchmark)

Store your benchmark data in a spreadsheet, and create two plots:

  1. For each number of threads, the total amount of time needed to sort arrays of increasing size.
  2. For the 2 and 4 thread series, the speedup for the arrays of increasing size, where speedup is defined as ts / tp, where ts is the sequential (1 thread) time and tp is the parallel (2 or 4 thread) time.

See the notes for Lecture 18 for an idea of what the plots should look like.

Hints

Use the System.currentTimeMillis method to collect millisecond-resolution timestamps.

Before running the sorting algorithm in your benchmark, call System.gc() to minimize the chances that the garbage collector will run. However, make sure you do not include the call to System.gc() within the calls to System.currentTimeMillis() that measure the time required to sort the array.

Use Arrays.sort to sort a region of the array sequentially.

Grading

  • Correctness: 25
  • Task class: 20
  • Threshold selection: 10
  • Performance: 25
  • Benchmark data/plots: 20

Submitting

Make sure you include your spreadsheet in your Eclipse project!

Export your finished project to a zip file (right-click on the project, then Export...->Archive File). Upload the zip file to the marmoset server as project assign4. The server URL is

https://camel.ycp.edu:8443/

IMPORTANT: after uploading, you should download a copy of your submission and double-check it to make sure that it contains the correct files. You are responsible for making sure your submission is correct. You may receive a grade of 0 for an incorrectly submitted assignment.