arXiv:2609.00843cs.DCSep 2026

Manuscript Offprint

arXiv:2609.00843

Shared-Memory Range-Tiled CDF Sort for Small-Range Integer Keys on GPUs

Kento Ando, Kaito Takase, Noriyuki Fujimoto, Koichi Wada

Abstract

We study unstable integer sorting on GPUs for arrays whose elements lie in a known integer range. Focusing on counting-sort-based methods that determine the output interval of each value from its frequency and the prefix sums of the frequencies, we propose and evaluate Range-Tiled CDF sort (RT-CDF), which partitions the possible value range into small intervals, called tiles, that fit in shared memory. For each tile, RT-CDF constructs a histogram, computes its prefix sum as a local CDF, and directly generates the output array from the local CDF. We compare RT-CDF against three baselines: CUB DeviceRadixSort, whose processed bit range is restricted to [0,⌊log⁡2R⌋)[0, \lfloor \log_2 R \rfloor) to exploit the known range size RR; Ref-H-P sort; and an implementation based on the algorithm of Kolonias et al. Experiments on an NVIDIA GeForce RTX 4090 with range sizes from R=27R = 2^7 to 2182^{18}, input sizes from n=106n = 10^6 to 10910^9, and uniformly distributed, normally distributed, and all-equal inputs show that RT-CDF outperforms the baselines over a broad set of conditions for small to medium ranges, achieving a maximum speedup of 4.39 over the fastest baseline. For R=218R = 2^{18}, however, at least one baseline outperforms RT-CDF for every evaluated input size and input distribution, showing that the cost of histogram construction limits the applicability of RT-CDF to larger ranges.

1 Introduction

Sorting is a fundamental operation used in many computational tasks, including database processing, graph processing, simulation, and image processing. GPUs can process large numbers of elements in parallel, and many parallel sorting algorithms, including radix sort, merge sort, and sample sort, have been studied and implemented [1, 2]. GPU radix sorting for integers is particularly important in practice, and recent implementations such as Onesweep reduce the amount of data read from and written to global memory [3]. CUB DeviceRadixSort, provided by NVIDIA, is also widely used as a highly optimized GPU sorting implementation [4].

When the range of possible input values is known in advance and is sufficiently small relative to the input size, however, this additional restriction can be exploited. In particular, counting sort can count the occurrences of each value and use prefix sums of the counts to determine the interval occupied by each value in the output array. If stability is not required, individual input elements need not be moved to their respective ranks. A correct sorted output can instead be obtained by determining the contiguous interval occupied by each value and writing that value throughout the interval. We denote the number of input elements by nn and the size of the known integer range [minVal,maxVal)[minVal, maxVal) by R=maxVal−minValR = maxVal - minVal. The problem considered in this paper is to sort nn integers from this range into nondecreasing order without preserving the relative order of equal values.

Previous work on range-restricted integer sorting on GPUs includes the counting sort of Kolonias et al. [5], a GPU implementation of H-P sort based on Eisenstat's algorithm [6, 7], and Ref-H-P sort (hereafter RefHP), which refines H-P sort for GPU execution [8]. These methods share the property that a histogram and its prefix sums provide information about the output position or output interval of each value. We focus on this common structure, in which output intervals are determined from a histogram and prefix sums. We then propose and evaluate Range-Tiled CDF sort (RT-CDF), which partitions the possible integer range into multiple small intervals, called range tiles, that fit in shared memory, and constructs a histogram and a cumulative distribution function (CDF) for each tile.

In this paper, the term CDF denotes the cumulative-count array obtained as the prefix sum of a histogram. It is not a probability distribution normalized to the interval [0,1][0,1]; rather, each entry gives the number of input values no greater than the corresponding value. The CDF constructed within a tile, which we call a local CDF, determines the output interval occupied by each value in that tile. Consequently, the output can be generated without rescanning the input array.

The contributions of this work are as follows.

  • We develop RT-CDF, which partitions the value range into tiles that fit in shared memory and directly generates the output array from the local CDF of each tile.

  • We clarify the algorithmic relationship between RT-CDF and a counting-sort implementation based on Kolonias et al., H-P sort, and RefHP, and identify how RT-CDF differs from existing methods that determine output intervals from a CDF.

  • On an NVIDIA GeForce RTX 4090, we compare RT-CDF with CUB DeviceRadixSort, RefHP, and an implementation based on Kolonias et al., and identify the range sizes and input sizes for which RT-CDF is effective, as well as its limitations near R=218R = 2^{18}.