BlockQuicksort

Author:

Edelkamp Stefan1,Weiß Armin2ORCID

Affiliation:

1. King’s College London

2. Universität Stuttgart

Abstract

It is well known that Quicksort -- which is commonly considered as one of the fastest in-place sorting algorithms -- suffers in an essential way from branch mispredictions. We present a novel approach to addressing this problem by partially decoupling control from dataflow: in order to perform the partitioning, we split the input into blocks of constant size. Then, all elements in one block are compared with the pivot and the outcomes of the comparisons are stored in a buffer. In a second pass, the respective elements are rearranged. By doing so, we avoid conditional branches based on outcomes of comparisons (except for the final Insertionsort). Moreover, we prove that when sorting n elements, the average total number of branch mispredictions is at most ϵ n log n + O ( n ) for some small ϵ depending on the block size. Our experimental results are promising: when sorting random-integer data, we achieve an increase in speed (number of elements sorted per second) of more than 80% over the GCC implementation of Quicksort (C++ std::sort). Also, for many other types of data and non-random inputs, there is still a significant speedup over std::sort. Only in a few special cases, such as sorted or almost sorted inputs, can std::sort beat our implementation. Moreover, on random-input permutations, our implementation is even slightly faster than an implementation of the highly tuned Super Scalar Sample Sort, which uses a linear amount of additional space. Finally, we also apply our approach to Quickselect and obtain a speed-up of more than 100% over the GCC implementation (C++ std::nth_element).

Publisher

Association for Computing Machinery (ACM)

Subject

Theoretical Computer Science

Reference40 articles.

1. Engineering of a Quicksort partitioning algorithm;Abhyankar D.;Journal of Global Research in Computer Science,2011

2. Optimal Partitioning for Dual Pivot Quicksort

3. How Good Is Multi-Pivot Quicksort?

Cited by 12 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. Data-centric workloads with MPI_Sort;Journal of Parallel and Distributed Computing;2024-05

2. Optimizing the gravitational tree algorithm for many-core processors;Monthly Notices of the Royal Astronomical Society;2023-12-29

3. Billion-scale Detection of Isomorphic Nodes;2023 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW);2023-05

4. Parallel Multi-Deque Partition Dual-Deque Merge sorting algorithm using OpenMP;Scientific Reports;2023-04-19

5. These Rows Are Made for Sorting and That’s Just What We’ll Do;2023 IEEE 39th International Conference on Data Engineering (ICDE);2023-04

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3