4#include <Kokkos_Random.hpp>
5#include <common/common.hpp>
6#include <common/traits.hpp>
17 using pool_type = Kokkos::Random_XorShift1024_Pool<Kokkos::DefaultExecutionSpace>;
18 explicit KPRNG(
size_t _seed = 0);
20 [[deprecated]] [[nodiscard]] KOKKOS_INLINE_FUNCTION
double double_uniform()
const
23 double x = generator.drand(0., 1.);
28 template <FloatingPo
intType T> KOKKOS_INLINE_FUNCTION T
uniform()
const
32 if constexpr (std::is_same_v<T, float>)
34 x = generator.frand();
36 else if constexpr (std::is_same_v<T, double>)
38 x = generator.drand();
44 template <FloatingPo
intType T> KOKKOS_INLINE_FUNCTION T
uniform(T a, T b)
const
48 if constexpr (std::is_same_v<T, float>)
50 x = generator.frand(a, b);
52 else if constexpr (std::is_same_v<T, double>)
54 x = generator.drand(a, b);
60 [[deprecated]] [[nodiscard]] Kokkos::View<double*, ComputeSpace>
61 double_uniform(
size_t n_sample,
double a = 0.,
double b = 1.)
const;
65 Kokkos::View<double[n_r], ComputeSpace> A(
"random");
71 [[deprecated]] KOKKOS_INLINE_FUNCTION std::array<double, n_r>
double_uniform()
const
76 [[nodiscard]] KOKKOS_INLINE_FUNCTION uint64_t
uniform_u(uint64_t a, uint64_t b)
const
80 uint64_t x = generator.urand64(a, b);
94 template <
typename random_pool_t,
size_t n_r,
size_t... I>
95 KOKKOS_INLINE_FUNCTION std::array<double, n_r>
99 auto generator = pool.get_state();
100 std::array<double, n_r> res = {{(
static_cast<void>(I), generator.drand(0., 1.))...}};
101 pool.free_state(generator);
Utilities and wrap around kokkos random generator.
Definition prng.hpp:15
KOKKOS_INLINE_FUNCTION uint64_t uniform_u(uint64_t a, uint64_t b) const
Definition prng.hpp:76
Kokkos::View< double[n_r], ComputeSpace > double_uniform_view() const
Definition prng.hpp:63
KOKKOS_INLINE_FUNCTION T uniform() const
Definition prng.hpp:28
KOKKOS_INLINE_FUNCTION T uniform(T a, T b) const
Definition prng.hpp:44
KOKKOS_INLINE_FUNCTION std::array< double, n_r > generate_uniform_impl(random_pool_t pool, std::index_sequence< I... >) const
Definition prng.hpp:96
auto get_seed() const
Definition prng.hpp:87
KPRNG(size_t _seed=0)
Definition prng.cpp:9
Kokkos::Random_XorShift1024_Pool< Kokkos::DefaultExecutionSpace > pool_type
Definition prng.hpp:17
KOKKOS_INLINE_FUNCTION std::array< double, n_r > double_uniform() const
Definition prng.hpp:71
KOKKOS_INLINE_FUNCTION double double_uniform() const
Definition prng.hpp:20
pool_type random_pool
Definition prng.hpp:85
std::size_t seed
Definition prng.hpp:93
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:9