1 Sorting Networks. 2 10 9 4 3 2 1 8 7 9 4 3 2 1 8 7 Sorting.

Slides:



Advertisements
Similar presentations
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Advertisements

Parallel Sorting Sathish Vadhiyar. Sorting  Sorting n keys over p processors  Sort and move the keys to the appropriate processor so that every key.
Recursive Definitions and Structural Induction
Theory of Computing Lecture 3 MAS 714 Hartmut Klauck.
Batcher’s merging network Efficient Parallel Algorithms COMP308.
Induction and Recursion. Odd Powers Are Odd Fact: If m is odd and n is odd, then nm is odd. Proposition: for an odd number m, m k is odd for all non-negative.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
1 Tuesday, November 14, 2006 “UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 9 Tuesday, 11/20/01 Parallel Algorithms Chapters 28,
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
Lecture 6 Divide and Conquer for Nearest Neighbor Problem Shang-Hua Teng.
CS 584. Sorting n One of the most common operations n Definition: –Arrange an unordered collection of elements into a monotonically increasing or decreasing.
Sorting networks Efficient Parallel Algorithms COMP308.
Bitonic and Merging sorting networks Efficient Parallel Algorithms COMP308.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Sorting Networks Uri Zwick Tel Aviv University May 2015.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
Induction and recursion
Induction and recursion
Mathematical Maxims and Minims, 1988
Lecture 12: Parallel Sorting Shantanu Dutt ECE Dept. UIC.
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Parallel and Distributed Algorithms Eric Vidal Reference: R. Johnsonbaugh and M. Schaefer, Algorithms (International Edition) Pearson Education.
Lecture 6 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
The Selection Problem. 2 Median and Order Statistics In this section, we will study algorithms for finding the i th smallest element in a set of n elements.
Comparison Networks Sorting Sorting binary values
Chapter 5 With Question/Answer Animations. Section 5.1.
Data Stream Algorithms Ke Yi Hong Kong University of Science and Technology.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
Advanced Counting Techniques CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Self Stabilizing Smoothing and Counting Maurice Herlihy, Brown University Srikanta Tirthapura, Iowa State University.
Lecture 4 Sorting Networks. Comparator comparator.
1 Parallel Sorting Algorithm. 2 Bitonic Sequence A bitonic sequence is defined as a list with no more than one LOCAL MAXIMUM and no more than one LOCAL.
Comparison Networks Sorting Sorting binary values Sorting arbitrary numbers Implementing symmetric functions.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Counting and Distributed Coordination BASED ON CHAPTER 12 IN «THE ART OF MULTIPROCESSOR PROGRAMMING» LECTURE BY: SAMUEL AMAR.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
+ Even Odd Sort & Even-Odd Merge Sort Wolfie Herwald Pengfei Wang Rachel Celestine.
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.
ICDCS 05Adaptive Counting Networks Srikanta Tirthapura Elec. And Computer Engg. Iowa State University.
1 Discrete Mathematical Mathematical Induction ( الاستقراء الرياضي )
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Induction and Recursion CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
Recursive Algorithms Section 5.4.
Lecture 4 Sorting Networks
Sorting Networks Characteristics The basic unit: a comparator
Randomized Smoothing Networks
CS2210:0001Discrete Structures Induction and Recursion
SORTING NETWORKS.
Single Final State for NFA
Proving Properties of Recursive List Functions
Comparison Networks Sorting Sorting binary values
Bitonic and Merging sorting networks
Lecture 6 Algorithm Analysis
Applied Discrete Mathematics Week 9: Integer Properties
Lecture 6 Algorithm Analysis
Shared Counters and Parallelism
The Selection Problem.
Asynchronous token routing device
Depth of an AVL tree Theorem: Any AVL tree with n nodes has height less than log n. Proof: Given an n-node AVL tree, we want to find an upper bound.
Efficient Parallel Algorithms COMP308
Presentation transcript:

1 Sorting Networks

Sorting

3 Sorting Network (Bitonic Sorting Network)

4 Sorting Network (Bitonic Sorting Network)

5 Comparator x y max(x,y) min(x,y)

6 Comparator max min

7 Comparator max min

8

9 Levels 123 Depth = 3 Width = 4

Level 1

Level 2

Level 3

InputOutput

InputOutput

levels

17 Sort(n) Sort(n/2) Merge(n) In Out depth Recursive construction of Bitonic Sorting Network

18 Merge(n) Merge(n/2) depth Recursive construction of merging network

19 Induction Basis Sort(2) Merge(2)

20 Width Sorting network depth: Merger width Total depth

21 Counting Networks

22 The Counting Problem 0 Shared variable

23 0 Token = Increment request Shared variable

24 1 Increment request Shared variable 0

25 1 Shared variable

26 1 Increment request Shared variable

27 2 Shared variable 1 Increment request

28 2 Shared variable

29 2 Increment request Shared variable

30 3 Increment request Shared variable 2

31 6 Sequential Bottleneck Shared variable The requests have to be serialized

32 Counting Network Inputs Outputs

33 Counting Network

34 Balancer Inputs Outputs Token

35 Balancer Inputs Outputs

36 Balancer

37 Balancer

38 Balancer

39 Balancer

40 Balancer

41 Balancer

42 Balancer All tokens together

43 Balancer Step property

44 Balancer Step property Another example

45 Balancer Step property Another example

46 Balancer Step property Another example

47 Counting Network (Bitonic Counting Network)

48 Counting Network

49 Counting Network

50 Counting Network

51 Counting Network

52 Counting Network

53 Counting Network

54 Counting Network

55 Counting Network

56 Counting Network

57 Counting Network

58 Counting Network

59 Counting Network

60 Counting Network

61 Counting Network

62 Counting Network

63 Counting Network

64 Counting Network

65 Counting Network All tokens

66 Counting Network All tokensStep property

67 Counting Network Another example Step property

68 Counting Network Another example Step property

69 Counting Network Another example Step property

70 Counting Network Another example Step property

71 Counting Network Parallelism Many increment requests are processed simultaneously

72 Counting Token = Increment request Output Shared variables

73 Counting Output Shared variables

74 Counting Returned value Shared variable value is increased by 4 (output width)

75 Counting Increment request

76 Counting

77 Counting Returned value

78 Counting Increment request

79 Counting Returned value

80 Counting

81 Counting Returned value

82 Counting

83 Counting Returned value

84 Counting

85 Counting Returned value

86 Counting All tokens

87 Bitonic Counting Network Isomorphic to Bitonic Sorting Network

88 Count(n) Count(n/2) Merge(n) In Out depth

89 Merge(n) Merge1(n/2) Merge2(n/2) depth Step Prop. Step Prop. Step Prop.

90 Even subsequence Odd subsequence

91 Merge(n) Merge1(n/2) Merge2(n/2)

92 Theorem: Proof: The proof is by induction on For the merger is a balancer and the claim holds trivially. Induction Basis: The merger(n) produces output Z with step property if both inputs X and Y have step property

93 Induction Hypothesis: Merge(n/2) If step sequence Then step sequence Assume that every merger of size n/2 and smaller performs merging properly

94 Merge(n) Induction step: If step Then step We want to show that: Suppose and have the step property. Then we show that has the step property

95 If has the step property then and have the step property Tokens

96 Merge1(n/2) Merge2(n/2) step Therefore, from induction hypothesis: Output sequence

97 First, we show: Where denotes the total number of tokens in sequence

98 We have: Merger 1 Merger 2

99 or Since has the step property: Therefore: Similarly:

100

101 Now, we show that has the step property There is at most one wire where the two sequences differ #tokens step

102 Step property Merge1(n/2) Merge(n/2) Merge(n)