21 #ifndef ROCRAND_SCRAMBLED_SOBOL64_H_
22 #define ROCRAND_SCRAMBLED_SOBOL64_H_
24 #include "rocrand/rocrand_common.h"
25 #include "rocrand/rocrand_sobol64.h"
27 namespace rocrand_device
30 template<
bool UseSharedVectors>
31 class scrambled_sobol64_engine
34 __forceinline__ __device__ __host__ scrambled_sobol64_engine() : scramble_constant() {}
36 __forceinline__ __device__ __host__
37 scrambled_sobol64_engine(
const unsigned long long int* vectors,
38 const unsigned long long int scramble_constant,
39 const unsigned int offset)
40 : m_engine(vectors, 0), scramble_constant(scramble_constant)
46 __forceinline__ __device__ __host__
void discard(
unsigned long long int offset)
48 m_engine.discard(offset);
51 __forceinline__ __device__ __host__
void discard()
57 __forceinline__ __device__ __host__
void discard_stride(
unsigned long long int stride)
59 m_engine.discard_stride(stride);
62 __forceinline__ __device__ __host__
unsigned long long int operator()()
67 __forceinline__ __device__ __host__
unsigned long long int next()
69 unsigned long long int p = m_engine.next();
70 return p ^ scramble_constant;
73 __forceinline__ __device__ __host__
unsigned long long int current()
75 unsigned long long int p = m_engine.current();
76 return p ^ scramble_constant;
79 __forceinline__ __device__ __host__
static constexpr
bool uses_shared_vectors()
81 return UseSharedVectors;
86 sobol64_engine<UseSharedVectors> m_engine;
88 unsigned long long int scramble_constant;
100 typedef rocrand_device::scrambled_sobol64_engine<false> rocrand_state_scrambled_sobol64;
114 __forceinline__ __device__ __host__
void
116 const unsigned long long int scramble_constant,
117 const unsigned int offset,
118 rocrand_state_scrambled_sobol64* state)
120 *state = rocrand_state_scrambled_sobol64(vectors, scramble_constant, offset);
135 __forceinline__ __device__ __host__
unsigned long long int
136 rocrand(rocrand_state_scrambled_sobol64* state)
138 return state->next();
149 __forceinline__ __device__ __host__
void skipahead(
unsigned long long offset,
150 rocrand_state_scrambled_sobol64* state)
152 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:136
__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:149
__forceinline__ __device__ __host__ void rocrand_init(const unsigned long long int *vectors, const unsigned long long int scramble_constant, const unsigned int offset, rocrand_state_scrambled_sobol64 *state)
Initialize scrambled_sobol64 state.
Definition: rocrand_scrambled_sobol64.h:115