999.specrand_r
999.specrand_r is not timed; its purpose is primarily as a short, but important, diagnostic tool.
Although it is not timed, in all other respects, it behaves like an ordinary benchmark. Therefore the remainder of this description will assume that this is understood and will refer to it as if it were a benchmark.
Cloyce D. Spradling <cloyce+specrand [at] headgear [dot] org>
Mine Canary
999.specrand_r is a small harness for the verifying the consistency of output from the implementation of the Mersenne Twister algorithm that some of the candidate benchmarks use.
It also includes testing of a C++ header which provides deterministic implementations of random number distributions which were adapted from the LLVM libc++ standard library.
These are used in SPEC CPU benchmarks to ensure reproducible results across different platforms and compilers.
The benchmark simply generates a sequence of pseudorandom numbers starting with a known seed. This benchmark is not a timed component of SPEC CPU 2026; rather, it's there as an indicator of larger problems. Several of the benchmarks use the specrand code as their PRNG. Thus, a failure in 999.specrand_r would point out a source of error in those codes as well. This is cheap (in both time and space) insurance.
The benchmark builds two executables:
specrand_r: The main specrand harness
testing the core Mersenne Twister PRNG functions.distributions_r: A test harness for the C++ random
distribution implementations.Parameters for both executables are read from a control file. Each line of the control file contains two numbers: a seed value for the PRNG and a count of the numbers to generate. Lines beginning with # or empty lines are ignored.
Both executables are invoked with the same command-line arguments:
specrand_r OutputThe specrand_r executable generates random numbers and
outputs them four times.
The first set is unscaled output from the spec_rand()
function, output as a standard floating point number with no precision
modifiers (using the standard printf '%f' format).
The second set is output from spec_rand() scaled to
between 1 and 2^31-1 (0x7fffffff, or the maximum positive value that a
signed 32-bit integer can hold), and is output as the original floating
point number, the multiplier, and the scaled result as a standard
integer (usijng the standard printf '%d' format).
The third set is the output from the spec_lrand48()
function, scaled to between 0 and 1 and output using standard printf
'%f' format.
The fourth sequence is unscaled output from the
spec_lrand48() function using standard printf
'%d' format.
The PRNG is re-seeded between sequences.
distributions_r OutputThe distributions_r executable samples from each
distribution type and outputs the results. For each distribution, it
outputs a header line identifying the distribution and its parameters,
followed by the specified number of samples.
The following distributions are exercised:
spec::normal_distribution<double> with mean=5.0
and stddev=2.0spec::poisson_distribution<int> with
mean=109.47spec::poisson_distribution<int> with
mean=5280.0spec::uniform_real_distribution<double> over the
interval [10.0, 20.0)spec::uniform_int_distribution<int> over the
interval [1, 65534] (generates count/10 + 1 samples)Each distribution uses a different seed derived from the base seed to ensure independent sequences.
specrand_r)distributions_r)
None.
The specrand benchmark is a version of the Mersenne-Twister PRNG that is licensed to SPEC by its authors (Makoto Matsumoto, Takuji Nishimura, and Mutsuo Saito) under a BSD license.
The specrand-distribution random distribution classes are excerpted from the LLVM Project's libc++ implementation which is licensed under the Apache License v2.0 with LLVM Exceptions license.
Primary source files for specrand-distributions from LLVM:
libcxx/include/__random/uniform_int_distribution.hlibcxx/include/__random/uniform_real_distribution.hlibcxx/include/__random/normal_distribution.hlibcxx/include/__random/poisson_distribution.hlibcxx/include/__random/generate_canonical.hlibcxx/include/__random/log2.hNone
Copyright © 2026 Standard Performance Evaluation Corporation (SPEC®)