9#include <cuda_runtime.h>
10#include <cuda/std/array>
12#include <cuda/std/span>
23template <
typename Prg,
int mul>
24concept Prgable =
requires(Prg prg, int4 seed) {
25 { prg.Gen(seed) } -> std::same_as<cuda::std::array<int4, mul>>;
41template <
typename Prg,
int mul>
43 { prg.GenHalf(seed, right) } -> std::same_as<cuda::std::array<int4, mul / 2>>;
81template <
typename Prg,
int mul>
83 { prg.Gen8(seeds) } -> std::same_as<cuda::std::array<cuda::std::array<int4, mul>, 8>>;
88namespace fss::detail {
90template <
int mul,
typename Prg>
92__host__ __device__
inline cuda::std::array<int4, mul / 2> GenHalf(Prg &prg, int4 seed,
bool right) {
94 return prg.GenHalf(seed, right);
96 auto full = prg.Gen(seed);
97 cuda::std::array<int4, mul / 2> out{};
98 int offset = right ? mul / 2 : 0;
99 for (
int i = 0; i < mul / 2; ++i) out[i] = full[i + offset];
105template <
int mul,
typename Prg>
106cuda::std::array<cuda::std::array<int4, mul>, 8> GenBatch(Prg &prg, cuda::std::span<const int4, 8> seeds) {
107 if constexpr (HasGen8<Prg, mul>) {
108 return prg.Gen8(seeds);
110 cuda::std::array<cuda::std::array<int4, mul>, 8> out{};
111 for (
int j = 0; j < 8; ++j) out[j] = prg.Gen(seeds[j]);
Optional eight-seed batch extension of Prgable.
Definition prg.cuh:82
Optional selected-half extension of Prgable for positive even mul.
Definition prg.cuh:42
Pseudorandom generator (PRG) interface.
Definition prg.cuh:24