Home Knowledge Base Parallel Sorting Algorithms

Parallel Sorting Algorithms are the fundamental computational primitives that order N elements in O(N log N / P) time on P processors — where GPU-optimized sorts (radix sort, merge sort, bitonic sort) achieve throughputs of billions of keys per second by exploiting massive parallelism, coalesced memory access, and shared-memory-based local sorting to provide the ordered data that indexing, searching, database queries, and computational geometry require.

GPU Radix Sort — The Throughput Champion

Radix sort processes one digit (k bits) at a time from least significant to most significant: 1. Local Histogram: Each thread block computes a histogram of k-bit digit values for its tile of data. k=4 bits → 16 buckets. 2. Prefix Sum (Scan): Global scan of histograms computes output offsets for each digit bucket across all blocks. 3. Scatter: Each element is written to its computed output position based on its digit value and the prefix sum offset. 4. Repeat: For 32-bit keys with 4-bit digits: 8 passes. Each pass is O(N) — total is O(N × 32/k).

GPU radix sort achieves 5-10 billion 32-bit keys/second on modern GPUs (H100). CUB and Thrust provide highly optimized implementations.

Merge Sort — The Comparison-Based Champion

For arbitrary comparison functions (not just integers): 1. Block-Level Sort: Each thread block sorts its tile (1024-4096 elements) using sorting networks or insertion sort in shared memory. 2. Multi-Way Merge: Progressively merge sorted tiles into larger sorted sequences. GPU-optimized merge uses binary search to partition the merge task equally across threads — each thread determines which elements from the two input sequences belong to its output range. 3. Complexity: O(N log²N / P) for simple parallel merge; O(N log N / P) with optimal merge partitioning.

Bitonic Sort — The Network Sort

A comparison-based sorting network with fixed comparison pattern:

Performance Comparison

AlgorithmWorkDepthBest GPU Use
Radix SortO(N × b/k)O(b/k × log N)Integer/float keys, maximum throughput
Merge SortO(N log N)O(log²N)Custom comparators, stable sort
Bitonic SortO(N log²N)O(log²N)Small arrays, fixed-function sorting
Sample SortO(N log N)O(log N)Distributed memory, very large N

Sorting as a Primitive

GPU sorts are building blocks for higher-level operations:

Parallel Sorting Algorithms are the throughput engines that transform unordered data into searchable, joinable, and analyzable form — the computational primitives whose GPU implementations process billions of records per second, enabling real-time analytics on datasets that sequential sorting would take minutes to process.

parallel merge sortgpu sort algorithmbitonic sort parallelradix sort gpusorting network parallel

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.