1 / 9

Batcher’s merging network

Batcher’s merging network. Efficient Parallel Algorithms COMP308. Odd-even merging network . We assume that n is exact power of 2, and we wish to merge the sorted sequence of elements on lines <a 1 ,..,a n > with those on lines <a n+1 ,..,a 2n >

kin
Download Presentation

Batcher’s merging network

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Batcher’s merging network Efficient Parallel Algorithms COMP308

  2. Odd-even merging network • We assume that n is exact power of 2, and we wish to merge the sorted sequence of elements on lines <a1,..,an> with those on lines <an+1,..,a2n> • We recursively construct two odd-even merging networks that merge sorted subsequences in parallel.

  3. Structure of the network • The first merges the sequence on lines <a1, a3,..,an-1> with sequences on lines <an+1, an+2,..,a2n-1> (the odd elements) • The second merges the sequence on lines <a2, a4,..,an> with sequences on lines <an+2, an+4,..,a2n> (the even elements) • To combine two sorted subsequences, we put a comparator between a2i-1 and a2i for all i=1,2,…,n

  4. 8-input network 1 2 3 4 5 6

  5. Skeleton of the Proof • Apply the zero-one principle to prove that Batcher’s sorting is correct, consideronly merges of sequences of the form 0000011111 and 00001111111 • In odd-even merging we send odd sequence to one merger and the even sequence to another merger. We can assume by induction that smaller mergers work correctly. • The first merger can get one or two more zeros. than the second one. The outputs of these mergers are interleaved and can be 1 before 0 (dirty one).

  6. After sorting separately on odd and even positions we will have everything sorted unless the situation like this happens 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 • Then the last final touch (correction step) cleans the sequence. • The situation is subtle, the last correction does not clean for example 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 • But the dirty 1 (if there is any) should be on an even position, which is always the case

More Related