A Memory Bandwidth-Efficient Hybrid Radix Sort on GPUs

Elias Stehle, Hans-Arno Jacobsen

Abstract

Sorting is a foundational operation for high-performance databases, yet it remains notoriously difficult to scale on GPUs due to memory bandwidth bottlenecks. This paper introduces a hybrid Most-Significant-Digit (MSD) radix sort that significantly reduces global memory traffic. By combining global partitioning with on-chip "local sorts" and optimized shared-memory atomics, the proposed algorithm achieves a 2.32x speedup over state-of-the-art libraries like CUB. Furthermore, a pipelined heterogeneous approach enables the sorting of datasets up to 64 GB, far exceeding the physical memory limits of the GPU.

Introduction

Traditional GPU sorting implementations primarily rely on Least-Significant-Digit (LSD) radix sort. While LSD sort is highly parallelizable, its requirement for stability necessitates multiple passes over the entire dataset in global memory—up to 39 passes for 64-bit keys. Each pass incurs significant read/write overhead, making the process memory bandwidth bound. Conversely, Most-Significant-Digit (MSD) sorts can reduce the number of passes but often suffer from load imbalance and the management overhead of millions of small buckets. This work addresses these challenges by shifting to a hybrid MSD strategy that minimizes global memory interaction.

Methodology

Hybrid MSD Partitioning and Local Sorting

The core of the proposed method is a multi-stage partitioning strategy. The algorithm processes 8 bits per pass (rather than the typical 4 or 5), reducing the total number of global memory transfers by approximately 1.6x. A critical innovation is the "Local Sort" Threshold ($\hat{\partial}$). When a partition becomes small enough to fit within the GPU's on-chip shared memory, global partitioning ceases. The remaining sorting passes are performed entirely on-chip, ensuring that data is read from and written to global memory only once for the final stages of the sort.

Optimized Histogramming

To mitigate contention during the histogramming phase—especially in the presence of data skew—the authors implement a "thread reduction & atomics" technique. Threads first aggregate small runs of keys in registers before performing atomic updates to shared memory counters. This approach maintains high memory bandwidth utilization even when the distribution of keys is highly concentrated.

Memory bandwidth utilization comparison between standard atomics and the proposed thread reduction technique.

Pipelined Heterogeneous Sorting

To handle datasets larger than the GPU's VRAM (up to 64 GB), the system employs a pipelined architecture. The data is divided into chunks, and PCIe transfers (Host-to-Device and Device-to-Host) are overlapped with the GPU's sorting execution. This "in-place replacement" strategy treats the GPU as a high-speed stream processor, where the CPU handles the final merging of sorted runs.

Pipelined execution model overlapping PCIe transfers with GPU sorting tasks.

Evaluation and Key Results

The hybrid sort was evaluated against synthetic uniform and skewed distributions (Zipfian $\theta = 0.75$).

  • Performance: The implementation achieved a 2.32x improvement over the CUB library for uniform distributions and at least 1.66x for highly skewed data.
  • Throughput: Peak performance exceeded 1 billion 32-bit keys per second, sorting 2 GB of 64-bit keys in just 50 milliseconds.
  • Scalability: For a 64 GB dataset, the heterogeneous pipeline outperformed PARADIS (a state-of-the-art multi-threaded CPU sort) by 2.06x.

Discussion and Conclusion

By abandoning the stability requirement of LSD sorts, the authors were able to leverage fast hardware atomics and on-chip memory more effectively. The "local sort" strategy effectively "lifts" the memory bandwidth limitation for the tail end of the sorting process. While the approach introduces a small memory overhead (approx. 5%) for bucket metadata and faces a potential CPU merging bottleneck at very large scales, it represents a significant step forward in GPU-accelerated data processing. Future work will focus on optimizing the CPU-side merge to keep pace with the increasing throughput of modern GPUs.

Summary updated

BibTeX
@inproceedings{stehle2017memory,
  author = {Elias Stehle and Hans-Arno Jacobsen},
  title = {{A Memory Bandwidth-Efficient Hybrid Radix Sort on GPUs}},
  booktitle = {SIGMOD},
  year = {2017},
  doi = {10.1145/3035918.3064043},
}
Figure