FINDING BETTER SORTING NETWORKS a Dissertation Submitted to Kent State University in Partial Fulfillment of the Requirements
Total Page:16
File Type:pdf, Size:1020Kb
FINDING BETTER SORTING NETWORKS A dissertation submitted to Kent State University in partial fulfillment of the requirements for the degree of Doctor of Philosophy by Sherenaz W. Al-Haj Baddar May 2009 Dissertation written by Sherenaz W. Al-Haj Baddar B.S., University of Jordan, Jordan, 2001 M.S., University of Jordan, Jordan, 2003 Ph.D., Kent State University, 2009 Approved by Kenneth Batcher , Chair, Doctoral Dissertation Committee Johnie Baker , Members, Doctoral Dissertation Committee Hassan Peyravi _ Mark Lewis _ Jay Lee _ Accepted by Robert Walker , Chair, Department of Computer Science Timothy Moerland , Dean, College of Arts and Sciences i TABLE OF CONTENTS LIST OF FIGURES ........................................................................................................... VI LIST OF TABLES .............................................................................................................. IX DEDICATION ....................................................................................................................... X ACKNOWLEDGEMENTS ............................................................................................... XI CHAPTER 1 INTRODUCTION ......................................................................................... 1 1.1 Problem Statement ......................................................................................................... 1 1.2 Dissertation Organization .............................................................................................. 3 CHAPTER 2 BASIC CONCEPTS ...................................................................................... 4 2.1 Knuth Diagrams ............................................................................................................. 4 2.2 The Zero/One Principle. ................................................................................................ 5 2.3 Partial Ordering and Haase Diagrams........................................................................... 6 2.4 Poset Operations. ............................................................................................................ 7 2.4.1 Poset Arithmetic .................................................................................................. 7 2.4.2 Lattices ................................................................................................................. 9 2.4.3 Example: A 4-key Sorting Network ................................................................. 10 2.5 Bracket Cases. .............................................................................................................. 12 2.6 Preserving Information. ............................................................................................... 15 2.7 Renaming. ..................................................................................................................... 17 CHAPTER 3 PREVIOUS WORK .................................................................................... 19 3.1 Two Models for Parallel Algorithms .......................................................................... 19 ii 3.2 Bitonic Sorting ............................................................................................................. 21 3.3 Odd-Even Merge Sorting ............................................................................................. 22 3.4 The Van Voorhis Network for 16 Keys ...................................................................... 24 3.5 The AKS Networks ...................................................................................................... 25 3.6 Cole’s Parallel Merge Sort........................................................................................... 27 3.6.1 Definitions .......................................................................................................... 28 3.6.2 The Main Idea .................................................................................................... 29 3.6.3 The Phases of the Algorithm ............................................................................. 30 3.6.4 The Practicality of Cole’s Parallel Merge Sort ................................................ 31 3.7 The Best Sorting Networks for Input Sizes ≤ 32 ...................................................... 32 3.7.1 The most-efficient N-key Sorting networks for N ≤ 32................................... 33 3.7.2 The fastest N-key Sorting networks for N ≤ 32 ............................................... 35 CHAPTER 4 SORTNET..................................................................................................... 37 4.1 The Interface of Sortnet ............................................................................................... 37 4.2 Sortnet Commands for Manipulating CEs .................................................................. 38 4.3 Sortnet Commands for Manipulating Zero/One cases ............................................... 39 4.4 How Sortnet Works ...................................................................................................... 45 4.5 An Example-Treating a 32-Key Network................................................................... 47 CHAPTER 5 A THREE-PHASE TECHNIQUE FOR DESIGNING FASTER SORTING NETWORKS ........................................................................................ 49 5.1 Phase I: Designing a Single-segment Poset ................................................................ 49 5.2 Phase II: Designing the Intermediate Steps ................................................................ 51 iii 5.3 Phase III: Finalizing the Network ............................................................................... 52 5.4 Remarks on the Three-phase Technique ..................................................................... 53 CHAPTER 6 AN 11-STEP NETWORK FOR SORTING 18 KEYS........................... 54 6.1 Phase I: Designing a Single-segment Poset in Steps 1 through 4 ............................. 55 6.2 Phase II: Generating a Shmoo Chart with a Staircase Pattern in Steps 5 through 9 .................................................................................................................... 55 6.3 Phase III: Finalizing the Network in Steps 10 and 11 .............................................. 57 6.4 An Illustrative Example ............................................................................................... 58 CHAPTER 7 A 12-STEP NETWORK FOR SORTING 22 KEYS.............................. 61 7.1 Phase I: Designing a Single-segment Poset in Steps 1 through 4 ............................. 62 7.2 Phase II: Generating a Shmoo Chart with a Staircase Pattern in Steps 5 through 9 .................................................................................................................... 62 7.3 Phase III: Finalizing the Network in Steps 10 through 12......................................... 64 CHAPTER 8 CONCLUSIONS AND FUTURE WORK ............................................... 66 8.1 Conclusions .................................................................................................................. 66 8.2 Future Work .................................................................................................................. 68 APPENDIX A PROOFS OF THEOREMS...................................................................... 69 A.1 Proof of Theorem 2-1................................................................................................... 69 A.2 Proof of Theorem 2-2................................................................................................... 70 A.3 Proof of Theorem 2-3................................................................................................... 70 REFERENCES ..................................................................................................................... 72 iv LIST OF FIGURES Figure 1.1. A compare-exchange element ............................................................................. 2 Figure 2.1. Three different ways for drawing a 4-key Sorting network .............................. 4 Figure 2.2. Haase diagrams tracking the sorting of 4 keys................................................... 7 Figure 2.3. The Boolean Lattice B ....................................................................................... 10 Figure 2.4. The key-poset U+U+U+U and the case-poset B(U+U+U+U) ............................... 11 Figure 2.5. The key-poset B+B and the case-poset B(B+B) .................................................. 11 Figure 2.6. The key-poset BB and the case-poset BBB ....................................................... 12 Figure 2.7. The chain of 4 keys and the corresponding chain of 5 zero/one cases ........... 12 Figure 2.8. Comparing c with d (Before and After)........................................................... 15 Figure 2.9. Comparing A with C and B with D (Before and After) ................................... 16 Figure 2.10. Preserving as much information as possible by comparing corresponding keys ................................................................................................................................. 17 Figure 2.11. The 16-key poset before renaming .................................................................. 18 Figure 3.1. Bitonic sorting of 4 keys.................................................................................... 22 Figure 3.2. The 8-key Odd-even merge Sorting network