This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Notebooks · lib/randla/philox

Philox4x32-10, the counter-based generator behind every randla sketch

A counter-based generator maps a counter and a key to random bits with no state in between: the bits for entry 7,000 of a sketch are computed directly from the number 7,000, without drawing the 6,999 before it. That is what lets randla build a sketching operator on the fly, one block of entries at a time, and give the same operator in the interpreter, in C and in wasm, and in any order of evaluation (Salmon, Moraes, Dror and Shaw, "Parallel random numbers: as easy as 1, 2, 3", SC11). RandBLAS makes the same choice.

philox4x32(c0, c1, c2, c3, k0, k1) is Random123's philox4x32 with ten rounds; the known-answer vectors from Random123's kat_vectors are tested below. The words are 32-bit values held in Ints.

randla's convention for the counter: (c0, c1) is a 64-bit block index (low word, high word), c2 is the stream, and c3 picks a sub-sequence when one index needs more than four words. The key is the 64-bit seed, split in two.

Used with from randla.philox import ....

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.

[1]lines 24–138