Notebooks · lib/randlc
randlc, the NAS Parallel Benchmarks' random number generator
The NAS Parallel Benchmarks draw every random number from one linear
congruential generator: x_{k+1} = a * x_k mod 2^46, returned as the uniform
2^-46 * x_{k+1} in (0, 1). The seeds and multipliers in the benchmarks
(a = 5^13 = 1220703125, s = 271828183 for EP and IS, 314159265 for CG)
are odd integers below 2^46.
NPB ships two versions of the same function: randdp.f90 splits each factor
into 23-bit halves so that every product is exact in a double, and
randi8.f90 (the one NPB3.4's sample make.def selects) multiplies two
64-bit integers and keeps the low 46 bits. Both give the same bits. This module
is the integer one: the product of two numbers below 2^46 wraps mod 2^64, and
band with 2^46 - 1 keeps the low 46 bits, which are the low 46 bits of the
exact product because 2^46 divides 2^64.
randlc(x, a): the next statea * x mod 2^46and the uniform it gives, as NPB'srandlc(x, a)returns the uniform and overwritesx.vranlc(n, x, a, y):nuniforms intoy[0], ..., y[n-1], returning the state after the last one (NPB'svranlc(n, x, a, y)).randlc_split(x, a): the same step byranddp.f90's double arithmetic, kept as the check member: the tests hold the two equal.
Used with from randlc import randlc, vranlc.
Look inside this program
- Atlas
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.