Communications of the ACM
Communications of the ACM
The C Programming Language
A Meticulous Analysis of Mergesort Programs
CIAC '97 Proceedings of the Third Italian Conference on Algorithms and Complexity
An experimental study of sorting and branch prediction
Journal of Experimental Algorithmics (JEA)
Algorithms in c++, parts 1-4: fundamentals, data structure, sorting, searching, third edition
Algorithms in c++, parts 1-4: fundamentals, data structure, sorting, searching, third edition
Computer Organization and Design, Fourth Edition, Fourth Edition: The Hardware/Software Interface (The Morgan Kaufmann Series in Computer Architecture and Design)
Compilers: Principles, Techniques, & Tools with Gradiance
Compilers: Principles, Techniques, & Tools with Gradiance
Tradeoffs between branch mispredictions and comparisons for sorting algorithms
WADS'05 Proceedings of the 9th international conference on Algorithms and Data Structures
Branch mispredictions don't affect mergesort
SEA'12 Proceedings of the 11th international conference on Experimental Algorithms
Hi-index | 0.00 |
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.