Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radix Sort on CUDA

The goal of this project was to efficiently parallelize Radix Sort on GPUs using CUDA. The design of the algorithm follows the paper Designing Efficient Sorting Algorithms for Manycore GPUs from the authors Satish, Harris a Garland. I made this as my semestral project for the subject GPU Architectures and Programming.

Brief description

The full detailed report, written in Czech, can be found in docs.

But briefly, each pass of the algorithm consists of 3 kernels (+ Host <-> Device mem transfers etc.).

  1. blockLocalSortAndComputeCountsKernel
    1. Locally (stably) sort each block bit-by-bit in shared memory using a split operation.
    2. Compute local offsets/starts of each digit.
    3. Compute the counts of each digit - histogram.
  2. prefixSumBucketCounts - Performs a parallel exclusive prefix sum over the histograms.
  3. globalScatterKernel - Scatters the numbers to the global output array, using the result of the PPS + local offsets.

Results

I performed several benchmarks to try to optimize the algorithm futher and to compare it with its sequential version and the highly optimized cub::DeviceRadixSort.

The benchmarks were run on an Apple M4 Pro CPU (14 cores, 48 GB RAM) and an NVIDIA GeForce RTX 4070 Ti GPU.

The tested distributions were uniform (random values), nearlySorted (almost sorted values with small noise), and heavyHitter (many repeated values from a small set).

CUDA configuration heatmaps

This graph measures CUDA configuration performance. The x-axis shows ITEMS_PER_THREAD / THREADS_PER_BLOCK, the y-axis shows RADIX_BITS, and each value is the relative runtime compared to the best configuration for the same dataset.

M4 CPU vs best CUDA speedup

This graph measures the speedup of the best CUDA configuration over the M4 CPU implementation. The x-axis shows the number of sorted elements, and the y-axis shows speedup in x.

Best CUDA vs CUB ratio

This graph measures how much slower the best CUDA configuration was compared to cub::DeviceRadixSort. The x-axis shows the number of sorted elements, and the y-axis shows the runtime ratio in x. As you can see, I was not faster :(

About

My semestral work for the subject NI-GPU (GPU Architectures and Programming). It consists of a sequential Radix Sort algorithm and a parallel one for GPUs.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages