7.1 What is a Sorting Network?

Slides:



Advertisements
Similar presentations
II Extreme Models Study the two extremes of parallel computation models: Abstract SM (PRAM); ignores implementation issues Concrete circuit model; incorporates.
Advertisements

Algorithms (and Datastructures) Lecture 3 MAS 714 part 2 Hartmut Klauck.
1 The 2-to-4 decoder is a block which decodes the 2-bit binary inputs and produces four output All but one outputs are zero One output corresponding to.
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Lecture 5: Linear Time Sorting Shang-Hua Teng. Sorting Input: Array A[1...n], of elements in arbitrary order; array size n Output: Array A[1...n] of the.
Lecture 5: Master Theorem and Linear Time Sorting
Sorting networks Efficient Parallel Algorithms COMP308.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
Midterm Review CS112 Fall Problem 1 You are a manager. You must implement some functionality. A number of your subordinates bring to you a number.
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Parallel and Distributed Algorithms Eric Vidal Reference: R. Johnsonbaugh and M. Schaefer, Algorithms (International Edition) Pearson Education.
Recurrence Relation. Outline  What is a recurrence relation ?  Solving linear recurrence relations  Divide-and-conquer algorithms and recurrence relations.
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Comparison Networks Sorting Sorting binary values
Complexity 20-1 Complexity Andrei Bulatov Parallel Arithmetic.
Recursion Algorithm : Design & Analysis [3]. In the last class… Asymptotic growth rate The Sets ,  and  Complexity Class An Example: Maximum Subsequence.
Lecture 4 Sorting Networks. Comparator comparator.
Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.
May 2015Sorting NetworksSlide 1 Sorting Networks A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar
Reducing number of operations: The joy of algebraic transformations CS498DHP Program Optimization.
Sorting Integers in the RAM Model Gerth Stølting Brodal Joint work with Djamal Belazzougui and Jesper Sindal Nielsen (to be presented at the 14th Scandinavian.
Unit-8 Sorting Algorithms Prepared By:-H.M.PATEL.
Sorting: Parallel Compare Exchange Operation A parallel compare-exchange operation. Processes P i and P j send their elements to each other. Process P.
May 2007Sorting NetworksSlide 1 Sorting Networks A Lecture in CE Freshman Seminar Series: Ten Puzzling Problems in Computer Engineering.
Lecture 3COMPSCI.220.S1.T Running Time: Estimation Rules Running time is proportional to the most significant term in T(n) Once a problem size.
MATH 224 – Discrete Mathematics
FLIP FLOPS Binary unit capable of storing one bit – 0 or 1
Lecture 4 Sorting Networks
Design and Analysis of Algorithms Chapter -2
Conditional-Sum Adders Parallel Prefix Network Adders
Sorting Networks Characteristics The basic unit: a comparator
The Steepest Ascent Hill Climbing Algorithm
Divide-and-Conquer 6/30/2018 9:16 AM
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Parallel Odd-Even Sort Algorithm Dr. Xiao.
Divide-and-Conquer Design
Analysis of Algorithms
SORTING NETWORKS.
Linear-Time Sorting Continued Medians and Order Statistics
Introduction to Algorithms
COSC160: Data Structures Linked Lists
CSCE 411 Design and Analysis of Algorithms
Quick-Sort 11/14/2018 2:17 PM Chapter 4: Sorting    7 9
(2,4) Trees 11/15/2018 9:25 AM Sorting Lower Bound Sorting Lower Bound.
Quick-Sort 11/19/ :46 AM Chapter 4: Sorting    7 9
The Complexity of Algorithms and the Lower Bounds of Problems
CSCE 411 Design and Analysis of Algorithms
Unsigned Multiplication
Heap Sort The idea: build a heap containing the elements to be sorted, then remove them in order. Let n be the size of the heap, and m be the number of.
(2,4) Trees 12/4/2018 1:20 PM Sorting Lower Bound Sorting Lower Bound.
Comparison Networks Sorting Sorting binary values
Divide-and-Conquer 7 2  9 4   2   4   7
8/04/2009 Many thanks to David Sun for some of the included slides!
13 Digital Logic Circuits.
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Multioperand Addition
Building block to sort two numbers
Lecture 6 Algorithm Analysis
Linear-Time Sorting Algorithms
Quick-Sort 2/23/2019 1:48 AM Chapter 4: Sorting    7 9
Sorting Networks A Lecture in CE Freshman Seminar Series:
Divide-and-Conquer 7 2  9 4   2   4   7
CSC 143 Binary Search Trees.
CPSC 411 Design and Analysis of Algorithms
David Kauchak cs161 Summer 2009
Divide-and-Conquer 7 2  9 4   2   4   7
CS200: Algorithm Analysis
Efficient Parallel Algorithms COMP308
Presentation transcript:

7.1 What is a Sorting Network? Fig. 7.1 An n-input sorting network or an n-sorter. Fig. 7.2 Block diagram and four different schematic representations for a 2-sorter. Fall 2008 Parallel Processing, Extreme Models

Building Blocks for Sorting Networks 2-sorter Implementation with bit-parallel inputs Implementation with bit-serial inputs Fig. 7.3 Parallel and bit-serial hardware realizations of a 2-sorter. Fall 2008 Parallel Processing, Extreme Models

Proving a Sorting Network Correct Fig. 7.4 Block diagram and schematic representation of a 4-sorter. Method 1: Exhaustive test – Try all n! possible input orders Method 2: Ad hoc proof – for the example above, note that y0 is smallest, y3 is largest, and the last comparator sorts the other two outputs Method 3: Use the zero-one principle – A comparison-based sorting algorithm is correct iff it correctly sorts all 0-1 sequences (2n tests) Fall 2008 Parallel Processing, Extreme Models

Elaboration on the Zero-One Principle Deriving a 0-1 sequence that is not correctly sorted, given an arbitrary sequence that is not correctly sorted. Let outputs yi and yi+1 be out of order, that is yi > yi+1 Replace inputs that are strictly less than yi with 0s and all others with 1s The resulting 0-1 sequence will not be correctly sorted either Fall 2008 Parallel Processing, Extreme Models

7.2 Figures of Merit for Sorting Networks Cost: Number of comparators In the following example, we have 5 comparators The following 4-sorter has 3 comparator levels on its critical path Delay: Number of levels Cost  Delay The cost-delay product for this example is 15 Fig. 7.4 Block diagram and schematic representation of a 4-sorter. Fall 2008 Parallel Processing, Extreme Models

Cost as a Figure of Merit Fig. 7.5 Some low-cost sorting networks. Fall 2008 Parallel Processing, Extreme Models

Delay as a Figure of Merit These 3 comparators constitute one level Fig. 7.6 Some fast sorting networks. Fall 2008 Parallel Processing, Extreme Models

Cost-Delay Product as a Figure of Merit Fast 10-sorter from Fig. 7.6 Low-cost 10-sorter from Fig. 7.5 Cost  Delay = 29  9 = 261 Cost  Delay = 31  7 = 217 The most cost-effective n-sorter may be neither the fastest design, nor the lowest-cost design Fall 2008 Parallel Processing, Extreme Models

7.3 Design of Sorting Networks C(n) = n(n – 1)/2 D(n ) = n Cost  Delay = n2(n – 1)/2 = Q(n3) Fig. 7.7 Brick-wall 6-sorter based on odd–even transposition. Fall 2008 Parallel Processing, Extreme Models

Insertion Sort and Selection Sort C(n) = n(n – 1)/2 D(n ) = 2n – 3 Cost  Delay = Q(n3) Fig. 7.8 Sorting network based on insertion sort or selection sort. Fall 2008 Parallel Processing, Extreme Models

Theoretically Optimal Sorting Networks O(log n) depth O(n log n) size Note that even for these optimal networks, delay-cost product is suboptimal; but this is the best we can do Existing sorting networks have O(log2 n) latency and O(n log2 n) cost Given that log2 n is only 20 for n = 1 000 000, the latter are more practical AKS sorting network (Ajtai, Komlos, Szemeredi: 1983) Unfortunately, AKS networks are not practical owing to large (4-digit) constant factors involved; improvements since 1983 not enough Fall 2008 Parallel Processing, Extreme Models

Bitonic-Sequence Sorter 1 3 3 4 6 6 6 2 2 1 0 0 Rises, then falls 8 7 7 6 6 6 5 4 6 8 8 9 Falls, then rises 8 9 8 7 7 6 6 6 5 4 6 8 The previous sequence, right-rotated by 2 Fig. 14.2 Sorting a bitonic sequence on a linear array. Fall 2008 Parallel Processing, Extreme Models