Lean programs, branch mispredictions, and sorting

Amr Ahmed Abd Elmoneim Elmasry, Jyrki Katajainen

6 Citationer (Scopus)

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.

OriginalsprogEngelsk
TitelFun with Algorithms : 6th International Conference, FUN 2012, Venice, Italy, June 4-6, 2012. Proceedings
RedaktørerEvangelos Kranakis, Danny Krizanc, Flaminia Luccio
Antal sider12
ForlagSpringer
Publikationsdato2012
Sider119-130
ISBN (Trykt)978-3-642-30346-3
ISBN (Elektronisk)978-3-642-30347-0
DOI
StatusUdgivet - 2012
BegivenhedThe Sixth International conference on Fun with Algorithms - Venice, Italien
Varighed: 4 jun. 20126 jun. 2012
Konferencens nummer: 6

Konference

KonferenceThe Sixth International conference on Fun with Algorithms
Nummer6
Land/OmrådeItalien
ByVenice
Periode04/06/201206/06/2012
NavnLecture notes in computer science
Vol/bind7288
ISSN0302-9743

Fingeraftryk

Dyk ned i forskningsemnerne om 'Lean programs, branch mispredictions, and sorting'. Sammen danner de et unikt fingeraftryk.

Citationsformater