Sorting using BItonic netwoRk wIth CUDA

Gabriele Capannini, Fabrizio Silvestri, Ranieri Baraglia, Franco Maria NardiniLSDS-IR @ SIGIR 2009

Abstract

Sorting is a fundamental bottleneck in large-scale Information Retrieval (IR) systems. This paper presents a high-performance sorting algorithm designed for GPUs using a bitonic sorting network implemented in CUDA. By optimizing memory access patterns and maximizing the use of on-chip shared memory through kernel fusion, the authors achieve significant speedups over traditional CPU-based sorting. The approach provides a more stable, data-independent alternative to existing GPU sorting methods, maintaining performance across diverse data distributions.

Introduction

In the indexing phase of web search engines, hundreds of gigabytes of data must be processed, making sorting a critical performance bottleneck. While modern GPUs offer massive parallel computing power, early attempts to leverage them for general-purpose tasks were often hindered by restrictive graphics APIs. The primary challenge lies in the "memory wall"—the performance gap caused by slow off-chip memory access. This work addresses these challenges by mapping a bitonic sorting algorithm to the SIMD (Single Instruction, Multiple Data) architecture of GPUs, specifically aiming to keep data on-chip as much as possible.

Methods: Bitonic Sorting and Kernel Fusion

The authors implement a Bitonic Sorting Network. Unlike data-dependent algorithms like Quicksort, a bitonic network uses a fixed, regular schema of comparisons. This regularity is ideally suited for the SIMD nature of GPUs, as it avoids "warp divergence" where threads in a group follow different execution paths.

Key technical contributions include:

  • Kernel Fusion: Instead of launching a new GPU kernel for every step of the sorting network, multiple steps are grouped into a single kernel. This allows the GPU to perform several rounds of comparisons while keeping data in the fast, 16KB on-chip shared memory.
  • Cache-Oblivious Modeling: The authors adapt the "ideal-cache model" to GPU architecture, treating shared memory as a cache line to minimize off-chip memory transfers.
  • Efficient Indexing: A bit-masking mechanism is introduced to calculate comparison pairs without complex branching.
Illustration of kernel fusion and shared memory utilization in the bitonic network.

Experimental Evaluation

The algorithm was evaluated using synthetic arrays of 32-bit integers across three distributions: Uniform, Gaussian (normal), and Zipfian (power-law). These distributions represent common data characteristics in natural language and web data. Performance was compared against a standard CPU-based Quicksort and a state-of-the-art GPU-Quicksort implementation.

Results and Discussion

The experimental results demonstrate that both GPU-based algorithms significantly outperform the CPU implementation as dataset size increases. The proposed bitonic sort was faster than the competing GPU-Quicksort for datasets up to 8 MB.

Performance comparison across Gaussian, Uniform, and Zipfian distributions showing the stability of the bitonic approach.

A key finding is the data independence of the bitonic network. While the performance of GPU-Quicksort varied and even failed to conclude for arrays larger than 16 MB, the bitonic network scaled successfully and showed much lower variance across different data distributions. This predictability makes it highly reliable for real-world IR tasks where data distributions are often unpredictable.

Conclusion and Future Work

While the bitonic network effectively addresses on-chip bottlenecks, the authors acknowledge that data transfer between the host (CPU) and device (GPU) remains a major overhead. Future work will focus on extending this algorithm to "tuple sorting" (key-value pairs), which is essential for building search engine postings lists, and refining performance models to better capture GPU transfer bandwidth nuances.

Summary updated

BibTeX
@inproceedings{capannini2009sorting,
  author = {Gabriele Capannini and Fabrizio Silvestri and Ranieri Baraglia and Franco Maria Nardini},
  title = {{Sorting using BItonic netwoRk wIth CUDA}},
  booktitle = {LSDS-IR @ SIGIR},
  year = {2009},
}
Figure