SeqRankSort.java
is a C-like sequential implementation of rank sort. Demonstrated with a sample reversed array of 10 integers.
ParallelRankSort.java
uses command line arguments for problem size and number of threads to use. It divides the array to be sorted into equal[1] blocks, which are then divided to each thread. The work of each thread is to calculate the position of each element in the (result
) array.
[1] In case of remainder Math.ceil
is invoked.
javac -Xdiags:verbose SeqRankSort.java
javac -Xdiags:verbose ParallelRankSort.java
Tested with Java 8.
java SeqRankSort
java ParallelRankSort 1000 4 true
ParallelRankSort
arguments:
1000
problem size, that is the number of elements of the array.4
problem size, that is the number of elements of the array.true
random boolean, true means random array elements while every other statement evaluates false.
Also available by running java ParallelRankSort
argument-less.
./run_parallel.sh
run_parallel
creates a results
directory and runs the parallel version for sample problem sizes and number of threads. It can be used as boilerplate for your own numbers for the arguments.
Code released under the MIT license.