Lean programs, branch mispredictions, and sorting

7Citations
Citations of this article
10Readers
Mendeley users who have this article in their library.
Get full text

Abstract

According to a folk theorem, every program can be transformed into a program that produces the same output and only has one loop. We generalize this to a form where the resulting program has one loop and no other branches than the one associated with the loop control. For this branch, branch prediction is easy even for a static branch predictor. If the original program is of length κ, measured in the number of assembly-language instructions, and runs in t(n) time for an input of size n, the transformed program is of length O(κ) and runs in O(κt(n)) time. Normally sorting programs are short, but still κ may be too large for practical purposes. Therefore, we provide more efficient hand-tailored heapsort and mergesort programs. Our programs retain most features of the original programs-e.g. they perform the same number of element comparisons-and they induce O(1) branch mispredictions. On computers where branch mispredictions were expensive, some of our programs were, for integer data and small instances, faster than the counterparts in the GNU implementation of the C++ standard library. © 2012 Springer-Verlag Berlin Heidelberg.

Cite

CITATION STYLE

APA

Elmasry, A., & Katajainen, J. (2012). Lean programs, branch mispredictions, and sorting. In Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) (Vol. 7288 LNCS, pp. 119–130). https://doi.org/10.1007/978-3-642-30347-0_14

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free