-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxorshift.cu
83 lines (75 loc) · 2.74 KB
/
xorshift.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <cmath>
#define Norum 0.0000000001f*2.32830643653869628906f
#define nLoopRndm (32)
__device__ __host__ __forceinline__
void fxorshift128(unsigned int& seed,
int n,
float* a)
{
unsigned int x,y,z,w,t;
seed=seed*2357+123456789U;
//1812433253 = 0x6C078965h;
x=seed=1812433253U*(seed^(seed>>30))+1;
y=seed=1812433253U*(seed^(seed>>30))+2;
z=seed=1812433253U*(seed^(seed>>30))+3;
w=seed=1812433253U*(seed^(seed>>30))+4;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t^t>>8;
t=x^x<<11;x=y;y=z;z=w;w^=w>>19^t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