Funnelsort
Funnelsort is a comparison-based sorting algorithm. It is similar to mergesort, but it is a cache-oblivious algorithm, designed for a setting where the number of elements to sort is too large to fit in a cache where operations are done. It was introduced by Matteo Frigo, Charles Leiserson, Harald Prokop, and Sridhar Ramachandran in 1999 in the context of the cache oblivious model. Source: e01 Encyclopedia. Licence: CC BY-SA 4.0.
Funnelsort is a comparison-based sorting algorithm. It is similar to mergesort, but it is a cache-oblivious algorithm, designed for a setting where the number of elements to sort is too large to fit in a cache where operations are done. It was introduced by Matteo Frigo, Charles Leiserson, Harald Prokop, and Sridhar Ramachandran in 1999 in the context of the cache oblivious model. In the external memory model, the number of memory transfers it needs to perform a sort of N items on a machine with cache of size Z and cache lines of length L is O \left(\tfrac{N}{L} \log_{Z} N \right) , under the tall cache assumption that Z = \Omega(L^2) . This number of memory transfers has been shown to be asymptotically optimal for comparison sorts. Funnelsort also achieves the asymptotically optimal runtime complexity of \Theta(N \log N) . The first important bound is that a k-merger can be fit in O(k^2) space. To see this, we let S(k) denote the space needed for a k-merger. To fit the k^{1/2} buffers of size 2k^{3/2} takes O(k^2) space. To fit the \sqrt{k} + 1 smaller buffers takes (\sqrt{k} + 1) S(\sqrt{k}) space. Thus, the space satisfies the recurrence S(k) = (\sqrt{k} + 1) S(\sqrt{k}) + O(k^2) . This recurrence has solution S(k) = O(k^2) . It follows that there is a positive constant \alpha such that a problem of size at most \alpha \sqrt{Z} fits entirely in cache, meaning that it incurs no additional cache misses. Letting Q_M(k) denote the number of cache misses incurred by a call to a k-merger, one can show that Q_M(k) = O((k^3 \log_Z k)/L). This is done by an induction argument. It has k \le \alpha \sqrt{Z} as a base case. For larger k, we can bound the number of times a \sqrt{k} -merger is called. The output merger is called exactly k^{3/2} times. The total number of calls on input mergers is at most k^{3/2} + 2\sqrt{k} . This gives a total bound of 2 k^{3/2} + 2 \sqrt{k} recursive calls. In addition, the algorithm checks every buffer to see if needs to be filled. This is done on \sqrt{k} buffers every step for k^{3/2} steps, leading to a max of k^2 cache misses for all the checks. This leads to the recurrence Q_M(k) \le (2k^{3/2} + 2 \sqrt{k}) Q_M(\sqrt{k}) + k^2 , which can be shown to have the solution given above. Finally, the total cache misses Q(N) for the entire sort can be analyzed. It satisfies the recurrence Q(N) = N^{1/3} Q(N^{2/3}) + Q_M(N^{1/3}). This can be shown to have solution Q(N) = O((N/L) \log_Z N).
Cite this
"Funnelsort". 1789398369. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1374885893 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy