10 #ifndef vtk_m_random_Philox_h
11 #define vtk_m_random_Philox_h
29 template <
typename UIntType, std::size_t N, UIntType... consts>
30 struct philox_parameters;
32 template <
typename T, T M0, T C0>
33 struct philox_parameters<T, 2, M0, C0>
35 static constexpr
Vec<T, 1> multipliers = { M0 };
36 static constexpr
Vec<T, 1> round_consts = { C0 };
39 template <
typename T, T M0, T C0, T M1, T C1>
40 struct philox_parameters<T, 4, M0, C0, M1, C1>
46 template <
typename UIntType, std::size_t N, std::size_t R, UIntType... consts>
49 template <
typename UIntType, std::size_t R, UIntType... consts>
50 class philox_functor<UIntType, 2, R, consts...>
56 VTKM_EXEC_CONT counters_type operator()(counters_type counters, keys_type keys)
const
58 for (std::size_t i = 0; i < R; ++i)
60 counters = round(counters, keys);
61 keys = bump_keys(keys);
67 static VTKM_EXEC_CONT counters_type round(counters_type counters, keys_type round_keys)
69 auto constexpr multipliers = philox_parameters<UIntType, 2, consts...>::multipliers;
71 return { r[1] ^ round_keys[0] ^ counters[1], r[0] };
76 auto constexpr round_consts = philox_parameters<UIntType, 2, consts...>::round_consts;
77 return { keys[0] + round_consts[0] };
81 template <
typename UIntType, std::size_t R, UIntType... consts>
82 class philox_functor<UIntType, 4, R, consts...>
87 static VTKM_EXEC_CONT counters_type round(counters_type counters, keys_type round_keys)
89 auto constexpr multipliers = philox_parameters<UIntType, 4, consts...>::multipliers;
93 r1[1] ^ round_keys[0] ^ counters[1], r1[0], r0[1] ^ round_keys[1] ^ counters[3], r0[0]
99 auto constexpr round_consts = philox_parameters<UIntType, 4, consts...>::round_consts;
100 keys[0] += round_consts[0];
101 keys[1] += round_consts[1];
106 VTKM_EXEC_CONT counters_type operator()(counters_type counters, keys_type keys)
const
108 for (std::size_t i = 0; i < R; ++i)
110 counters = round(counters, keys);
111 keys = bump_key(keys);
124 #endif //vtk_m_random_Philox_h