21 #ifndef ROCRAND_SCRAMBLED_SOBOL32_H_
22 #define ROCRAND_SCRAMBLED_SOBOL32_H_
24 #include "rocrand/rocrand_common.h"
25 #include "rocrand/rocrand_sobol32.h"
27 namespace rocrand_device
30 template<
bool UseSharedVectors>
31 class scrambled_sobol32_engine
34 __forceinline__ __device__ __host__ scrambled_sobol32_engine() : scramble_constant() {}
36 __forceinline__ __device__ __host__
37 scrambled_sobol32_engine(
const unsigned int* vectors,
38 const unsigned int scramble_constant,
39 const unsigned int offset)
40 : m_engine(vectors, 0), scramble_constant(scramble_constant)
46 __forceinline__ __device__ __host__
void discard(
unsigned int offset)
48 m_engine.discard(offset);
51 __forceinline__ __device__ __host__
void discard()
57 __forceinline__ __device__ __host__
void discard_stride(
unsigned int stride)
59 m_engine.discard_stride(stride);
62 __forceinline__ __device__ __host__
unsigned int operator()()
67 __forceinline__ __device__ __host__
unsigned int next()
69 unsigned int p = m_engine.next();
70 return p ^ scramble_constant;
73 __forceinline__ __device__ __host__
unsigned int current()
75 unsigned int p = m_engine.current();
76 return p ^ scramble_constant;
79 __forceinline__ __device__ __host__
static constexpr
bool uses_shared_vectors()
81 return UseSharedVectors;
86 sobol32_engine<UseSharedVectors> m_engine;
88 unsigned int scramble_constant;
100 typedef rocrand_device::scrambled_sobol32_engine<false> rocrand_state_scrambled_sobol32;
114 __forceinline__ __device__ __host__
void rocrand_init(
const unsigned int* vectors,
115 const unsigned int scramble_constant,
116 const unsigned int offset,
117 rocrand_state_scrambled_sobol32* state)
119 *state = rocrand_state_scrambled_sobol32(vectors, scramble_constant, offset);
134 __forceinline__ __device__ __host__
unsigned int rocrand(rocrand_state_scrambled_sobol32* state)
136 return state->next();
147 __forceinline__ __device__ __host__
void skipahead(
unsigned long long offset,
148 rocrand_state_scrambled_sobol32* state)
150 return state->discard(offset);
__forceinline__ __device__ __host__ unsigned int rocrand(rocrand_state_scrambled_sobol32 *state)
Returns uniformly distributed random unsigned int value from [0; 2^32 - 1] range.
Definition: rocrand_scrambled_sobol32.h:134
__forceinline__ __device__ __host__ void rocrand_init(const unsigned int *vectors, const unsigned int scramble_constant, const unsigned int offset, rocrand_state_scrambled_sobol32 *state)
Initialize scrambled_sobol32 state.
Definition: rocrand_scrambled_sobol32.h:114
__forceinline__ __device__ __host__ void skipahead(unsigned long long offset, rocrand_state_scrambled_sobol32 *state)
Updates SCRAMBLED_SOBOL32 state to skip ahead by offset elements.
Definition: rocrand_scrambled_sobol32.h:147