Re:Hoare’s Rebuttal and Bubble Sort’s Comeback
by frankmcsherry on Sunday May 31, 2020 @08:43AM
(#23369206)
Thanks for the interesting post! I liked the MergeDouble approach which I hadn’t seen before. Couldn’t that be extended to finding the median of the results using binary search and then doing four concurrent merges, for even more ILP?
[ Parent
| on HN ]
Re:Hoare’s Rebuttal and Bubble Sort’s Comeback
by gerbenst on Sunday May 31, 2020 @11:35AM
(#23370191)
Yes that is very much possible. In general you won't get 4 equal length ranges though. For instance in an already sorted array the median results in (n/2,0) and a (0,n/2) division. But the average case should be two sets of merge intervals both of size (n/4, n/4). In reality I think you will quickly run into other limits. You need quite a bit of registers, that shouldn't spill to stack.
Re:Hoare’s Rebuttal and Bubble Sort’s Comeback
by frankmcsherry on Sunday May 31, 2020 @12:04PM
(#23370403)
I think the median of the results works great in any case (but, you are the expert here). If we find the result median in each of the two inputs, say 'a' and 'b' we have four merges (two forward, two reverse):
[0, ..) w (0, ..)
(.., a) w (.., b)
[a, ..) w [b, ..)
(.., n) w (.., n)
each of which should produce n/4 elements and then meet.If the array is already sorted then great; that split will just "merge":
[0, ..) w nothing
(.., n/2) w nothing
nothing w [n/2, ..)
nothing w (.., n)
which should go very fast. Anyhow, possible I'm missing something!