vSMC  v3.0.0
Scalable Monte Carlo
threefry.h
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rngc/threefry.h
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2016, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_RNGC_THREEFRY_H
33 #define VSMC_RNGC_THREEFRY_H
34 
35 #include <vsmc/internal/config.h>
36 
39 typedef struct {
40  uint32_t v[2];
42 
45 typedef struct {
46  uint32_t v[4];
48 
51 typedef struct {
52  uint64_t v[2];
54 
57 typedef struct {
58  uint64_t v[4];
60 
63 typedef struct {
64  uint32_t v[2];
66 
69 typedef struct {
70  uint32_t v[4];
72 
75 typedef struct {
76  uint64_t v[2];
78 
81 typedef struct {
82  uint64_t v[4];
84 
85 typedef struct {
86  uint32_t v[3];
88 
89 typedef struct {
90  uint32_t v[5];
92 
93 typedef struct {
94  uint64_t v[3];
96 
97 typedef struct {
98  uint64_t v[5];
100 
103 typedef struct {
109 
112 typedef struct {
118 
121 typedef struct {
127 
130 typedef struct {
136 
138 {
139  if (++ctr->v[0] != 0)
140  return;
141  if (++ctr->v[1] != 0)
142  return;
143 }
144 
146 {
147  if (++ctr->v[0] != 0)
148  return;
149  if (++ctr->v[1] != 0)
150  return;
151  if (++ctr->v[2] != 0)
152  return;
153  if (++ctr->v[3] != 0)
154  return;
155 }
156 
158 {
159  if (++ctr->v[0] != 0)
160  return;
161  if (++ctr->v[1] != 0)
162  return;
163 }
164 
166 {
167  if (++ctr->v[0] != 0)
168  return;
169  if (++ctr->v[1] != 0)
170  return;
171  if (++ctr->v[2] != 0)
172  return;
173  if (++ctr->v[3] != 0)
174  return;
175 }
176 
177 static inline void vsmc_threefry2x32_initpar(
179 {
180  par->v[0] = key->v[0];
181  par->v[1] = key->v[1];
182 
183  par->v[2] = UINT32_C(0x1BD11BDA);
184  par->v[2] ^= par->v[0];
185  par->v[2] ^= par->v[1];
186 }
187 
188 static inline void vsmc_threefry4x32_initpar(
190 {
191  par->v[0] = key->v[0];
192  par->v[1] = key->v[1];
193  par->v[2] = key->v[2];
194  par->v[3] = key->v[3];
195 
196  par->v[4] = UINT32_C(0x1BD11BDA);
197  par->v[4] ^= par->v[0];
198  par->v[4] ^= par->v[1];
199  par->v[4] ^= par->v[2];
200  par->v[4] ^= par->v[3];
201 }
202 
203 static inline void vsmc_threefry2x64_initpar(
205 {
206  par->v[0] = key->v[0];
207  par->v[1] = key->v[1];
208 
209  par->v[2] = UINT64_C(0x1BD11BDAA9FC1A22);
210  par->v[2] ^= par->v[0];
211  par->v[2] ^= par->v[1];
212 }
213 
214 static inline void vsmc_threefry4x64_initpar(
216 {
217  par->v[0] = key->v[0];
218  par->v[1] = key->v[1];
219  par->v[2] = key->v[2];
220  par->v[3] = key->v[3];
221 
222  par->v[4] = UINT64_C(0x1BD11BDAA9FC1A22);
223  par->v[4] ^= par->v[0];
224  par->v[4] ^= par->v[1];
225  par->v[4] ^= par->v[2];
226  par->v[4] ^= par->v[3];
227 }
228 
229 static inline void vsmc_threefry2x32_rotate(
231 {
232  state->v[0] += state->v[1];
233  state->v[1] = ((state->v[1]) << r) | ((state->v[1]) >> (32 - r));
234  state->v[1] ^= state->v[0];
235 }
236 
237 static inline void vsmc_threefry4x32_rotate(
238  vsmc_threefry4x32_ctr_t *state, uint32_t r0, uint32_t r2, int i0, int i2)
239 {
240  state->v[0] += state->v[i0];
241  state->v[i0] = ((state->v[i0]) << r0) | ((state->v[i0]) >> (32 - r0));
242  state->v[i0] ^= state->v[0];
243 
244  state->v[2] += state->v[i2];
245  state->v[i2] = ((state->v[i2]) << r2) | ((state->v[i2]) >> (32 - r2));
246  state->v[i2] ^= state->v[2];
247 }
248 
249 static inline void vsmc_threefry2x64_rotate(
251 {
252  state->v[0] += state->v[1];
253  state->v[1] = ((state->v[1]) << r) | ((state->v[1]) >> (64 - r));
254  state->v[1] ^= state->v[0];
255 }
256 
257 static inline void vsmc_threefry4x64_rotate(
258  vsmc_threefry4x64_ctr_t *state, uint64_t r0, uint64_t r2, int i0, int i2)
259 {
260  state->v[0] += state->v[i0];
261  state->v[i0] = ((state->v[i0]) << r0) | ((state->v[i0]) >> (64 - r0));
262  state->v[i0] ^= state->v[0];
263 
264  state->v[2] += state->v[i2];
265  state->v[i2] = ((state->v[i2]) << r2) | ((state->v[i2]) >> (64 - r2));
266  state->v[i2] ^= state->v[2];
267 }
268 
270  const vsmc_threefry2x32_par_t *par, uint32_t inc, int i0, int i1)
271 {
272  state->v[0] += par->v[i0];
273  state->v[1] += par->v[i1];
274  state->v[1] += inc;
275 }
276 
278  const vsmc_threefry4x32_par_t *par, uint32_t inc, int i0, int i1, int i2,
279  int i3)
280 {
281  state->v[0] += par->v[i0];
282  state->v[1] += par->v[i1];
283  state->v[2] += par->v[i2];
284  state->v[3] += par->v[i3];
285  state->v[3] += inc;
286 }
287 
289  const vsmc_threefry2x64_par_t *par, uint64_t inc, int i0, int i1)
290 {
291  state->v[0] += par->v[i0];
292  state->v[1] += par->v[i1];
293  state->v[1] += inc;
294 }
295 
297  const vsmc_threefry4x64_par_t *par, uint64_t inc, int i0, int i1, int i2,
298  int i3)
299 {
300  state->v[0] += par->v[i0];
301  state->v[1] += par->v[i1];
302  state->v[2] += par->v[i2];
303  state->v[3] += par->v[i3];
304  state->v[3] += inc;
305 }
306 
309 static inline void vsmc_threefry2x32_gen(const vsmc_threefry2x32_ctr_t *ctr,
311 {
312  *state = *ctr;
314  vsmc_threefry2x32_initpar(key, &par);
315 
316  vsmc_threefry2x32_insertkey(state, &par, 0, 0, 1); // N = 0
317  vsmc_threefry2x32_rotate(state, 13); // N = 1
318  vsmc_threefry2x32_rotate(state, 15); // N = 2
319  vsmc_threefry2x32_rotate(state, 26); // N = 3
320  vsmc_threefry2x32_rotate(state, 6); // N = 4
321  vsmc_threefry2x32_insertkey(state, &par, 1, 1, 2); // N = 4
322  vsmc_threefry2x32_rotate(state, 17); // N = 5
323  vsmc_threefry2x32_rotate(state, 29); // N = 6
324  vsmc_threefry2x32_rotate(state, 16); // N = 7
325  vsmc_threefry2x32_rotate(state, 24); // N = 8
326  vsmc_threefry2x32_insertkey(state, &par, 2, 2, 0); // N = 8
327  vsmc_threefry2x32_rotate(state, 13); // N = 9
328  vsmc_threefry2x32_rotate(state, 15); // N = 10
329  vsmc_threefry2x32_rotate(state, 26); // N = 11
330  vsmc_threefry2x32_rotate(state, 6); // N = 12
331  vsmc_threefry2x32_insertkey(state, &par, 3, 0, 1); // N = 12
332  vsmc_threefry2x32_rotate(state, 17); // N = 13
333  vsmc_threefry2x32_rotate(state, 29); // N = 14
334  vsmc_threefry2x32_rotate(state, 16); // N = 15
335  vsmc_threefry2x32_rotate(state, 24); // N = 16
336  vsmc_threefry2x32_insertkey(state, &par, 4, 1, 2); // N = 16
337  vsmc_threefry2x32_rotate(state, 13); // N = 17
338  vsmc_threefry2x32_rotate(state, 15); // N = 18
339  vsmc_threefry2x32_rotate(state, 26); // N = 19
340  vsmc_threefry2x32_rotate(state, 6); // N = 20
341  vsmc_threefry2x32_insertkey(state, &par, 5, 2, 0); // N = 20
342 }
343 
346 static inline void vsmc_threefry4x32_gen(const vsmc_threefry4x32_ctr_t *ctr,
348 {
349  *state = *ctr;
351  vsmc_threefry4x32_initpar(key, &par);
352 
353  vsmc_threefry4x32_insertkey(state, &par, 0, 0, 1, 2, 3); // N = 0
354  vsmc_threefry4x32_rotate(state, 10, 26, 1, 3); // N = 1
355  vsmc_threefry4x32_rotate(state, 11, 21, 3, 1); // N = 2
356  vsmc_threefry4x32_rotate(state, 13, 27, 1, 3); // N = 3
357  vsmc_threefry4x32_rotate(state, 23, 5, 3, 1); // N = 4
358  vsmc_threefry4x32_insertkey(state, &par, 1, 1, 2, 3, 4); // N = 4
359  vsmc_threefry4x32_rotate(state, 6, 20, 1, 3); // N = 5
360  vsmc_threefry4x32_rotate(state, 17, 11, 3, 1); // N = 6
361  vsmc_threefry4x32_rotate(state, 25, 10, 1, 3); // N = 7
362  vsmc_threefry4x32_rotate(state, 18, 20, 3, 1); // N = 8
363  vsmc_threefry4x32_insertkey(state, &par, 2, 2, 3, 4, 0); // N = 8
364  vsmc_threefry4x32_rotate(state, 10, 26, 1, 3); // N = 9
365  vsmc_threefry4x32_rotate(state, 11, 21, 3, 1); // N = 10
366  vsmc_threefry4x32_rotate(state, 13, 27, 1, 3); // N = 11
367  vsmc_threefry4x32_rotate(state, 23, 5, 3, 1); // N = 12
368  vsmc_threefry4x32_insertkey(state, &par, 3, 3, 4, 0, 1); // N = 12
369  vsmc_threefry4x32_rotate(state, 6, 20, 1, 3); // N = 13
370  vsmc_threefry4x32_rotate(state, 17, 11, 3, 1); // N = 14
371  vsmc_threefry4x32_rotate(state, 25, 10, 1, 3); // N = 15
372  vsmc_threefry4x32_rotate(state, 18, 20, 3, 1); // N = 16
373  vsmc_threefry4x32_insertkey(state, &par, 4, 4, 0, 1, 2); // N = 16
374  vsmc_threefry4x32_rotate(state, 10, 26, 1, 3); // N = 17
375  vsmc_threefry4x32_rotate(state, 11, 21, 3, 1); // N = 18
376  vsmc_threefry4x32_rotate(state, 13, 27, 1, 3); // N = 19
377  vsmc_threefry4x32_rotate(state, 23, 5, 3, 1); // N = 20
378  vsmc_threefry4x32_insertkey(state, &par, 5, 0, 1, 2, 3); // N = 20
379 }
380 
383 static inline void vsmc_threefry2x64_gen(const vsmc_threefry2x64_ctr_t *ctr,
385 {
386  *state = *ctr;
388  vsmc_threefry2x64_initpar(key, &par);
389 
390  vsmc_threefry2x64_insertkey(state, &par, 0, 0, 1); // N = 0
391  vsmc_threefry2x64_rotate(state, 16); // N = 1
392  vsmc_threefry2x64_rotate(state, 42); // N = 2
393  vsmc_threefry2x64_rotate(state, 12); // N = 3
394  vsmc_threefry2x64_rotate(state, 31); // N = 4
395  vsmc_threefry2x64_insertkey(state, &par, 1, 1, 2); // N = 4
396  vsmc_threefry2x64_rotate(state, 16); // N = 5
397  vsmc_threefry2x64_rotate(state, 32); // N = 6
398  vsmc_threefry2x64_rotate(state, 24); // N = 7
399  vsmc_threefry2x64_rotate(state, 21); // N = 8
400  vsmc_threefry2x64_insertkey(state, &par, 2, 2, 0); // N = 8
401  vsmc_threefry2x64_rotate(state, 16); // N = 9
402  vsmc_threefry2x64_rotate(state, 42); // N = 10
403  vsmc_threefry2x64_rotate(state, 12); // N = 11
404  vsmc_threefry2x64_rotate(state, 31); // N = 12
405  vsmc_threefry2x64_insertkey(state, &par, 3, 0, 1); // N = 12
406  vsmc_threefry2x64_rotate(state, 16); // N = 13
407  vsmc_threefry2x64_rotate(state, 32); // N = 14
408  vsmc_threefry2x64_rotate(state, 24); // N = 15
409  vsmc_threefry2x64_rotate(state, 21); // N = 16
410  vsmc_threefry2x64_insertkey(state, &par, 4, 1, 2); // N = 16
411  vsmc_threefry2x64_rotate(state, 16); // N = 17
412  vsmc_threefry2x64_rotate(state, 42); // N = 18
413  vsmc_threefry2x64_rotate(state, 12); // N = 19
414  vsmc_threefry2x64_rotate(state, 31); // N = 20
415  vsmc_threefry2x64_insertkey(state, &par, 5, 2, 0); // N = 20
416 }
417 
420 static inline void vsmc_threefry4x64_gen(const vsmc_threefry4x64_ctr_t *ctr,
422 {
423  *state = *ctr;
425  vsmc_threefry4x64_initpar(key, &par);
426 
427  vsmc_threefry4x64_insertkey(state, &par, 0, 0, 1, 2, 3); // N = 0
428  vsmc_threefry4x64_rotate(state, 14, 16, 1, 3); // N = 1
429  vsmc_threefry4x64_rotate(state, 52, 57, 3, 1); // N = 2
430  vsmc_threefry4x64_rotate(state, 23, 40, 1, 3); // N = 3
431  vsmc_threefry4x64_rotate(state, 5, 37, 3, 1); // N = 4
432  vsmc_threefry4x64_insertkey(state, &par, 1, 1, 2, 3, 4); // N = 4
433  vsmc_threefry4x64_rotate(state, 25, 33, 1, 3); // N = 5
434  vsmc_threefry4x64_rotate(state, 46, 12, 3, 1); // N = 6
435  vsmc_threefry4x64_rotate(state, 58, 22, 1, 3); // N = 7
436  vsmc_threefry4x64_rotate(state, 32, 32, 3, 1); // N = 8
437  vsmc_threefry4x64_insertkey(state, &par, 2, 2, 3, 4, 0); // N = 8
438  vsmc_threefry4x64_rotate(state, 14, 16, 1, 3); // N = 9
439  vsmc_threefry4x64_rotate(state, 52, 57, 3, 1); // N = 10
440  vsmc_threefry4x64_rotate(state, 23, 40, 1, 3); // N = 11
441  vsmc_threefry4x64_rotate(state, 5, 37, 3, 1); // N = 12
442  vsmc_threefry4x64_insertkey(state, &par, 3, 3, 4, 0, 1); // N = 12
443  vsmc_threefry4x64_rotate(state, 25, 33, 1, 3); // N = 13
444  vsmc_threefry4x64_rotate(state, 46, 12, 3, 1); // N = 14
445  vsmc_threefry4x64_rotate(state, 58, 22, 1, 3); // N = 15
446  vsmc_threefry4x64_rotate(state, 32, 32, 3, 1); // N = 16
447  vsmc_threefry4x64_insertkey(state, &par, 4, 4, 0, 1, 2); // N = 16
448  vsmc_threefry4x64_rotate(state, 14, 16, 1, 3); // N = 17
449  vsmc_threefry4x64_rotate(state, 52, 57, 3, 1); // N = 18
450  vsmc_threefry4x64_rotate(state, 23, 40, 1, 3); // N = 19
451  vsmc_threefry4x64_rotate(state, 5, 37, 3, 1); // N = 20
452  vsmc_threefry4x64_insertkey(state, &par, 5, 0, 1, 2, 3); // N = 20
453 }
454 
457 static inline void vsmc_threefry2x32_init(
458  vsmc_threefry2x32 *rng, uint32_t seed)
459 {
460  rng->ctr.v[0] = 0;
461  rng->ctr.v[1] = 0;
462  rng->key.v[0] = seed;
463  rng->key.v[1] = 0;
464  rng->index = 2;
465 }
466 
469 static inline void vsmc_threefry4x32_init(
470  vsmc_threefry4x32 *rng, uint32_t seed)
471 {
472  rng->ctr.v[0] = 0;
473  rng->ctr.v[1] = 0;
474  rng->ctr.v[2] = 0;
475  rng->ctr.v[3] = 0;
476  rng->key.v[0] = seed;
477  rng->key.v[1] = 0;
478  rng->key.v[2] = 0;
479  rng->key.v[3] = 0;
480  rng->index = 4;
481 }
482 
485 static inline void vsmc_threefry2x64_init(
486  vsmc_threefry2x64 *rng, uint64_t seed)
487 {
488  rng->ctr.v[0] = 0;
489  rng->ctr.v[1] = 0;
490  rng->key.v[0] = seed;
491  rng->key.v[1] = 0;
492  rng->index = 2;
493 }
494 
497 static inline void vsmc_threefry4x64_init(
498  vsmc_threefry4x64 *rng, uint64_t seed)
499 {
500  rng->ctr.v[0] = 0;
501  rng->ctr.v[1] = 0;
502  rng->ctr.v[2] = 0;
503  rng->ctr.v[3] = 0;
504  rng->key.v[0] = seed;
505  rng->key.v[1] = 0;
506  rng->key.v[2] = 0;
507  rng->key.v[3] = 0;
508  rng->index = 4;
509 }
510 
514 {
515  if (rng->index == 2) {
516  vsmc_threefry2x32_inc(&rng->ctr);
517  vsmc_threefry2x32_gen(&rng->ctr, &rng->key, &rng->state);
518  rng->index = 0;
519  }
520 
521  return rng->state.v[rng->index++];
522 }
523 
527 {
528  if (rng->index == 4) {
529  vsmc_threefry4x32_inc(&rng->ctr);
530  vsmc_threefry4x32_gen(&rng->ctr, &rng->key, &rng->state);
531  rng->index = 0;
532  }
533 
534  return rng->state.v[rng->index++];
535 }
536 
540 {
541  if (rng->index == 2) {
542  vsmc_threefry2x64_inc(&rng->ctr);
543  vsmc_threefry2x64_gen(&rng->ctr, &rng->key, &rng->state);
544  rng->index = 0;
545  }
546 
547  return rng->state.v[rng->index++];
548 }
549 
553 {
554  if (rng->index == 4) {
555  vsmc_threefry4x64_inc(&rng->ctr);
556  vsmc_threefry4x64_gen(&rng->ctr, &rng->key, &rng->state);
557  rng->index = 0;
558  }
559 
560  return rng->state.v[rng->index++];
561 }
562 
563 #endif // VSMC_RNGC_THREEFRY_H
#define UINT64_C(x)
Definition: opencl.h:44
static void vsmc_threefry4x32_initpar(const vsmc_threefry4x32_key_t *key, vsmc_threefry4x32_par_t *par)
Definition: threefry.h:188
static void vsmc_threefry4x32_rotate(vsmc_threefry4x32_ctr_t *state, uint32_t r0, uint32_t r2, int i0, int i2)
Definition: threefry.h:237
static void vsmc_threefry2x32_init(vsmc_threefry2x32 *rng, uint32_t seed)
Initialize Threefry2x32 RNG state.
Definition: threefry.h:457
static void vsmc_threefry4x32_inc(vsmc_threefry4x32_ctr_t *ctr)
Definition: threefry.h:145
uint32_t index
Definition: threefry.h:107
uint uint32_t
Definition: opencl.h:41
static void vsmc_threefry2x64_inc(vsmc_threefry2x64_ctr_t *ctr)
Definition: threefry.h:157
ulong uint64_t
Definition: opencl.h:42
vsmc_threefry2x32_key_t key
Definition: threefry.h:106
static void vsmc_threefry4x64_init(vsmc_threefry4x64 *rng, uint64_t seed)
Initialize Threefry4x64 RNG state.
Definition: threefry.h:497
uint64_t index
Definition: threefry.h:125
uint64_t index
Definition: threefry.h:134
Threefry2x64 counter type.
Definition: threefry.h:51
static void vsmc_threefry2x64_init(vsmc_threefry2x64 *rng, uint64_t seed)
Initialize Threefry2x64 RNG state.
Definition: threefry.h:485
static void vsmc_threefry2x32_gen(const vsmc_threefry2x32_ctr_t *ctr, const vsmc_threefry2x32_key_t *key, vsmc_threefry2x32_ctr_t *state)
Generate Threefry2x32 RNG state.
Definition: threefry.h:309
vsmc_threefry2x64_ctr_t ctr
Definition: threefry.h:123
static void vsmc_threefry4x64_insertkey(vsmc_threefry4x64_ctr_t *state, const vsmc_threefry4x64_par_t *par, uint64_t inc, int i0, int i1, int i2, int i3)
Definition: threefry.h:296
Threefry4x64 counter type.
Definition: threefry.h:57
static void vsmc_threefry2x64_rotate(vsmc_threefry2x64_ctr_t *state, uint64_t r)
Definition: threefry.h:249
static void vsmc_threefry4x64_initpar(const vsmc_threefry4x64_key_t *key, vsmc_threefry4x64_par_t *par)
Definition: threefry.h:214
static void vsmc_threefry2x32_initpar(const vsmc_threefry2x32_key_t *key, vsmc_threefry2x32_par_t *par)
Definition: threefry.h:177
vsmc_threefry4x32_ctr_t state
Definition: threefry.h:113
vsmc_threefry4x32_key_t key
Definition: threefry.h:115
static void vsmc_threefry4x64_gen(const vsmc_threefry4x64_ctr_t *ctr, const vsmc_threefry4x64_key_t *key, vsmc_threefry4x64_ctr_t *state)
Generate Threefry4x64 RNG state.
Definition: threefry.h:420
static void vsmc_threefry4x32_init(vsmc_threefry4x32 *rng, uint32_t seed)
Initialize Threefry4x32 RNG state.
Definition: threefry.h:469
vsmc_threefry4x64_key_t key
Definition: threefry.h:133
static void vsmc_threefry4x32_insertkey(vsmc_threefry4x32_ctr_t *state, const vsmc_threefry4x32_par_t *par, uint32_t inc, int i0, int i1, int i2, int i3)
Definition: threefry.h:277
vsmc_threefry2x32_ctr_t state
Definition: threefry.h:104
Threefry2x32 counter type.
Definition: threefry.h:39
Threefry4x32 key type.
Definition: threefry.h:69
vsmc_threefry4x64_ctr_t state
Definition: threefry.h:131
static uint64_t vsmc_threefry2x64_rand(vsmc_threefry2x64 *rng)
Generate random 64-bit integers from Threefry2x64 RNG.
Definition: threefry.h:539
Threefry2x32 RNG state structure.
Definition: threefry.h:103
Threefry2x64 RNG state structure.
Definition: threefry.h:121
static uint32_t vsmc_threefry2x32_rand(vsmc_threefry2x32 *rng)
Generate random 32-bit integers from Threefry2x32 RNG.
Definition: threefry.h:513
Threefry4x32 counter type.
Definition: threefry.h:45
vsmc_threefry4x32_ctr_t ctr
Definition: threefry.h:114
static void vsmc_threefry2x32_insertkey(vsmc_threefry2x32_ctr_t *state, const vsmc_threefry2x32_par_t *par, uint32_t inc, int i0, int i1)
Definition: threefry.h:269
Threefry4x32 RNG state structure.
Definition: threefry.h:112
Threefry4x64 RNG state structure.
Definition: threefry.h:130
static void vsmc_threefry2x64_gen(const vsmc_threefry2x64_ctr_t *ctr, const vsmc_threefry2x64_key_t *key, vsmc_threefry2x64_ctr_t *state)
Generate Threefry2x64 RNG state.
Definition: threefry.h:383
Threefry2x32 key type.
Definition: threefry.h:63
static void vsmc_threefry2x64_insertkey(vsmc_threefry2x64_ctr_t *state, const vsmc_threefry2x64_par_t *par, uint64_t inc, int i0, int i1)
Definition: threefry.h:288
vsmc_threefry2x64_key_t key
Definition: threefry.h:124
static uint64_t vsmc_threefry4x64_rand(vsmc_threefry4x64 *rng)
Generate random 64-bit integers from Threefry4x64 RNG.
Definition: threefry.h:552
static void vsmc_threefry4x64_rotate(vsmc_threefry4x64_ctr_t *state, uint64_t r0, uint64_t r2, int i0, int i2)
Definition: threefry.h:257
uint32_t index
Definition: threefry.h:116
static void vsmc_threefry2x64_initpar(const vsmc_threefry2x64_key_t *key, vsmc_threefry2x64_par_t *par)
Definition: threefry.h:203
vsmc_threefry4x64_ctr_t ctr
Definition: threefry.h:132
Threefry4x64 key type.
Definition: threefry.h:81
static uint32_t vsmc_threefry4x32_rand(vsmc_threefry4x32 *rng)
Generate random 32-bit integers from Threefry4x32 RNG.
Definition: threefry.h:526
#define UINT32_C(x)
Definition: opencl.h:43
static void vsmc_threefry4x32_gen(const vsmc_threefry4x32_ctr_t *ctr, const vsmc_threefry4x32_key_t *key, vsmc_threefry4x32_ctr_t *state)
Generate Threefry4x32 RNG state.
Definition: threefry.h:346
static void vsmc_threefry2x32_rotate(vsmc_threefry2x32_ctr_t *state, uint32_t r)
Definition: threefry.h:229
vsmc_threefry2x64_ctr_t state
Definition: threefry.h:122
Threefry2x64 key type.
Definition: threefry.h:75
static void vsmc_threefry4x64_inc(vsmc_threefry4x64_ctr_t *ctr)
Definition: threefry.h:165
vsmc_threefry2x32_ctr_t ctr
Definition: threefry.h:105
static void vsmc_threefry2x32_inc(vsmc_threefry2x32_ctr_t *ctr)
Definition: threefry.h:137