TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
rng.hpp File Reference

Deterministic, counter-based random numbers (design doc 02 §6.2). More...

#include <cstdint>
#include "core/hd.hpp"

Go to the source code of this file.

Classes

struct  tmk::U32x4
struct  tmk::U32x2
class  tmk::RngStream
 A random stream identified by (seed, stage, item). More...

Namespaces

namespace  tmk
namespace  tmk::detail

Functions

TM_HD_INLINE constexpr void tmk::detail::mul_hi_lo (std::uint32_t a, std::uint32_t b, std::uint32_t &hi, std::uint32_t &lo)
TM_HD_INLINE constexpr U32x4 tmk::philox4x32_10 (U32x4 ctr, U32x2 key)
 One Philox4x32-10 block: 128 random bits for a 128-bit counter under a 64-bit key.
TM_HD_INLINE constexpr std::uint64_t tmk::splitmix64 (std::uint64_t x)
 SplitMix64 finaliser: a fast, well-mixed 64-bit hash, used to derive keys and for hashing ids.

Detailed Description

Deterministic, counter-based random numbers (design doc 02 §6.2).

Every random decision is a pure function of (job seed, stage, item, counter), so results never depend on thread timing, and CPU reference code and CUDA kernels produce identical streams.

Philox4x32-10: Salmon, Moraes, Dror, Shaw, "Parallel random numbers: as easy as 1, 2, 3", SC 2011. SplitMix64: Steele, Lea, Flood, "Fast splittable pseudorandom number generators", OOPSLA 2014.

Definition in file rng.hpp.