Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 Sorting Networks. 2 10 9 4 3 2 1 8 7 9 4 3 2 1 8 7 Sorting."— Presentation transcript:

1 1 Sorting Networks

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

3 3 Sorting Network (Bitonic Sorting Network)

4 4 Sorting Network (Bitonic Sorting Network)

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

6 6 Comparator max min 1 9 9 1

7 7 Comparator max min 100 4 4

8 8

9 9 Levels 123 Depth = 3 Width = 4

10 10 1 8 2 5

11 11 1 8 2 5 Level 1

12 12 1 8 2 5 Level 2

13 13 1 8 2 5 Level 3

14 14 1 8 2 5 1 8 2 5 InputOutput

15 15 10 9 4 3 2 1 8 7 9 4 3 2 1 8 7 InputOutput

16 16 10 9 4 3 2 1 8 7 9 4 3 2 1 8 7 1 2 3 456 levels

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

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

19 19 Induction Basis Sort(2) Merge(2)

20 20 Width Sorting network depth: Merger width Total depth

21 21 Counting Networks

22 22 The Counting Problem 0 Shared variable

23 23 0 Token = Increment request Shared variable

24 24 1 Increment request Shared variable 0

25 25 1 Shared variable

26 26 1 Increment request Shared variable

27 27 2 Shared variable 1 Increment request

28 28 2 Shared variable

29 29 2 Increment request Shared variable

30 30 3 Increment request Shared variable 2

31 31 6 Sequential Bottleneck Shared variable The requests have to be serialized 0 1 2 3 4 5

32 32 Counting Network Inputs Outputs

33 33 Counting Network

34 34 Balancer Inputs Outputs Token

35 35 Balancer Inputs Outputs

36 36 Balancer

37 37 Balancer

38 38 Balancer

39 39 Balancer

40 40 Balancer

41 41 Balancer

42 42 Balancer All tokens together

43 43 Balancer Step property

44 44 Balancer Step property Another example

45 45 Balancer Step property Another example

46 46 Balancer Step property Another example

47 47 Counting Network (Bitonic Counting Network)

48 48 Counting Network

49 49 Counting Network

50 50 Counting Network

51 51 Counting Network

52 52 Counting Network

53 53 Counting Network

54 54 Counting Network

55 55 Counting Network

56 56 Counting Network

57 57 Counting Network

58 58 Counting Network

59 59 Counting Network

60 60 Counting Network

61 61 Counting Network

62 62 Counting Network

63 63 Counting Network

64 64 Counting Network

65 65 Counting Network All tokens

66 66 Counting Network All tokensStep property

67 67 Counting Network Another example Step property

68 68 Counting Network Another example Step property

69 69 Counting Network Another example Step property

70 70 Counting Network Another example Step property

71 71 Counting Network Parallelism Many increment requests are processed simultaneously

72 72 Counting 0 1 2 3 Token = Increment request Output Shared variables

73 73 Counting 0 1 2 3 Output Shared variables

74 74 Counting 4 1 2 3 0 Returned value Shared variable value is increased by 4 (output width)

75 75 Counting 4 1 2 3 0 Increment request

76 76 Counting 4 1 2 3 0

77 77 Counting 4 5 2 3 0 1 Returned value

78 78 Counting 4 5 2 3 0 1 Increment request

79 79 Counting 4 5 6 3 0 1 2 Returned value

80 80 Counting 4 5 6 3 0 1 2

81 81 Counting 4 5 6 7 0 1 2 3 Returned value

82 82 Counting 4 5 6 7 0 1 2 3

83 83 Counting 8 5 6 7 0 1 2 3 4 Returned value

84 84 Counting 8 5 6 7 0 1 2 3 4

85 85 Counting 8 9 6 7 0 1 2 3 4 5 Returned value

86 86 Counting 8 9 6 7 0 1 2 3 4 5 All tokens

87 87 Bitonic Counting Network Isomorphic to Bitonic Sorting Network

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

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

90 90 Even subsequence Odd subsequence

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

92 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 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 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 95 If has the step property then and have the step property Tokens

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

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

98 98 We have: Merger 1 Merger 2

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

100 100

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

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


Download ppt "1 Sorting Networks. 2 10 9 4 3 2 1 8 7 9 4 3 2 1 8 7 Sorting."

Similar presentations


Ads by Google