Sorting with GPUs: A Survey

Dmitri I. Arkhipov, Di Wu, Keqin Li, Amelia ReganarXiv 2017 · DOI

Abstract: Sorting is a fundamental operation in computer science and is a bottleneck in many important fields. Sorting is critical to database applications, online search and indexing, biomedical computing, and many other applications. The explosive growth in computational power and availability of GPU coprocessors has allowed sort operations on GPUs to be done much faster than any equivalently priced CPU. Current trends in GPU computing shows that this explosive growth in GPU capabilities is likely to continue for some time. As such, there is a need to develop algorithms to effectively harness the power of GPUs for crucial applications such as sorting.

Introduction

Sorting serves as the "glue" of modern computing, essential for everything from database indexing to complex biomedical simulations. As global data volumes continue to explode, traditional CPU-based sorting has increasingly become a major performance bottleneck. Graphics Processing Units (GPUs) offer a compelling alternative, providing thousands of cores designed for massive parallelism.

Trends in GPU performance and memory bandwidth (2000-2012).

As shown in the performance trends above, GPU compute capabilities (Gflops) have historically outpaced memory bandwidth growth. This disparity creates a unique challenge: while GPUs have the raw power to process data, they are primarily designed for Single Instruction, Multiple Data (SIMD) workloads. Sorting, by contrast, often requires complex "if-then" logic and irregular data movement, which can lead to "thread divergence" and significantly degraded performance.

The Memory Bottleneck and GPU Architecture

A central theme in GPU sorting research is the orchestration of data movement across the hardware's memory hierarchy. The efficiency of a sorting algorithm is rarely limited by raw compute cycles; instead, the primary enemies are the high latency and limited bandwidth of global memory (VRAM).

GPU hardware hierarchy including SMs, SPs, and memory layers.

To achieve high performance, algorithms must maximize the use of on-chip resources. As illustrated in the architecture diagram, each Streaming Multiprocessor (SM) contains fast, low-latency Shared Memory. The most successful sorting implementations are those that stay "on-chip" as long as possible, minimizing expensive trips to the DRAM. Furthermore, memory access must be "coalesced"—where groups of threads access contiguous blocks—to prevent performance drops of an order of magnitude.

Taxonomy of GPU Sorting Algorithms

Research over the last decade has categorized GPU sorting into several primary algorithmic families:

  • Sorting Networks: Algorithms such as Batcher’s Bitonic and Odd-Even Merge Sort are highly predictable and "hard-wired" in logic. These are ideal for small datasets where every thread performs the exact same comparison, avoiding branching penalties.
  • Non-Comparison Sorts: Radix Sort is often considered the "gold standard" for GPU performance. It decomposes numbers into digits and utilizes efficient hardware primitives like scan (prefix sum) and scatter to move data.
  • Comparison-Based Sorts: Adaptations of Quicksort and Merge Sort are necessary for complex data types like strings. While their recursive nature is difficult to map to SIMD architectures, modern implementations use warp-level synchronization to bypass slower shared memory.
  • Hybrid Approaches: The most advanced modern algorithms often use a Radix-style bucketization to partition data globally, followed by high-speed bitonic sorting within the local shared memory of each SM.

Key Insights and Results

The survey reveals that Radix Sort remains the speed champion for 32-bit integers, with optimized implementations consistently outperforming CPUs by 10x to 40x. The "winning recipe" for a high-performance GPU sort involves a combination of global partitioning and local sorting networks.

Beyond raw speed, the efficiency of these algorithms relies heavily on low-level hardware primitives. If primitives like 1-bit scatter or prefix sums are poorly implemented in the hardware or driver, the entire sorting pipeline suffers. Additionally, modern comparison sorts like Warpsort have found success by enabling synchronization-free communication between threads within a single warp (32 threads), further reducing latency.

Limitations and Future Outlook

Despite significant progress, several frontiers remain:

  • Variable-Length Data: Sorting strings or unaligned records remains difficult because it disrupts the neat memory alignment GPUs require.
  • Memory Contention: As core counts increase, "bank conflicts" (multiple threads hitting the same memory address) become more frequent.
  • Dynamic Parallelism: Newer architectures that allow for better inter-unit communication may finally make recursive algorithms like Quicksort truly efficient.
  • External Sorting: There is a growing need for "out-of-core" algorithms capable of sorting datasets larger than the GPU's onboard VRAM by streaming data directly from system memory or disk.

Summary updated

BibTeX
@misc{arkhipov2017sorting,
  author = {Dmitri I. Arkhipov and Di Wu and Keqin Li and Amelia Regan},
  title = {{Sorting with GPUs: A Survey}},
  year = {2017},
  eprint = {1709.02520},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1709.02520},
}
Figure