ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
curand_kernel.h
Go to the documentation of this file.
1#if !defined(CURAND_KERNEL_H_)
2# define CURAND_KERNEL_H_
3
4# include "curand_precalc.h"
5# include <cmath>
6# include <curand.h>
7
8# define MAX_XOR_N (5)
9# define SKIPAHEAD_BLOCKSIZE (4)
10# define SKIPAHEAD_MASK ((1 << SKIPAHEAD_BLOCKSIZE) - 1)
11# define CURAND_2POW32_INV (2.3283064e-10f)
12# define CURAND_2POW32_INV_DOUBLE (2.3283064365386963e-10)
13# define CURAND_2POW53_INV_DOUBLE (1.1102230246251565e-16)
14# define CURAND_2POW32_INV_2PI (2.3283064e-10f * 6.2831855f)
15# define CURAND_2POW53_INV_2PI_DOUBLE \
16 (1.1102230246251565e-16 * 6.2831853071795860)
17# define CURAND_SQRT2 (-1.4142135f)
18# define CURAND_SQRT2_DOUBLE (-1.4142135623730951)
19# define PRECALC_NUM_MATRICES (8)
20# define PRECALC_BLOCK_SIZE (2)
21# define PRECALC_BLOCK_MASK ((1 << PRECALC_BLOCK_SIZE) - 1)
22# define XORWOW_SEQUENCE_SPACING (67)
23
24static unsigned int precalc_xorwow_matrix[8][2] = {{850664906UL, 4258393217UL}};
25
26# if !defined(QUALIFIERS)
27# define QUALIFIERS static inline __device__
28# endif
29
30/* Test RNG */
31/* This generator uses the formula:
32 x_n = x_(n-1) + 1 mod 2^32
33 x_0 = (unsigned int)seed * 3
34 Subsequences are spaced 31337 steps apart.
35*/
37{
38 unsigned int v;
39};
40
42
43/* XORSHIFT FAMILY RNGs */
44/* These generators are a family proposed by Marsaglia. They keep state
45 in 32 bit chunks, then use repeated shift and xor operations to scramble
46 the bits. The following generators are a combination of a simple Weyl
47 generator with an N variable XORSHIFT generator.
48*/
49
50/* XORSHIFT RNG */
51/* This generator uses the xorwow formula of
52www.jstatsoft.org/v08/i14/paper page 5
53Has period 2^192 - 2^32.
54*/
59
64
65/* Implementation details not in reference documentation */
67{
68 unsigned int d, v[5];
72};
73
74/* SOBOL QRNG */
79
80/* Implementation details not in reference documentation */
82{
83 unsigned int i, x;
84 unsigned int direction_vectors[32];
85};
86
91
96
97/* Implementation details not in reference documentation */
99{
100 unsigned int i, x, c;
101 unsigned int direction_vectors[32];
102};
103
108
112struct curandStateSobol64;
113
114/* Implementation details not in reference documentation */
116{
117 unsigned long long i, x;
118 unsigned long long direction_vectors[64];
119};
120
125
130
131/* Implementation details not in reference documentation */
133{
134 unsigned long long i, x, c;
135 unsigned long long direction_vectors[64];
136};
137
142
148
149/****************************************************************************/
150/* Utility functions needed by RNGs */
151/****************************************************************************/
152
153/* multiply vector by matrix, store in result
154 matrix is n x n, measured in 32 bit units
155 matrix is stored in row major order
156 vector and result cannot be same pointer
157*/
158/*QUALIFIERS*/ void __curand_matvec(
159 unsigned int *vector,
160 unsigned int *matrix,
161 unsigned int *result,
162 int n)
163{
164 for (int i = 0; i < n; i++)
165 {
166 result[i] = 0;
167 }
168 for (int i = 0; i < n; i++)
169 {
170 for (int j = 0; j < 32; j++)
171 {
172 if (vector[i] & (1 << j))
173 {
174 for (int k = 0; k < n; k++)
175 {
176 result[k] ^= matrix[n * (i * 32 + j) + k];
177 }
178 }
179 }
180 }
181}
182
183/* generate identity matrix */
184/*QUALIFIERS*/ void __curand_matidentity(unsigned int *matrix, int n)
185{
186 int r;
187 for (int i = 0; i < n * 32; i++)
188 {
189 for (int j = 0; j < n; j++)
190 {
191 r = i & 31;
192 if (i / 32 == j)
193 {
194 matrix[i * n + j] = (1 << r);
195 }
196 else
197 {
198 matrix[i * n + j] = 0;
199 }
200 }
201 }
202}
203
204/* multiply matrixA by matrixB, store back in matrixA
205 matrixA and matrixB must not be same matrix */
206/*QUALIFIERS*/ void
207__curand_matmat(unsigned int *matrixA, unsigned int *matrixB, int n)
208{
209 unsigned int result[MAX_XOR_N];
210 for (int i = 0; i < n * 32; i++)
211 {
212 __curand_matvec(matrixA + i * n, matrixB, result, n);
213 for (int j = 0; j < n; j++)
214 {
215 matrixA[i * n + j] = result[j];
216 }
217 }
218}
219
220/* copy vectorA to vector */
221/*QUALIFIERS*/ void
222__curand_veccopy(unsigned int *vector, unsigned int *vectorA, int n)
223{
224 for (int i = 0; i < n; i++)
225 {
226 vector[i] = vectorA[i];
227 }
228}
229
230/* copy matrixA to matrix */
231/*QUALIFIERS*/ void
232__curand_matcopy(unsigned int *matrix, unsigned int *matrixA, int n)
233{
234 for (int i = 0; i < n * n * 32; i++)
235 {
236 matrix[i] = matrixA[i];
237 }
238}
239
240/* compute matrixA to power p, store result in matrix */
241/*QUALIFIERS*/ void __curand_matpow(
242 unsigned int *matrix,
243 unsigned int *matrixA,
244 unsigned long long p,
245 int n)
246{
247 unsigned int matrixR[MAX_XOR_N * MAX_XOR_N * 32];
248 unsigned int matrixS[MAX_XOR_N * MAX_XOR_N * 32];
249 __curand_matidentity(matrix, n);
250 __curand_matcopy(matrixR, matrixA, n);
251 while (p)
252 {
253 if (p & 1)
254 {
255 __curand_matmat(matrix, matrixR, n);
256 }
257 __curand_matcopy(matrixS, matrixR, n);
258 __curand_matmat(matrixR, matrixS, n);
259 p >>= 1;
260 }
261}
262
263/* Convert unsigned int to float, use no intrinsics */
264/*QUALIFIERS*/ float __curand_uint32AsFloat(unsigned int i)
265{
266 union xa
267 {
268 float f;
269 unsigned int i;
270 } xx;
271 xx.i = i;
272 return xx.f;
273}
274
275/* Convert two unsigned ints to double, use no intrinsics */
276/*QUALIFIERS*/ double
277__curand_hilouint32AsDouble(unsigned int hi, unsigned int lo)
278{
279 union xb
280 {
281 double f;
282 unsigned int hi;
283 unsigned int lo;
284 } xx;
285 xx.hi = hi;
286 xx.lo = lo;
287 return xx.f;
288}
289
290/* Convert unsigned int to float, as efficiently as possible */
291/*QUALIFIERS*/ float __curand_uint32_as_float(unsigned int x)
292{
293# if __CUDA_ARCH__ > 0
294 return __int_as_float(x);
295# elif !defined(__CUDA_ARCH__)
296 return __curand_uint32AsFloat(x);
297# endif
298}
299
300/*
301QUALIFIERS double __curand_hilouint32_as_double(unsigned int hi, unsigned int
302lo)
303{
304#if __CUDA_ARCH__ > 0
305 return __hiloint2double(hi, lo);
306#elif !defined(__CUDA_ARCH__)
307 return hilouint32AsDouble(hi, lo);
308#endif
309}
310*/
311
312/****************************************************************************/
313/* Kernel implementations of RNGs */
314/****************************************************************************/
315
316/* Test RNG */
317
318/*QUALIFIERS*/ void curand_init(
319 unsigned long long seed,
320 unsigned long long subsequence,
321 unsigned long long offset,
322 curandStateTest_t *state)
323{
324 state->v = (unsigned int)(seed * 3) + (unsigned int)(subsequence * 31337) +
325 (unsigned int)offset;
326}
327
328/*QUALIFIERS*/ unsigned int curand(curandStateTest_t *state)
329{
330 unsigned int r = state->v++;
331 return r;
332}
333
334/*QUALIFIERS*/ void skipahead(unsigned long long n, curandStateTest_t *state)
335{
336 state->v += (unsigned int)n;
337}
338
339/* XORWOW RNG */
340
341template <typename T, int n>
342/*QUALIFIERS*/ void
344{
345 T state;
346 // Generate matrix that advances one step
347 // matrix has n * n * 32 32-bit elements
348 // solve for matrix by stepping single bit states
349 for (int i = 0; i < 32 * n; i++)
350 {
351 state.d = 0;
352 for (int j = 0; j < n; j++)
353 {
354 state.v[j] = 0;
355 }
356 state.v[i / 32] = (1 << (i & 31));
357 curand(&state);
358 for (int j = 0; j < n; j++)
359 {
360 matrix[i * n + j] = state.v[j];
361 }
362 }
363}
364
365template <typename T, int n>
366/*QUALIFIERS*/ void
367_skipahead_scratch(unsigned long long x, T *state, unsigned int *scratch)
368{
369 // unsigned int matrix[n * n * 32];
370 unsigned int *matrix = scratch;
371 // unsigned int matrixA[n * n * 32];
372 unsigned int *matrixA = scratch + (n * n * 32);
373 // unsigned int vector[n];
374 unsigned int *vector = scratch + (n * n * 32) + (n * n * 32);
375 // unsigned int result[n];
376 unsigned int *result = scratch + (n * n * 32) + (n * n * 32) + n;
377 unsigned long long p = x;
378 for (int i = 0; i < n; i++)
379 {
380 vector[i] = state->v[i];
381 }
382 int matrix_num = 0;
383 while (p && matrix_num < PRECALC_NUM_MATRICES - 1)
384 {
385 for (unsigned int t = 0; t < (p & PRECALC_BLOCK_MASK); t++)
386 {
387# ifdef __CUDA_ARCH__
389 vector, precalc_xorwow_offset_matrix[matrix_num], result, n);
390# else
391// __curand_matvec(vector,
392// precalc_xorwow_offset_matrix_host[matrix_num], result, n);
393# endif
394 __curand_veccopy(vector, result, n);
395 }
396 p >>= PRECALC_BLOCK_SIZE;
397 matrix_num++;
398 }
399 if (p)
400 {
401# ifdef __CUDA_ARCH__
403 matrix, precalc_xorwow_offset_matrix[PRECALC_NUM_MATRICES - 1], n);
405 matrixA, precalc_xorwow_offset_matrix[PRECALC_NUM_MATRICES - 1], n);
406# else
407// __curand_matcopy(matrix,
408// precalc_xorwow_offset_matrix_host[PRECALC_NUM_MATRICES - 1], n);
409// __curand_matcopy(matrixA,
410// precalc_xorwow_offset_matrix_host[PRECALC_NUM_MATRICES - 1], n);
411# endif
412 }
413 while (p)
414 {
415 for (unsigned int t = 0; t < (p & SKIPAHEAD_MASK); t++)
416 {
417 __curand_matvec(vector, matrixA, result, n);
418 __curand_veccopy(vector, result, n);
419 }
421 if (p)
422 {
423 for (int i = 0; i < SKIPAHEAD_BLOCKSIZE; i++)
424 {
425 __curand_matmat(matrix, matrixA, n);
426 __curand_matcopy(matrixA, matrix, n);
427 }
428 }
429 }
430 for (int i = 0; i < n; i++)
431 {
432 state->v[i] = vector[i];
433 }
434 state->d += 362437 * (unsigned int)x;
435}
436
437template <typename T, int n>
438/*QUALIFIERS*/ void _skipahead_sequence_scratch(
439 unsigned long long x,
440 T *state,
441 unsigned int *scratch)
442{
443 // unsigned int matrix[n * n * 32];
444 unsigned int *matrix = scratch;
445 // unsigned int matrixA[n * n * 32];
446 unsigned int *matrixA = scratch + (n * n * 32);
447 // unsigned int vector[n];
448 unsigned int *vector = scratch + (n * n * 32) + (n * n * 32);
449 // unsigned int result[n];
450 unsigned int *result = scratch + (n * n * 32) + (n * n * 32) + n;
451 unsigned long long p = x;
452 for (int i = 0; i < n; i++)
453 {
454 vector[i] = state->v[i];
455 }
456 int matrix_num = 0;
457 while (p && matrix_num < PRECALC_NUM_MATRICES - 1)
458 {
459 for (unsigned int t = 0; t < (p & PRECALC_BLOCK_MASK); t++)
460 {
461# ifdef __CUDA_ARCH__
462 __curand_matvec(vector, precalc_xorwow_matrix[matrix_num], result, n);
463# else
464// __curand_matvec(vector, precalc_xorwow_matrix_host[matrix_num],
465// result, n);
466# endif
467 __curand_veccopy(vector, result, n);
468 }
469 p >>= PRECALC_BLOCK_SIZE;
470 matrix_num++;
471 }
472 if (p)
473 {
474# ifdef __CUDA_ARCH__
479# else
480// __curand_matcopy(matrix,
481// precalc_xorwow_matrix_host[PRECALC_NUM_MATRICES - 1], n);
482// __curand_matcopy(matrixA,
483// precalc_xorwow_matrix_host[PRECALC_NUM_MATRICES - 1], n);
484# endif
485 }
486 while (p)
487 {
488 for (unsigned int t = 0; t < (p & SKIPAHEAD_MASK); t++)
489 {
490 __curand_matvec(vector, matrixA, result, n);
491 __curand_veccopy(vector, result, n);
492 }
494 if (p)
495 {
496 for (int i = 0; i < SKIPAHEAD_BLOCKSIZE; i++)
497 {
498 __curand_matmat(matrix, matrixA, n);
499 __curand_matcopy(matrixA, matrix, n);
500 }
501 }
502 }
503 for (int i = 0; i < n; i++)
504 {
505 state->v[i] = vector[i];
506 }
507 /* No update of state->d needed, guaranteed to be a multiple of 2^32 */
508}
509
521/*QUALIFIERS*/ void skipahead(unsigned long long n, curandStateXORWOW_t *state)
522{
523 unsigned int scratch[5 * 5 * 32 * 2 + 5 * 2];
524 _skipahead_scratch<curandStateXORWOW_t, 5>(n, state, (unsigned int *)scratch);
525}
526
541/*QUALIFIERS*/ void
542skipahead_sequence(unsigned long long n, curandStateXORWOW_t *state)
543{
544 unsigned int scratch[5 * 5 * 32 * 2 + 5 * 2];
546 n, state, (unsigned int *)scratch);
547}
548
549/*QUALIFIERS*/ void _curand_init_scratch(
550 unsigned long long seed,
551 unsigned long long subsequence,
552 unsigned long long offset,
553 curandStateXORWOW_t *state,
554 unsigned int *scratch)
555{
556 // Break up seed, apply salt
557 // Constants are arbitrary nonzero values
558 unsigned int s0 = ((unsigned int)seed) ^ 0xaad26b49UL;
559 unsigned int s1;
560 s1 = (unsigned int)(seed >> 32) ^ 0xf7dcefddUL;
561 // Simple multiplication to mix up bits
562 // Constants are arbitrary odd values
563 unsigned int t0 = 1099087573UL * s0;
564 unsigned int t1 = 2591861531UL * s1;
565 state->d = 6615241 + t1 + t0;
566 state->v[0] = 123456789UL + t0;
567 state->v[1] = 362436069UL ^ t0;
568 state->v[2] = 521288629UL + t1;
569 state->v[3] = 88675123UL ^ t1;
570 state->v[4] = 5783321UL + t0;
571 _skipahead_scratch<curandStateXORWOW_t, 5>(offset, state, scratch);
573 subsequence, state, scratch);
574 state->boxmuller_flag = 0;
575}
576
595/*QUALIFIERS*/ void curand_init(
596 unsigned long long seed,
597 unsigned long long subsequence,
598 unsigned long long offset,
599 curandStateXORWOW_t *state)
600{
601 unsigned int scratch[5 * 5 * 32 * 2 + 5 * 2];
603 seed, subsequence, offset, state, (unsigned int *)scratch);
604}
605
616/*QUALIFIERS*/ unsigned int curand(curandStateXORWOW_t *state)
617{
618 unsigned int t;
619 t = (state->v[0] ^ (state->v[0] >> 2));
620 state->v[0] = state->v[1];
621 state->v[1] = state->v[2];
622 state->v[2] = state->v[3];
623 state->v[3] = state->v[4];
624 state->v[4] = (state->v[4] ^ (state->v[4] << 4)) ^ (t ^ (t << 1));
625 state->d += 362437;
626 return state->v[4] + state->d;
627}
628
629// #############
630
641template <typename T>
642/*QUALIFIERS*/ void skipahead(unsigned int n, T state)
643{
644 unsigned int i_gray;
645 state->i += n;
646 /* Convert state->i to gray code */
647 i_gray = state->i ^ (state->i >> 1);
648 for (unsigned int k = 0; k < 32; k++)
649 {
650 if (i_gray & (1 << k))
651 {
652 state->x ^= state->direction_vectors[k];
653 }
654 }
655 return;
656}
657
668template <typename T>
669/*QUALIFIERS*/ void skipahead(unsigned long long n, T state)
670{
671 unsigned long long i_gray;
672 state->i += n;
673 /* Convert state->i to gray code */
674 i_gray = state->i ^ (state->i >> 1);
675 for (unsigned k = 0; k < 64; k++)
676 {
677 if (i_gray & (1ULL << k))
678 {
679 state->x ^= state->direction_vectors[k];
680 }
681 }
682 return;
683}
684
700/*in curand.h*/
701
702/*QUALIFIERS void curand_init(curandDirectionVectors32_t direction_vectors,
703 unsigned int offset,
704 curandStateSobol32_t *state)
705{
706 state->i = 0;
707 for(int i = 0; i < 32; i++) {
708 state->direction_vectors[i] = direction_vectors[i];
709 }
710 state->x = 0;
711 skipahead<curandStateSobol32_t *>(offset, state);
712}*/
713
730
731/*in curand.h*/
732/*QUALIFIERS void curand_init(curandDirectionVectors32_t direction_vectors,
733 unsigned int scramble_c,
734 unsigned int offset,
735 curandStateScrambledSobol32_t
736*state)
737{
738 state->i = 0;
739 for(int i = 0; i < 32; i++) {
740 state->direction_vectors[i] = direction_vectors[i];
741 }
742 state->x = scramble_c;
743 skipahead<curandStateScrambledSobol32_t *>(offset, state);
744}
745*/
746template <typename XT>
747/*QUALIFIERS*/ int __curand_find_trailing_zero(XT x)
748{
749# if __CUDA_ARCH__ > 0
750 unsigned long long z = x;
751 int y = __ffsll(~z) | 0x40;
752 return (y - 1) & 0x3F;
753# else
754 unsigned long long z = x;
755 int i = 1;
756 while (z & 1)
757 {
758 i++;
759 z >>= 1;
760 }
761 return i - 1;
762# endif
763}
764
780
781/*in curand.h*/
782/*QUALIFIERS*/ void curand_init(
783 curandDirectionVectors64_t direction_vectors,
784 unsigned long long offset,
786{
787 state->i = 0;
788 for (int i = 0; i < 64; i++)
789 {
790 state->direction_vectors[i] = direction_vectors[i];
791 }
792 state->x = 0;
794}
795
796template <typename PT>
797/*QUALIFIERS*/ void _skipahead_stride(int n_log2, PT state)
798{
799 /* Moving from i to i+2^n_log2 element in gray code is flipping two bits */
800 unsigned int shifted_i = state->i >> n_log2;
801 state->x ^= state->direction_vectors[n_log2 - 1];
802 state->x ^=
803 state->direction_vectors[__curand_find_trailing_zero(shifted_i) + n_log2];
804 state->i += 1 << n_log2;
805}
806
823/*in curand.h*/
824/*QUALIFIERS*/ void curand_init(
825 curandDirectionVectors64_t direction_vectors,
826 unsigned long long scramble_c,
827 unsigned long long offset,
829{
830 state->i = 0;
831 for (int i = 0; i < 64; i++)
832 {
833 state->direction_vectors[i] = direction_vectors[i];
834 }
835 state->x = scramble_c;
837}
838
849
850/*QUALIFIERS*/ unsigned int curand(curandStateSobol32_t *state)
851{
852 /* Moving from i to i+1 element in gray code is flipping one bit,
853 the trailing zero bit of i
854 */
855 unsigned int res = state->x;
856 state->x ^= state->direction_vectors[__curand_find_trailing_zero(state->i)];
857 state->i++;
858 return res;
859}
860
871
872/*QUALIFIERS*/ unsigned int curand(curandStateScrambledSobol32_t *state)
873{
874 /* Moving from i to i+1 element in gray code is flipping one bit,
875 the trailing zero bit of i
876 */
877 unsigned int res = state->x;
878 state->x ^= state->direction_vectors[__curand_find_trailing_zero(state->i)];
879 state->i++;
880 return res;
881}
882
894
895/*QUALIFIERS*/ unsigned long long curand(curandStateSobol64_t *state)
896{
897 /* Moving from i to i+1 element in gray code is flipping one bit,
898 the trailing zero bit of i
899 */
900 unsigned long long res = state->x;
901 state->x ^= state->direction_vectors[__curand_find_trailing_zero(state->i)];
902 state->i++;
903 return res;
904}
905
917
918/*QUALIFIERS*/ unsigned long long curand(curandStateScrambledSobol64_t *state)
919{
920 /* Moving from i to i+1 element in gray code is flipping one bit,
921 the trailing zero bit of i
922 */
923 unsigned long long res = state->x;
924 state->x ^= state->direction_vectors[__curand_find_trailing_zero(state->i)];
925 state->i++;
926 return res;
927}
928
929/******************************************************/
930
931/*QUALIFIERS*/ float _curand_uniform(unsigned int x)
932{
933 return x * CURAND_2POW32_INV + (CURAND_2POW32_INV / 2.0f);
934}
935
936/*QUALIFIERS*/ float _curand_uniform(unsigned long long x)
937{
938 unsigned int t;
939 t = (unsigned int)(x >> 32);
940 return t * CURAND_2POW32_INV + (CURAND_2POW32_INV / 2.0f);
941}
942
943/*QUALIFIERS*/ double _curand_uniform_double(unsigned int x)
944{
946}
947
948/*QUALIFIERS*/ double _curand_uniform_double(unsigned long long x)
949{
950 return (x >> 11) * CURAND_2POW53_INV_DOUBLE +
952}
953
954/*QUALIFIERS*/ double _curand_uniform_double_hq(unsigned int x, unsigned int y)
955{
956 unsigned long long z =
957 (unsigned long long)x ^ ((unsigned long long)y << (53 - 32));
959}
960
961/*QUALIFIERS*/ double _curand_uniform_double_64(unsigned long long x)
962{
963 unsigned long long z;
964 z = (unsigned long long)x >> (64 - 53);
966}
967
968/*QUALIFIERS*/ float curand_uniform(curandStateTest_t *state)
969{
970 return _curand_uniform(curand(state));
971}
972
973/*QUALIFIERS*/ double curand_uniform_double(curandStateTest_t *state)
974{
975 return _curand_uniform_double(curand(state));
976}
977
994/*QUALIFIERS*/ float curand_uniform(curandStateXORWOW_t *state)
995{
996 return _curand_uniform(curand(state));
997}
998
1015/*QUALIFIERS*/ double curand_uniform_double(curandStateXORWOW_t *state)
1016{
1017 unsigned int x, y;
1018 x = curand(state);
1019 y = curand(state);
1020 return _curand_uniform_double_hq(x, y);
1021}
1022
1037/*QUALIFIERS*/ float curand_uniform(curandStateSobol32_t *state)
1038{
1039 return _curand_uniform(curand(state));
1040}
1041
1057/*QUALIFIERS*/ double curand_uniform_double(curandStateSobol32_t *state)
1058{
1059 return _curand_uniform_double(curand(state));
1060}
1061
1077{
1078 return _curand_uniform(curand(state));
1079}
1080
1097/*QUALIFIERS*/ double
1102
1116/*QUALIFIERS*/ float curand_uniform(curandStateSobol64_t *state)
1117{
1118 return _curand_uniform(curand(state));
1119}
1120
1136/*QUALIFIERS*/ double curand_uniform_double(curandStateSobol64_t *state)
1137{
1138 return _curand_uniform_double(curand(state));
1139}
1140
1156{
1157 return _curand_uniform(curand(state));
1158}
1159
1176/*QUALIFIERS*/ double
1181
1182#endif // !defined(CURAND_KERNEL_H_)
double _curand_uniform_double(unsigned int x)
Definition curand_kernel.h:943
static unsigned int precalc_xorwow_matrix[8][2]
Definition curand_kernel.h:24
void __curand_matidentity(unsigned int *matrix, int n)
Definition curand_kernel.h:184
double _curand_uniform_double_hq(unsigned int x, unsigned int y)
Definition curand_kernel.h:954
#define PRECALC_BLOCK_SIZE
Definition curand_kernel.h:20
double curand_uniform_double(curandStateTest_t *state)
Definition curand_kernel.h:973
struct curandStateXORWOW curandState_t
Default RNG.
Definition curand_kernel.h:146
struct curandStateXORWOW curandState
Definition curand_kernel.h:147
#define SKIPAHEAD_BLOCKSIZE
Definition curand_kernel.h:9
int __curand_find_trailing_zero(XT x)
Initialize Sobol32 state.
Definition curand_kernel.h:747
float _curand_uniform(unsigned int x)
Definition curand_kernel.h:931
#define CURAND_2POW53_INV_DOUBLE
Definition curand_kernel.h:13
void _skipahead_sequence_scratch(unsigned long long x, T *state, unsigned int *scratch)
Definition curand_kernel.h:438
void __curand_veccopy(unsigned int *vector, unsigned int *vectorA, int n)
Definition curand_kernel.h:222
#define MAX_XOR_N
Definition curand_kernel.h:8
void __curand_matmat(unsigned int *matrixA, unsigned int *matrixB, int n)
Definition curand_kernel.h:207
#define PRECALC_BLOCK_MASK
Definition curand_kernel.h:21
double _curand_uniform_double_64(unsigned long long x)
Definition curand_kernel.h:961
struct curandStateXORWOW curandStateXORWOW_t
CURAND XORWOW state.
Definition curand_kernel.h:63
void __curand_generate_skipahead_matrix_xor(unsigned int matrix[])
Definition curand_kernel.h:343
void _curand_init_scratch(unsigned long long seed, unsigned long long subsequence, unsigned long long offset, curandStateXORWOW_t *state, unsigned int *scratch)
Definition curand_kernel.h:549
double __curand_hilouint32AsDouble(unsigned int hi, unsigned int lo)
Definition curand_kernel.h:277
#define CURAND_2POW32_INV_DOUBLE
Definition curand_kernel.h:12
struct curandStateScrambledSobol64 curandStateScrambledSobol64_t
CURAND Scrambled Sobol64 state.
Definition curand_kernel.h:141
unsigned int curand(curandStateTest_t *state)
Definition curand_kernel.h:328
void __curand_matpow(unsigned int *matrix, unsigned int *matrixA, unsigned long long p, int n)
Definition curand_kernel.h:241
void skipahead(unsigned long long n, curandStateTest_t *state)
Definition curand_kernel.h:334
struct curandStateTest curandStateTest_t
Definition curand_kernel.h:41
void _skipahead_scratch(unsigned long long x, T *state, unsigned int *scratch)
Definition curand_kernel.h:367
void skipahead_sequence(unsigned long long n, curandStateXORWOW_t *state)
Update XORWOW state to skip ahead n subsequences.
Definition curand_kernel.h:542
void _skipahead_stride(int n_log2, PT state)
Definition curand_kernel.h:797
void __curand_matvec(unsigned int *vector, unsigned int *matrix, unsigned int *result, int n)
Definition curand_kernel.h:158
float curand_uniform(curandStateTest_t *state)
Definition curand_kernel.h:968
struct curandStateSobol64 curandStateSobol64_t
CURAND Sobol64 state.
Definition curand_kernel.h:124
struct curandStateSobol32 curandStateSobol32_t
CURAND Sobol32 state.
Definition curand_kernel.h:90
#define CURAND_2POW32_INV
Definition curand_kernel.h:11
#define PRECALC_NUM_MATRICES
Definition curand_kernel.h:19
struct curandStateScrambledSobol32 curandStateScrambledSobol32_t
CURAND Scrambled Sobol32 state.
Definition curand_kernel.h:107
void curand_init(unsigned long long seed, unsigned long long subsequence, unsigned long long offset, curandStateTest_t *state)
Definition curand_kernel.h:318
float __curand_uint32_as_float(unsigned int x)
Definition curand_kernel.h:291
void __curand_matcopy(unsigned int *matrix, unsigned int *matrixA, int n)
Definition curand_kernel.h:232
float __curand_uint32AsFloat(unsigned int i)
Definition curand_kernel.h:264
#define SKIPAHEAD_MASK
Definition curand_kernel.h:10
#define T
Definition exp2f.c:24
unsigned long long curandDirectionVectors64_t[64]
CURAND array of 64-bit direction vectors.
Definition curand.h:145
Definition int.py:1
Definition curand_kernel.h:99
unsigned int x
Definition curand_kernel.h:100
unsigned int c
Definition curand_kernel.h:100
unsigned int i
Definition curand_kernel.h:100
unsigned int direction_vectors[32]
Definition curand_kernel.h:101
Definition curand_kernel.h:133
unsigned long long i
Definition curand_kernel.h:134
unsigned long long x
Definition curand_kernel.h:134
unsigned long long c
Definition curand_kernel.h:134
unsigned long long direction_vectors[64]
Definition curand_kernel.h:135
Definition curand_kernel.h:82
unsigned int direction_vectors[32]
Definition curand_kernel.h:84
unsigned int x
Definition curand_kernel.h:83
unsigned int i
Definition curand_kernel.h:83
Definition curand_kernel.h:116
unsigned long long i
Definition curand_kernel.h:117
unsigned long long direction_vectors[64]
Definition curand_kernel.h:118
unsigned long long x
Definition curand_kernel.h:117
Definition curand_kernel.h:37
unsigned int v
Definition curand_kernel.h:38
Definition curand_kernel.h:67
double boxmuller_extra_double
Definition curand_kernel.h:71
int boxmuller_flag
Definition curand_kernel.h:69
unsigned int d
Definition curand_kernel.h:68
unsigned int v[5]
Definition curand_kernel.h:68
float boxmuller_extra
Definition curand_kernel.h:70