Volume xx (200y), Number z, pp. 1–9
GPU Random Numbers via the Tiny Encryption Algorithm
Fahad Zafar, Marc Olano, Aaron Curtis
University of Maryland, Baltimore County
Abstract
Random numbers are extensively used on the GPU. As more computation is ported to the GPU, it can no longer
be treated as rendering hardware alone. Random number generators (RNG) are expected to cater general purpose
and graphics applications alike. Such diversity adds to expected requirements of a RNG. A good GPU RNG should
be able to provide repeatability, random access, multiple independent streams, speed, and random numbers free
from detectable statistical bias. A specific application may require some if not all of the above characteristics at
one time. In particular, we hypothesize that not all algorithms need the highest-quality random numbers, so a good
GPU RNG should provide a speed quality tradeoff that can be tuned for fast low quality or slower high quality
random numbers.
We propose that the Tiny Encryption Algorithm satisfies all of the requirements of a good GPU Pseudo Random
Number Generator. We compare our technique against previous approaches, and present an evaluation using
standard randomness test suites as well as Perlin noise and a Monte-Carlo shadow algorithm. We show that the
quality of random number generation directly affects the quality of the noise produced, however, good quality
noise can still be produced with a lower quality random number generator.
Categories and Subject Descriptors (according to ACM CCS): G.3 [Probability and Statistics]: Random number
generation— I.3.7 [Computer Graphics]: Three-dimensional Graphics and Realism—Color, shading, shadowing,
and texture E.2 [Data Encryption]: —
Keywords: cryptographic hash, noise, shadows
1. Introduction
Random numbers have many uses in computer graphics,
from Monte-Carlo sampling for realistic image synthesis to
noise generation for artistic shader construction. The mod-
ern Graphics Processing Unit (GPU) is a high performance
programmable parallel processor. While many randomized
shading effects can be accomplished through textures, the
increasing bias of GPUs towards computation over texture
lookups, especially potentially uncorrelated texture lookups,
leads to a desire for more computational solutions.
In particular, generation of random numbers on the GPU
should not require valuable texture storage and texture band-
width. Since changes in random sampling can introduce
dancing or shimmering artifacts, we need the same ran-
dom numbers from the RNG given the same seed position
in space or on a surface. Additionally we require indepen-
dent parallel streams of random numbers. For some appli-
cations, these streams are per-GPU thread, while for oth-
ers they are based on either position in space or on the sur-
face, with a single GPU thread potentially pulling numbers
from several streams. For spatial streams, several threads
may access numbers from the same stream, and should get
the same results. The numbers should be statistically inde-
pendent within each stream and between streams. Multiple
calls should also not halt for some shared memory object
that maintains the state of the RNG.
This leads to a set of desired properties for GPU random
number generation: repeatability to avoid frame-to-frame
coherence artifacts, independent random streams and ran-
dom access within the stream for parallel consistency, ran-
dom numbers free from noticeable statistical bias, and gen-
erator speed. Like other authors, we find a cryptographic
function satisfies all of these requirements [TW08]. By run-
ning a seed and possible sequence number through the cryp-
tographic function, we get repeatable, randomly accessible
parallel streams of random numbers. One of the primary
submitted to COMPUTER GRAPHICS Forum (5/2010).