18 #ifndef viskores_random_Philox_h
19 #define viskores_random_Philox_h
38 template <
typename UIntType, std::size_t N, UIntType... consts>
39 struct philox_parameters;
41 template <
typename T, T M0, T C0>
42 struct philox_parameters<T, 2, M0, C0>
44 static constexpr
Vec<T, 1> multipliers = { M0 };
45 static constexpr
Vec<T, 1> round_consts = { C0 };
48 template <
typename T, T M0, T C0, T M1, T C1>
49 struct philox_parameters<T, 4, M0, C0, M1, C1>
55 template <
typename UIntType, std::size_t N, std::size_t R, UIntType... consts>
58 template <
typename UIntType, std::size_t R, UIntType... consts>
59 class philox_functor<UIntType, 2, R, consts...>
65 VISKORES_EXEC_CONT counters_type operator()(counters_type counters, keys_type keys)
const
67 for (std::size_t i = 0; i < R; ++i)
69 counters = round(counters, keys);
70 keys = bump_keys(keys);
76 static VISKORES_EXEC_CONT counters_type round(counters_type counters, keys_type round_keys)
78 auto constexpr multipliers = philox_parameters<UIntType, 2, consts...>::multipliers;
80 return { r[1] ^ round_keys[0] ^ counters[1], r[0] };
85 auto constexpr round_consts = philox_parameters<UIntType, 2, consts...>::round_consts;
86 return { keys[0] + round_consts[0] };
90 template <
typename UIntType, std::size_t R, UIntType... consts>
91 class philox_functor<UIntType, 4, R, consts...>
96 static VISKORES_EXEC_CONT counters_type round(counters_type counters, keys_type round_keys)
98 auto constexpr multipliers = philox_parameters<UIntType, 4, consts...>::multipliers;
102 r1[1] ^ round_keys[0] ^ counters[1], r1[0], r0[1] ^ round_keys[1] ^ counters[3], r0[0]
108 auto constexpr round_consts = philox_parameters<UIntType, 4, consts...>::round_consts;
109 keys[0] += round_consts[0];
110 keys[1] += round_consts[1];
115 VISKORES_EXEC_CONT counters_type operator()(counters_type counters, keys_type keys)
const
117 for (std::size_t i = 0; i < R; ++i)
119 counters = round(counters, keys);
120 keys = bump_key(keys);
130 detail::philox_functor<viskores::UInt32, 2, 10, 0xD256D193, 0x9E3779B9>;
134 #endif //viskores_random_Philox_h