Abstract
Branch mispredictions is an important factor affecting the running time in practice. In this paper we consider tradeoffs between the number of branch mispredictions and the number of comparisons for sorting algorithms in the comparison model. We prove that a sorting algorithm using O(dn log n) comparisons performs Ω(n log d n) branch mispredictions. We show that Multiway MergeSort achieves this tradeoff by adopting a multiway merger with a low number of branch mispredictions. For adaptive sorting algorithms we similarly obtain that an algorithm performing O(dn(1 + log(1 + Inv/n))) comparisons must perform Ω(n log d (1 + Inv/n)) branch mispredictions, where Inv is the number of inversions in the input. This tradeoff can be achieved by GenericSort by Estivill-Castro and Wood by adopting a multiway division protocol and a multiway merging algorithm with a low number of branch mispredictions.
Chapter PDF
References
Brodal, G.S., Fagerberg, R., Moruz, G.: Cache-aware and cache-oblivious adaptive sorting. In: Proc. 32nd International Colloquium on Automata, Languages, and Programming. LNCS, Springer, Heidelberg (2005)
Brodal, G.S., Fagerberg, R., Moruz, G.: On the adaptiveness of quicksort. In: Proc. 7th Workshop on Algorithm Engineering and Experiments. SIAM, Philadelphia (2005)
Colin, A., Puaut, I.: Worst case execution time for a processor with branch prediction. Real-Time Systems, Special issue on worst-case execution time analysis 18(2), 249–274 (2000)
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 2nd edn. MIT Press, Cambridge (2001)
Estivill-Castro, V., Wood, D.: Practical adaptive sorting. In: Dehne, F., Fiala, F., Koczkodaj, W.W. (eds.) ICCI 1991. LNCS, vol. 497, pp. 47–54. Springer, Heidelberg (1991)
Estivill-Castro, V., Wood, D.: A survey of adaptive sorting algorithms. ACM Computing Surverys 24(4), 441–475 (1992)
Floyd, R.W.: Algorithm 245: Treesort3. Communications of the ACM 7(12), 701 (1964)
Guibas, L.J., McCreight, E.M., Plass, M.F., Roberts, J.R.: A new representation of linear lists. In: Proc. 9th Ann. ACM Symposium on Theory of Computing, pp. 49–60 (1977)
Hennesy, J.L., Patterson, D.A.: Computer Architecture: A Quantitative Approach. Morgan Kaufmann, San Francisco (1996)
Levcopoulos, C., Petersson, O.: Splitsort – an adaptive sorting algorithm. Information Processing Letters 39(1), 205–211 (1991)
Li, X., Mitra, T., Roychoudhury, A.: Modeling control speculation for timing analysis. Real-Time Systems Journal 29(1) (January 2005)
Manilla, H.: Measures of presortedness and optimal sorting algorithms. IEEE Trans. Comput. 34, 318–325 (1985)
McFarling, S.: Combining branch predictors. Technical report, Western Research Laboratory (1993)
Mehlhorn, K.: Data structures and algorithms. Sorting and searching, vol. 1. Springer, Heidelberg (1984)
Sanders, P., Winkel, S.: Super scalar sample sort. In: Albers, S., Radzik, T. (eds.) ESA 2004. LNCS, vol. 3221, pp. 784–796. Springer, Heidelberg (2004)
Williams, J.W.J.: Algorithm 232: Heapsort. Communications of the ACM 7(6), 347–348 (1964)
Yeh, Y.-Y., Patt, Y.N.: Alternative implementations of two-level adaptive branch prediction. In: ACM International Symposium on Computer Architecture, ISCA (1992)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Brodal, G.S., Moruz, G. (2005). Tradeoffs Between Branch Mispredictions and Comparisons for Sorting Algorithms. In: Dehne, F., López-Ortiz, A., Sack, JR. (eds) Algorithms and Data Structures. WADS 2005. Lecture Notes in Computer Science, vol 3608. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11534273_34
Download citation
DOI: https://doi.org/10.1007/11534273_34
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-28101-6
Online ISBN: 978-3-540-31711-1
eBook Packages: Computer ScienceComputer Science (R0)