21 #ifndef ROCRAND_SCRAMBLED_SOBOL64_H_
22 #define ROCRAND_SCRAMBLED_SOBOL64_H_
24 #include "rocrand/rocrand_sobol64.h"
26 #include <hip/hip_runtime.h>
28 namespace rocrand_device
31 template<
bool UseSharedVectors>
32 class scrambled_sobol64_engine
35 __forceinline__ __device__ __host__
36 scrambled_sobol64_engine()
40 __forceinline__ __device__ __host__
41 scrambled_sobol64_engine(
const unsigned long long int* vectors,
42 const unsigned long long int scramble_constant,
43 const unsigned long long int offset)
44 : m_engine(vectors, 0), scramble_constant(scramble_constant)
50 __forceinline__ __device__ __host__
51 void discard(
unsigned long long int offset)
53 m_engine.discard(offset);
56 __forceinline__ __device__ __host__
63 __forceinline__ __device__ __host__
64 void discard_stride(
unsigned long long int stride)
66 m_engine.discard_stride(stride);
69 __forceinline__ __device__ __host__
70 unsigned long long int operator()()
75 __forceinline__ __device__ __host__
76 unsigned long long int next()
78 unsigned long long int p = m_engine.next();
79 return p ^ scramble_constant;
82 __forceinline__ __device__ __host__
83 unsigned long long int current()
85 unsigned long long int p = m_engine.current();
86 return p ^ scramble_constant;
89 __forceinline__ __device__ __host__
90 static constexpr
bool uses_shared_vectors()
92 return UseSharedVectors;
97 sobol64_engine<UseSharedVectors> m_engine;
99 unsigned long long int scramble_constant;
111 typedef rocrand_device::scrambled_sobol64_engine<false> rocrand_state_scrambled_sobol64;
125 __forceinline__ __device__ __host__
127 const unsigned long long int scramble_constant,
128 const unsigned long long int offset,
129 rocrand_state_scrambled_sobol64* state)
131 *state = rocrand_state_scrambled_sobol64(vectors, scramble_constant, offset);
146 __forceinline__ __device__ __host__
147 unsigned long long int rocrand(rocrand_state_scrambled_sobol64* state)
149 return state->next();
160 __forceinline__ __device__ __host__
161 void skipahead(
unsigned long long offset, rocrand_state_scrambled_sobol64* state)
163 return state->discard(offset);
__forceinline__ __device__ __host__ unsigned long long int rocrand(rocrand_state_scrambled_sobol64 *state)
Returns uniformly distributed random unsigned long long int value from [0; 2^64 - 1] range.
Definition: rocrand_scrambled_sobol64.h:147
__forceinline__ __device__ __host__ void skipahead(unsigned long long offset, rocrand_state_scrambled_sobol64 *state)
Updates scrambled_sobol64 state to skip ahead by offset elements.
Definition: rocrand_scrambled_sobol64.h:161
__forceinline__ __device__ __host__ void rocrand_init(const unsigned long long int *vectors, const unsigned long long int scramble_constant, const unsigned long long int offset, rocrand_state_scrambled_sobol64 *state)
Initialize scrambled_sobol64 state.
Definition: rocrand_scrambled_sobol64.h:126