Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/omega/libraries/xorwow_mix.om # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / omega / libraries / xorwow_mix.om` 229 lines · 4006 bytes Raw Blame History 1 note SPDX-License-Identifier Apache-2.0 WITH LLVM-exception 2 note L441 host check. XORWOW is Marsaglia, J. Stat. Soft. 8(14), 2003, page 5, from the published state 3 note Metric: Berlekamp-Massey linear complexity over GF(2) of each output bit, first 1000 outputs 4 note An ideal bit scores about 500. Raw XORWOW bit 0 scores 162 and bit 1 scores 323 5 note The fold mix o xor (o shr 16) is a bijection on 32 bits and lifts every bit to about 500 6 note Expected values are the Wolfram receipts in evidence/xorwow-mix-`20261109`/README.md 7 note Prints one line of 32 scores for raw and one for fold. Exit 0 only if all checks hold 8 note Not curand: the fold changes every output word. Not the GPU 9 global xmst ulong 6 10 global xmow ulong 1000 11 global xmsq ulong 1000 12 global xmcc ulong 1001 13 global xmbb ulong 1001 14 global xmtt ulong 1001 15 global xmob uchar 24 16 global xmlc ulong 64 17 text xmlraw "raw " 18 text xmlfold "fold" 19 text xmlnl "\n" 20 fn xmixmask x ulong to ulong 21 ret and x `4294967295` 22 end 23 fn xmixinit to void 24 put xmst 0 ulong `123456789` 25 put xmst 1 ulong `362436069` 26 put xmst 2 ulong `521288629` 27 put xmst 3 ulong `88675123` 28 put xmst 4 ulong `5783321` 29 put xmst 5 ulong `6615241` 30 end 31 fn xmixstep to ulong 32 t = xmixmask xor get xmst 0 shr get xmst 0 2 33 old4 = get xmst 4 34 put xmst 0 get xmst 1 35 put xmst 1 get xmst 2 36 put xmst 2 get xmst 3 37 put xmst 3 old4 38 n4 = xmixmask xor xor old4 shl old4 4 xor t shl t 1 39 put xmst 4 n4 40 d = xmixmask add get xmst 5 362437 41 put xmst 5 d 42 ret xmixmask add n4 d 43 end 44 fn xmixfold o ulong to ulong 45 ret xor o shr o 16 46 end 47 fn xmixbits k ulong fold ulong to void 48 i = ulong 0 49 while lt i 1000 bound 1000 50 o = get xmow i 51 if eq fold 1 52 o = xmixfold o 53 end 54 put xmsq i and shr o k 1 55 i = add i 1 56 end 57 end 58 fn xmixdisc i ulong lc ulong to ulong 59 d = get xmsq i 60 j = ulong 1 61 while le j lc bound 1001 62 d = xor d and get xmcc j get xmsq sub i j 63 j = add j 1 64 end 65 ret d 66 end 67 fn xmixsave to void 68 j = ulong 0 69 while le j 1000 bound 1001 70 put xmtt j get xmcc j 71 j = add j 1 72 end 73 end 74 fn xmixrest to void 75 j = ulong 0 76 while le j 1000 bound 1001 77 put xmbb j get xmtt j 78 j = add j 1 79 end 80 end 81 fn xmixfix sh ulong to void 82 j = sh 83 while le j 1000 bound 1001 84 put xmcc j xor get xmcc j get xmbb sub j sh 85 j = add j 1 86 end 87 end 88 fn xmixbm to ulong 89 j = ulong 0 90 while le j 1000 bound 1001 91 put xmcc j ulong 0 92 put xmbb j ulong 0 93 j = add j 1 94 end 95 put xmcc 0 ulong 1 96 put xmbb 0 ulong 1 97 lc = ulong 0 98 mp = ulong 0 99 i = ulong 0 100 while lt i 1000 bound 1000 101 d = xmixdisc i lc 102 if eq d 1 103 xmixsave 104 xmixfix sub add i 1 mp 105 if le mul 2 lc i 106 lc = sub add i 1 lc 107 mp = add i 1 108 xmixrest 109 end 110 end 111 i = add i 1 112 end 113 ret lc 114 end 115 fn xmixnum v ulong to int 116 x = v 117 p = ulong 23 118 while lt p 24 bound 21 119 put xmob p uchar add 48 rem x 10 120 x = div x 10 121 if eq x 0 122 break 123 end 124 p = sub p 1 125 end 126 p = sub p 1 127 put xmob p uchar 32 128 n = sub 24 p 129 k = write 1 xmob p n 130 if ne k long n 131 ret 1 132 end 133 ret 0 134 end 135 fn xmixline fold ulong to int 136 if eq fold 1 137 k = write 1 xmlfold 0 len xmlfold 138 else 139 k = write 1 xmlraw 0 len xmlraw 140 end 141 b = ulong 0 142 while lt b 32 bound 32 143 r = xmixnum get xmlc add mul fold 32 b 144 if ne r 0 145 ret 1 146 end 147 b = add b 1 148 end 149 k = write 1 xmlnl 0 len xmlnl 150 ret 0 151 end 152 fn xmixfirst to int 153 if ne get xmow 0 `246875399` 154 ret 1 155 end 156 if ne get xmow 1 `3690007200` 157 ret 1 158 end 159 if ne get xmow 2 `1264581005` 160 ret 1 161 end 162 if ne get xmow 3 `3906711041` 163 ret 1 164 end 165 if ne get xmow 4 `1866187943` 166 ret 1 167 end 168 if ne get xmow 5 `2481925219` 169 ret 1 170 end 171 if ne get xmow 6 `2464530826` 172 ret 1 173 end 174 if ne get xmow 7 `1604040631` 175 ret 1 176 end 177 ret 0 178 end 179 fn xmixlow fold ulong to ulong 180 c = ulong 0 181 b = ulong 0 182 while lt b 32 bound 32 183 if lt get xmlc add mul fold 32 b 480 184 c = add c 1 185 end 186 b = add b 1 187 end 188 ret c 189 end 190 fn main to int 191 xmixinit 192 i = ulong 0 193 while lt i 1000 bound 1000 194 put xmow i xmixstep 195 i = add i 1 196 end 197 f = ulong 0 198 while lt f 2 bound 2 199 b = ulong 0 200 while lt b 32 bound 32 201 xmixbits b f 202 put xmlc add mul f 32 b xmixbm 203 b = add b 1 204 end 205 f = add f 1 206 end 207 if ne xmixline 0 0 208 ret 2 209 end 210 if ne xmixline 1 0 211 ret 2 212 end 213 if ne xmixfirst 0 214 ret 10 215 end 216 if ne get xmlc 0 162 217 ret 20 218 end 219 if ne get xmlc 1 323 220 ret 21 221 end 222 if ne xmixlow 0 2 223 ret 22 224 end 225 if ne xmixlow 1 0 226 ret 30 227 end 228 ret 0 229 end