22 template<
unsigned TCounterSize,
unsigned TW
idth,
unsigned TRounds>
26 static constexpr unsigned width = TWidth;
27 static constexpr unsigned rounds = TRounds;
37 template<
typename T_Params>
42 return T_Params::rounds;
47 return T_Params::counterSize;
52 return T_Params::width;
55 static_assert(
numRounds() > 0,
"Number of Philox rounds must be > 0.");
56 static_assert(
vectorSize() % 2 == 0,
"Philox counter size must be an even number.");
57 static_assert(
vectorSize() <= 16,
"Philox SP network is not specified for sizes > 16.");
58 static_assert(
numberWidth() % 8 == 0,
"Philox number width in bits must be a multiple of 8.");
60 static_assert(
numberWidth() == 32,
"Philox implemented only for 32 bit numbers.");
75 std::uint32_t H0, L0, H1, L1;
78 return Counter{H1 ^ counter[1] ^ key[0], L1, H0 ^ counter[3] ^ key[1], L0};
105 for(
unsigned int n = 0; n < rounds; ++n)
static consteval std::uint32_t MULTIPLITER_4x32_1()
Second Philox S-box multiplier.
static consteval std::uint32_t MULTIPLITER_4x32_0()
First Philox S-box multiplier.
static consteval std::uint32_t WEYL_32_0()
1st Weyl sequence parameter, 32 bits
static consteval std::uint32_t WEYL_32_1()
2nd Weyl sequence parameter, 32 bits
Class basic Philox family counter-based PRNG.
static constexpr auto singleRound(Counter const &counter, Key const &key)
Single round of the Philox shuffle.
static constexpr auto nRounds(Counter const &counter_in, Key const &key_in) -> Counter
Performs N rounds of the Philox shuffle.
static constexpr unsigned numRounds()
static constexpr unsigned vectorSize()
alpaka::Vec< std::uint32_t, T_Params::counterSize/2 > Key
static constexpr unsigned numberWidth()
static constexpr auto generate(Counter const &counter, Key const &key) -> Counter
Generates a random number (TCounterSize x32-bit).
static constexpr auto bumpKey(Key const &key)
Bump the key by the Weyl sequence step parameter.
alpaka::Vec< std::uint32_t, T_Params::counterSize > Counter
constexpr void multiplyAndSplit64to32(std::uint64_t const a, std::uint64_t const b, std::uint32_t &resultHigh, std::uint32_t &resultLow)
Multiply two 64-bit numbers and split the result into high and low 32 bits, also known as "mulhilo32"...
Philox algorithm parameters.
static constexpr unsigned width
static constexpr unsigned rounds
static constexpr unsigned counterSize