Skip to content

Performance: GPU

Each figure is measured with the released 1.0 xcc, on an Apple MacBook Pro with an M3 Max (Metal), a Linux machine with an AMD Ryzen 9 9955HX and its integrated Radeon (Vulkan), and a Windows machine with an RTX 5080 and an RTX 3090 (CUDA and Vulkan). How the CPU code compares with other compilers is on Performance: CPU; GPUs on other machines are on Performance: networked.

A par block runs a loop’s iterations at once, across every CPU thread, on the GPU, or across several devices at once: the block is cut into tiles handed to every GPU the machine has, and to the CPU, together. The GPU is reached through:

  • Metal on Apple silicon;
  • CUDA on an NVIDIA GPU under Windows;
  • Vulkan on Linux, Windows and Android;
  • WebGPU in a browser.

The programs in benchmark/par are plain loops: none of them says par. xcc turns each loop whose iterations are independent into a par block by itself (--par-style=auto, the default), so they are built with no flags. They are:

  • mandelbrot: a 2048×2048 escape-time image, at most 256 iterations a pixel;
  • perlin: 2048×2048 improved noise, four octaves;
  • nbody: the force on each of 8192 bodies from all the others;
  • saxpy: y = a·x + y over 16 million integers, with a sum;
  • md5, md5_mask: the hashcat MD5 workload, hashing 64 million candidates through the full 64-round compression and summing the digests;
  • mandel_deep: the mandelbrot image at up to 65,536 iterations a pixel.

Each runs its block eight times and reports the best run. The single-device modes are one thread (XC_PAR=cpu XC_PAR_THREADS=1), all threads (XC_PAR=cpu) and GPU (XC_PAR=gpu). A block can also run on every GPU (XC_PAR=gpus) or on every device (XC_PAR=all), and XC_PAR_WORKERS=… names an exact set (cuda, vulkan, metal, cpu). auto, the default, times the sets the machine can form and keeps the fastest; it remembers the choice, per program and per machine, so later runs do not measure again. Every mode’s checksum must agree. On Windows GPU is CUDA and Vulkan the same work through Vulkan (XC_PAR_GPU=vulkan).

Apple MacBook Pro, M3 Max, a 40-core GPU (12 performance and 4 efficiency cores), its GPU through Metal (ms; best of eight runs)

benchmarkone threadall threadsGPUall devicesautoGPU vs all threadsGPU’s first run
mandelbrot16513.71.31.2977 µs10.2× faster34.4
md513491085.05.75.021× faster42.6
md5_mask106484.94.24.44.220× faster26.6
nbody17.81.81.11.31.31.59× faster23.9
perlin72.76.11.1790 µs779 µs5.3× faster26.5
saxpy1.41.14.02.01.13.7× slower4.0

AMD Ryzen 9 9955HX (16 cores, 32 threads), Linux, its integrated Radeon 610M (2 compute units, 128 shader lanes) through Vulkan (ms; best of eight runs)

benchmarkone threadall threadsGPUall devicesautoGPU vs all threadsGPU’s first run
mandelbrot56.22.49.49.42.43.9× slower31.7
md52299.51071099.511.3× slower139
md5_mask1998.488.787.28.410.6× slower118
nbody7.5524 µs3.33.4530 µs6.4× slower25.5
perlin83.76.15.05.35.01.23× faster30.7
saxpy3.32.29.82.62.34.4× slower10.3

Intel Core i5-14500 (14 cores, 20 threads), Linux, an NVIDIA RTX 5070 through CUDA and Vulkan (from 0.88) (ms; best of eight runs)

benchmarkone threadall threadsGPUVulkanall devicesautoGPU vs all threadsGPU’s first runVulkan’s first run
mandelbrot96.68.3197 µs280 µs235 µs198 µs42× faster214111
md576672.01.52.61.71.549× faster213114
md5_mask62160.11.22.31.31.249× faster125108
nbody18.53.4365 µs354 µs394 µs366 µs9.4× faster210106
perlin11110.6374 µs1.1406 µs372 µs28× faster122108
saxpy4.42.56.325.72.62.52.5× slower10.431.4

Raspberry Pi 5 (four Cortex-A76 cores at 2.4 GHz), Raspberry Pi OS, its VideoCore VII GPU (V3D 7.1) through Vulkan (from 0.89) (ms; best of eight runs)

benchmarkone threadall threadsGPUall devicesautoGPU vs all threadsGPU’s first run
mandel_deep50772135238393835657021.61× faster8463
mandelbrot32586.511011162.51.28× slower157
md5287471966011336111.09× faster706
md5_mask23435864744753271.23× faster518
nbody96.023.823.723.917.6the same67.5
perlin32481.355.977.153.51.45× faster125
saxpy25.534.613157.726.73.8× slower134

AMD Ryzen 9 5950X with an RTX 5080 and an RTX 3090

Section titled “AMD Ryzen 9 5950X with an RTX 5080 and an RTX 3090”

AMD Ryzen 9 5950X (16 cores, 32 threads), Windows, an NVIDIA RTX 5080 through CUDA and an RTX 3090 through Vulkan (ms; best of eight runs)

benchmarkone threadall threadsGPUall GPUsVulkanall devicesautoGPU vs all threadsGPU’s first runVulkan’s first run
mandelbrot81.24.0141 µs196 µs291 µs198 µs142 µs29× faster95.2157
md581939.9894 µs790 µs1.6784 µs898 µs45× faster80.9163
md5_mask65232.5748 µs666 µs1.4689 µs747 µs43× faster101160
nbody15.01.0398 µs441 µs739 µs442 µs399 µs2.6× faster81.9163
perlin1338.3447 µs492 µs1.0377 µs443 µs18.6× faster81.9165
saxpy4.83.15.45.429.73.23.21.75× slower16.531.0

Chrome on the Apple M4 Max: wasm32 (one thread) and WebGPU (from 0.73); measured with 0.86, as the M3 Max has no Chrome (ms; best of eight runs)

benchmarkone threadall threadsGPUautoGPU vs one threadGPU’s first run
mandelbrot494–1.81.6274× faster11.7
md54229–5.35.4798× faster32.3
md5_mask3395–4.34.4790× faster24.6
nbody59.2–1.71.435× faster10.8
perlin104–2.62.640× faster10.1
saxpy1.9–29.21.915.4× slower48.9

What the tables show:

  • A discrete GPU wins by a wide margin on the programs that do real work per element — md5 hashes 64 million candidates in about a millisecond on one discrete card against hundreds on the CPU — and auto finds that and uses it.
  • saxpy stays on the CPU. It does one multiply-add for every eight bytes it moves, so copying to and from the GPU outweighs the arithmetic, and auto keeps it on the CPU everywhere.
  • The tile queue scales a block across GPUs, where that pays. saxpy spreads across both cards as the sum of their PCIe links — one GPU 16 ms, both 7.9 — though it is memory-bound, so the CPU still wins and auto keeps it there. md5 at 64 million candidates takes 0.9 ms on one card and 0.7 on both: a block this short gains little from a second card, since the queue’s cost per tile is paid twice, and auto chooses between them by measuring. A second GPU pays most on a block big enough to need its compute and not bound by the transfer to it.
  • Mixed graphics APIs. The scheduler does not require one API: a block can run one card through CUDA beside another through Vulkan, so an NVIDIA and an AMD card could share a block the same way.
  • The Raspberry Pi 5 (from 0.89): the V3D runs par blocks through Vulkan in 32-bit kernels, as it has no 64-bit integers. On its own it trails the four cores on most blocks and edges them on md5; auto measures both and then the two together, and runs perlin, md5, md5_mask and mandel_deep across the CPU and the GPU at once: mandel_deep in 9.6 s, against 14.0 s on the cores and 22.9 s on the GPU alone, where GCC with OpenMP takes about 32 s (Performance: C). The “all devices” column is the set forced from the start, before auto has measured the CPU, so it is mostly the GPU’s tiles.
  • The Ryzen’s integrated Radeon has 128 shader lanes against the CPU’s 32 threads. It just beats them on mandelbrot, perlin and md5 and loses on nbody and saxpy, where auto keeps the CPU.
  • Vulkan against CUDA: the RTX 3090 through Vulkan against the RTX 5080 through CUDA, two cards, so this compares the APIs only roughly: Vulkan is slower on mandel_deep (32.5 ms against 17.5) and mandelbrot (291 µs against 141 µs) and md5 (1.6 ms against 894 µs) and md5_mask (1.4 ms against 748 µs) and nbody (739 µs against 398 µs) and perlin (1.0 ms against 447 µs) and saxpy (29.7 ms against 5.4).
  • The first run carries one-off costs (building the kernel, and on NVIDIA creating the driver context and compiling the PTX or SPIR-V), so it is shown apart: a few tens of milliseconds on Metal and the integrated GPU, and on the 3090 16 to 122 ms through CUDA and 31 to 214 ms through Vulkan. auto pays it once, while it measures.
python3 benchmark/par/run.py # the par tables
python3 benchmark/page.py