My Linux Environment





A Simple Fast Parallel Sort Algorithm


Here is a source code tarball and screenshot for some code that explores parallel sorting of data leveraging a 2d grid data structure. The below screenshot shows a count of less than 12000 logically parallel steps to sort 16 million random numbers. This is significantly faster than I was expecting so decided to put this on the web in case anyone else wanted to play with it. More algorithm info is below.


This program also attempts to animate the data movement of the sort for clarity. The source code partitions the 16 million integers in a matrix configuration into 256 smaller matrices of 64K each, visible in the pane on the left. Each sub matrix is connected to its immediate neighbor to allow data to swap accross the sub matrix boundaries which is required for a global sort of all data. The pane on the right animates the data movement of the swapping occuring within the sub matrix selected in the left pane.


Each of the sub matrices can be processed independently and are sized arbitrarily. On my current computer I only have 8 hardware threads. The software allocates each of the sub matrices to one of the available real hardware threads. This algorithm can easily scale to thousands of CPU hardware threads when they become available. Performance on current computers is primarily gated by thread count.


This code uses the SDL graphics library and I have released this under the BSD0 license for maximum permissive reuse.


  • gridsort.tar.gz


  • The Algorithm



    Performance



    Next Steps



    Links


  • Google Parallel Computer Architecture