There's something wrong with the bit shifting at the putchar()
Unlikely. Looked good when I checked the output with hexdump. Except we can perhaps have a different byte ordering. Which dieharder would not care about.
Okay... I made a mistake as seen in my code above. Only passing 32 bits of the 64 to stdout. When I ran it again with all bits, it began failing misserable!
Here's the output from Practrand
PE 1 | ./RNG_test stdin
RNG_test using PractRand version 0.93
RNG = RNG_stdin, seed = 0xa4eaaac4
test set = normal, folding = standard(unknown format)
rng=RNG_stdin, seed=0xa4eaaac4
length= 128 megabytes (2^27 bytes), time= 3.8 seconds
Test Name Raw Processed Evaluation
BCFN(2+0,13-3,T) R= +74.9 p = 3.0e-35 FAIL !!!
BCFN(2+1,13-3,T) R= +18.9 p = 9.6e-9 VERY SUSPICIOUS
DC6-9x1Bytes-1 R= +1413 p = 6.3e-868 FAIL !!!!!!!
Gap-16:A R=+149.1 p = 1.3e-126 FAIL !!!!!
Gap-16:B R=+367.1 p = 6.1e-294 FAIL !!!!!!
FPF-14+6/16:(0,14-0) R= +5478 p = 8e-5069 FAIL !!!!!!!!
FPF-14+6/16:(1,14-0) R= +2754 p = 5e-2548 FAIL !!!!!!!!
FPF-14+6/16:(2,14-0) R= +1357 p = 2e-1255 FAIL !!!!!!!!
FPF-14+6/16:(3,14-1) R=+967.8 p = 1.7e-857 FAIL !!!!!!!
FPF-14+6/16:(4,14-2) R=+655.1 p = 1.0e-572 FAIL !!!!!!!
FPF-14+6/16:(5,14-2) R=+254.4 p = 3.0e-222 FAIL !!!!!!
FPF-14+6/16:all R= +5306 p = 2e-4979 FAIL !!!!!!!!
FPF-14+6/16:all2 R=+9738850 p = 0 FAIL !!!!!!!!
FPF-14+6/16:cross R= +5198 p = 2e-4373 FAIL !!!!!!!!
[Low1/8]Gap-16:B R= +4.4 p = 1.0e-3 unusual
...and 136 test result(s) without anomalies
Yeah, we have been posting over each other. I saw your comments.
It's miserable.
What about trying pactrand on the original 64 bit output [63:0] ?
My feeling is that we might as well use that bit zero. If it gets through pactrand surely we are good to go with 64 bits for all practical purposes on the P2 ?
Where did you get pactrand from? Google does not seem to want to find it for me. Never mind. Helps if I spell it properly!
So the top 64 bits from the 65-bit sum of s0+s1 do not pass the randomness test?
I cant help but note here that, despite these overly-verbose typecasts in C++, there are all kinds of uncertainties and ambiguities about what the compilers are doing. Meanwhile, the forum software keeps substituting "08" for some idiotic emoji smiley face, further muddling up everyone's efforts. The Modern Way has almost ruined computing.
Yes, the existing solution uses only the high 63 bits. Why? Because the bit zero is said to be not so statistically random looking as the rest.
...
Unless I have made a mistake I think we may as well use the original 64 bit result.
Using the original 64 bit result without discarding the LSB fails Practrand after just a few seconds!
I cant help but note here that, despite these overly-verbose typecasts in C++, there are all kinds of uncertainties and ambiguities about what the compilers are doing.
According to the standard explicit casting is 100% certain to produce the intended results. There's a reason why most embedded coding is made using C/C++... You CAN be certain what the compiler does IF YOU know what you are doing. On the other hand C++ is a monster for beginners!
Oops, I wasn't doing the shift by one. Okay, got something looking better now. Straightened up the byte order while I was at it.
Okay, the Dieharder 63 bits results fails quite a lot, while the 64 bit results are all good, just as Heater had observed. I don't understand because it doesn't match Johannes's earlier findings.
I ran Dieharder with only the 8 LSB's ( (PRNG::getXoroshiro() >> 1) &0x7 ) as I figured that the randomness for all other bits would be equally good. Diharder reads 4 8 bits values and merge them into a 32 bit value internally. I am now running the same test with the 32 LSB of "PRNG::getXoroshiro() >> 1) & 0x1F"
So the top 64 bits from the 65-bit sum of s0+s1 do not pass the randomness test?
That is correct.
On the whole the compilers are pretty clear. Well C anyway. C++ can always catch you out until you have learned all it's intricacies. Which can take a lifetime... Which is why most embedded projects limit the feature set of C++ you can use and have 200 page coding standards documents!
Not sure what is up with the forum and "8)". A curse on emoji and Unicode I say. One sees them causing so much data corruption around the web.
The xoroshiro128+ document advised a sign test for extracting a random bit. That would mean just looking at sum [63], only, per iteration. We need as many bits as possible per iteration.
Hmm, it terminates the testing with the first "fail".
I've had a single "fail" amongst a mass of "normal"s and a small number of "unusual"s on the simple sum [63:0]. It's not that bad, but I suppose we expected that.
Admittedly sum [63:1] isn't "fail"ing at all and has even less "unusual"s.
I concur with Johannes. Chip, keep the Prop2 as you've got it now.
PS: Wow! sum [64:1] fails in bulk in the first round! It's smallest output so I'll post it here:
RNG_test using PractRand version 0.93
RNG = RNG_stdin, seed = 0x956c7f6a
test set = normal, folding = standard(unknown format)
rng=RNG_stdin, seed=0x956c7f6a
length= 64 megabytes (2^26 bytes), time= 2.5 seconds
Test Name Raw Processed Evaluation
BCFN(2+0,13-3,T) R= +29.8 p = 6.7e-14 FAIL
BCFN(2+1,13-3,T) R= +0.8 p = 0.365 normal
BCFN(2+2,13-4,T) R= -0.5 p = 0.563 normal
BCFN(2+3,13-4,T) R= +1.7 p = 0.231 normal
BCFN(2+4,13-5,T) R= -1.7 p = 0.756 normal
BCFN(2+5,13-5,T) R= -1.0 p = 0.645 normal
BCFN(2+6,13-6,T) R= -0.6 p = 0.561 normal
BCFN(2+7,13-6,T) R= -0.9 p = 0.622 normal
BCFN(2+8,13-7,T) R= +1.4 p = 0.250 normal
BCFN(2+9,13-8,T) R= +2.9 p = 0.111 normal
BCFN(2+10,13-8,T) R= -0.1 p = 0.453 normal
BCFN(2+11,13-9,T) R= -0.3 p = 0.464 normal
BCFN(2+12,13-9,T) R= +4.3 p = 0.048 normal
DC6-9x1Bytes-1 R=+765.2 p = 2.1e-487 FAIL !!!!!!!
Gap-16:A R= +83.2 p = 3.8e-72 FAIL !!!!
Gap-16:B R=+220.5 p = 3.7e-196 FAIL !!!!!!
FPF-14+6/16:(0,14-0) R= +2756 p = 3e-2550 FAIL !!!!!!!!
FPF-14+6/16:(1,14-0) R= +1379 p = 2e-1275 FAIL !!!!!!!!
FPF-14+6/16:(2,14-1) R=+973.4 p = 1.9e-862 FAIL !!!!!!!
FPF-14+6/16:(3,14-2) R=+680.1 p = 1.3e-594 FAIL !!!!!!!
FPF-14+6/16:(4,14-2) R=+318.3 p = 3.4e-278 FAIL !!!!!!
FPF-14+6/16:(5,14-3) R=+181.6 p = 6.2e-159 FAIL !!!!!
FPF-14+6/16:(6,14-4) R= -0.2 p = 0.559 normal
FPF-14+6/16:(7,14-5) R= +0.7 p = 0.309 normal
FPF-14+6/16:(8,14-5) R= +0.8 p = 0.295 normal
FPF-14+6/16:(9,14-6) R= -2.4 p = 0.964 normal
FPF-14+6/16:(10,14-7) R= -0.0 p = 0.500 normal
FPF-14+6/16:(11,14-8) R= -1.3 p = 0.831 normal
FPF-14+6/16:(12,14-8) R= -1.6 p = 0.876 normal
FPF-14+6/16:(13,14-9) R= -2.3 p = 0.968 normal
FPF-14+6/16:(14,14-10) R= +0.6 p = 0.311 normal
FPF-14+6/16:(15,14-11) R= -1.4 p = 0.862 normal
FPF-14+6/16:(16,14-11) R= -1.6 p = 0.910 normal
FPF-14+6/16:all R= +3043 p = 3e-2855 FAIL !!!!!!!!
FPF-14+6/16:all2 R=+2679396 p = 0 FAIL !!!!!!!!
FPF-14+6/16:cross R= +2680 p = 1e-2359 FAIL !!!!!!!!
BRank(12):128(4) R= -0.2 p~= 0.500 normal
BRank(12):256(2) R= -1.0 p~= 0.744 normal
BRank(12):384(1) R= +0.4 p~= 0.366 normal
BRank(12):512(2) R= -1.0 p~= 0.744 normal
BRank(12):768(1) R= -0.7 p~= 0.689 normal
BRank(12):1K(1) R= -0.7 p~= 0.689 normal
[Low1/8]BCFN(2+0,13-5,T) R= +1.2 p = 0.292 normal
[Low1/8]BCFN(2+1,13-5,T) R= +2.1 p = 0.189 normal
[Low1/8]BCFN(2+2,13-6,T) R= +0.6 p = 0.367 normal
[Low1/8]BCFN(2+3,13-6,T) R= +0.1 p = 0.443 normal
[Low1/8]BCFN(2+4,13-6,T) R= -3.7 p = 0.961 normal
[Low1/8]BCFN(2+5,13-7,T) R= +1.6 p = 0.228 normal
[Low1/8]BCFN(2+6,13-8,T) R= -2.6 p = 0.905 normal
[Low1/8]BCFN(2+7,13-8,T) R= -1.0 p = 0.620 normal
[Low1/8]BCFN(2+8,13-9,T) R= -2.6 p = 0.942 normal
[Low1/8]BCFN(2+9,13-9,T) R= +0.2 p = 0.376 normal
[Low1/8]DC6-9x1Bytes-1 R= +4.1 p = 0.045 normal
[Low1/8]Gap-16:A R= +1.1 p = 0.393 normal
[Low1/8]Gap-16:B R= +2.4 p = 0.046 normal
[Low1/8]FPF-14+6/16:(0,14-2) R= +1.3 p = 0.182 normal
[Low1/8]FPF-14+6/16:(1,14-2) R= -1.4 p = 0.848 normal
[Low1/8]FPF-14+6/16:(2,14-3) R= -1.4 p = 0.847 normal
[Low1/8]FPF-14+6/16:(3,14-4) R= +0.0 p = 0.498 normal
[Low1/8]FPF-14+6/16:(4,14-5) R= +0.0 p = 0.484 normal
[Low1/8]FPF-14+6/16:(5,14-5) R= -1.4 p = 0.832 normal
[Low1/8]FPF-14+6/16:(6,14-6) R= +1.6 p = 0.132 normal
[Low1/8]FPF-14+6/16:(7,14-7) R= -0.0 p = 0.490 normal
[Low1/8]FPF-14+6/16:(8,14-8) R= +1.6 p = 0.132 normal
[Low1/8]FPF-14+6/16:(9,14-8) R= +1.3 p = 0.179 normal
[Low1/8]FPF-14+6/16:(10,14-9) R= +0.2 p = 0.412 normal
[Low1/8]FPF-14+6/16:(11,14-10) R= -1.9 p = 0.944 normal
[Low1/8]FPF-14+6/16:(12,14-11) R= -0.1 p = 0.453 normal
[Low1/8]FPF-14+6/16:(13,14-11) R= +2.7 p = 0.050 normal
[Low1/8]FPF-14+6/16:all R= -0.4 p = 0.635 normal
[Low1/8]FPF-14+6/16:all2 R= -0.5 p = 0.637 normal
[Low1/8]FPF-14+6/16:cross R= +0.5 p = 0.283 normal
[Low1/8]BRank(12):128(2) R= -0.2 p~= 0.554 normal
[Low1/8]BRank(12):256(2) R= +1.6 p~= 0.168 normal
[Low1/8]BRank(12):384(1) R= -0.7 p~= 0.689 normal
[Low1/8]BRank(12):512(1) R= +0.4 p~= 0.366 normal
[Low4/32]BCFN(2+0,13-5,T) R= -2.5 p = 0.857 normal
[Low4/32]BCFN(2+1,13-5,T) R= +3.2 p = 0.101 normal
[Low4/32]BCFN(2+2,13-6,T) R= +0.0 p = 0.462 normal
[Low4/32]BCFN(2+3,13-6,T) R= +0.2 p = 0.437 normal
[Low4/32]BCFN(2+4,13-6,T) R= +1.8 p = 0.214 normal
[Low4/32]BCFN(2+5,13-7,T) R= -1.3 p = 0.679 normal
[Low4/32]BCFN(2+6,13-8,T) R= -0.2 p = 0.462 normal
[Low4/32]BCFN(2+7,13-8,T) R= +1.0 p = 0.278 normal
[Low4/32]BCFN(2+8,13-9,T) R= -1.5 p = 0.727 normal
[Low4/32]BCFN(2+9,13-9,T) R= +0.9 p = 0.270 normal
[Low4/32]DC6-9x1Bytes-1 R= -0.3 p = 0.708 normal
[Low4/32]Gap-16:A R= +0.5 p = 0.546 normal
[Low4/32]Gap-16:B R= +1.4 p = 0.160 normal
[Low4/32]FPF-14+6/16:(0,14-2) R= +0.6 p = 0.342 normal
[Low4/32]FPF-14+6/16:(1,14-2) R= -0.5 p = 0.628 normal
[Low4/32]FPF-14+6/16:(2,14-3) R= +0.9 p = 0.266 normal
[Low4/32]FPF-14+6/16:(3,14-4) R= +0.1 p = 0.481 normal
[Low4/32]FPF-14+6/16:(4,14-5) R= -0.3 p = 0.574 normal
[Low4/32]FPF-14+6/16:(5,14-5) R= -0.9 p = 0.744 normal
[Low4/32]FPF-14+6/16:(6,14-6) R= +1.0 p = 0.233 normal
[Low4/32]FPF-14+6/16:(7,14-7) R= +0.5 p = 0.360 normal
[Low4/32]FPF-14+6/16:(8,14-8) R= +4.2 p = 4.8e-3 normal
[Low4/32]FPF-14+6/16:(9,14-8) R= -1.0 p = 0.748 normal
[Low4/32]FPF-14+6/16:(10,14-9) R= -0.7 p = 0.661 normal
[Low4/32]FPF-14+6/16:(11,14-10) R= -0.2 p = 0.524 normal
[Low4/32]FPF-14+6/16:(12,14-11) R= -0.3 p = 0.526 normal
[Low4/32]FPF-14+6/16:(13,14-11) R= +0.8 p = 0.252 normal
[Low4/32]FPF-14+6/16:all R= +0.4 p = 0.413 normal
[Low4/32]FPF-14+6/16:all2 R= -0.2 p = 0.495 normal
[Low4/32]FPF-14+6/16:cross R= +0.1 p = 0.428 normal
[Low4/32]BRank(12):128(2) R= +0.8 p~= 0.293 normal
[Low4/32]BRank(12):256(2) R= +0.6 p~= 0.322 normal
[Low4/32]BRank(12):384(1) R= -0.7 p~= 0.689 normal
[Low4/32]BRank(12):512(1) R= +1.8 p~= 0.146 normal
[Low1/32]BCFN(2+0,13-6,T) R= +0.5 p = 0.389 normal
[Low1/32]BCFN(2+1,13-6,T) R= +0.5 p = 0.383 normal
[Low1/32]BCFN(2+2,13-7,T) R= +0.4 p = 0.384 normal
[Low1/32]BCFN(2+3,13-7,T) R= -1.0 p = 0.634 normal
[Low1/32]BCFN(2+4,13-8,T) R= -1.6 p = 0.748 normal
[Low1/32]BCFN(2+5,13-8,T) R= +0.4 p = 0.372 normal
[Low1/32]BCFN(2+6,13-9,T) R= -2.6 p = 0.934 normal
[Low1/32]BCFN(2+7,13-9,T) R= +1.0 p = 0.265 normal
[Low1/32]DC6-9x1Bytes-1 R= -0.3 p = 0.683 normal
[Low1/32]Gap-16:A R= +3.6 p = 0.013 normal
[Low1/32]Gap-16:B R= -1.8 p = 0.893 normal
[Low1/32]FPF-14+6/16:(0,14-3) R= -1.0 p = 0.771 normal
[Low1/32]FPF-14+6/16:(1,14-4) R= +1.7 p = 0.118 normal
[Low1/32]FPF-14+6/16:(2,14-5) R= +1.6 p = 0.127 normal
[Low1/32]FPF-14+6/16:(3,14-5) R= +2.6 p = 0.040 normal
[Low1/32]FPF-14+6/16:(4,14-6) R= +1.1 p = 0.216 normal
[Low1/32]FPF-14+6/16:(5,14-7) R= +0.6 p = 0.320 normal
[Low1/32]FPF-14+6/16:(6,14-8) R= -0.2 p = 0.546 normal
[Low1/32]FPF-14+6/16:(7,14-8) R= +0.5 p = 0.337 normal
[Low1/32]FPF-14+6/16:(8,14-9) R= +1.8 p = 0.106 normal
[Low1/32]FPF-14+6/16:(9,14-10) R= -0.6 p = 0.629 normal
[Low1/32]FPF-14+6/16:(10,14-11) R= +1.0 p = 0.210 normal
[Low1/32]FPF-14+6/16:(11,14-11) R= -1.2 p = 0.796 normal
[Low1/32]FPF-14+6/16:all R= +2.3 p = 0.062 normal
[Low1/32]FPF-14+6/16:all2 R= -0.5 p = 0.644 normal
[Low1/32]FPF-14+6/16:cross R= +1.7 p = 0.059 normal
[Low1/32]BRank(12):128(2) R= -1.0 p~= 0.744 normal
[Low1/32]BRank(12):256(2) R= +0.8 p~= 0.293 normal
[Low1/32]BRank(12):384(1) R= -0.7 p~= 0.689 normal
Being part of this P2 PRNG issue has renewed my interest in the P2. This has been so much fun!
Could somebody give me a crash course (so I don't need to go through 1000's of forum pages) on how to download and run the latest P2 version on my DE2-115?
Third link in Chip's opening post is the dev files. There is image files for the DE2-115/DE0-Nano/BeMicro-A2/BeMicro-A9, I think you might need to use Quartus to load them. PX.exe is only for the Prop123 boards.
Comments
Have a look at my comments again, I realized my mistake immediately and all comments/results after that are based on my fixed code!
I changed my code to do explicit casting: So it is the C equivalent of your version.
Still fails.
Yeah, we have been posting over each other. I saw your comments.
It's miserable.
What about trying pactrand on the original 64 bit output [63:0] ?
My feeling is that we might as well use that bit zero. If it gets through pactrand surely we are good to go with 64 bits for all practical purposes on the P2 ?
Where did you get pactrand from? Google does not seem to want to find it for me. Never mind. Helps if I spell it properly!
I cant help but note here that, despite these overly-verbose typecasts in C++, there are all kinds of uncertainties and ambiguities about what the compilers are doing. Meanwhile, the forum software keeps substituting "08" for some idiotic emoji smiley face, further muddling up everyone's efforts. The Modern Way has almost ruined computing.
Using the original 64 bit result without discarding the LSB fails Practrand after just a few seconds!
Okay, the Dieharder 63 bits results fails quite a lot, while the 64 bit results are all good, just as Heater had observed. I don't understand because it doesn't match Johannes's earlier findings.
sum [63:0] fails?
sum [63:1] passes?
What about sum [64:1]?
I ran Dieharder with only the 8 LSB's ( (PRNG::getXoroshiro() >> 1) &0x7 ) as I figured that the randomness for all other bits would be equally good. Diharder reads 4 8 bits values and merge them into a 32 bit value internally. I am now running the same test with the 32 LSB of "PRNG::getXoroshiro() >> 1) & 0x1F"
/Johannes
Other way round. But Johannes is saying that isn't good either. I've just had another shot at sum [64:1] and it's definitely the worst.
I'm thinking sum [63:1] is presumably okay but the tests are tripping up on the fixed 0 value for the shifted bit 63.
On the whole the compilers are pretty clear. Well C anyway. C++ can always catch you out until you have learned all it's intricacies. Which can take a lifetime... Which is why most embedded projects limit the feature set of C++ you can use and have 200 page coding standards documents!
Not sure what is up with the forum and "8)". A curse on emoji and Unicode I say. One sees them causing so much data corruption around the web. Yep.
It goes through Dieharder without trouble, but Practrand fails just after a few seconds!
Be sure you are packing those 63 bits so as to not be passing 64 bits with an MSB of zero. Or some such.
There is a lot of shifting to be done to feed 63 bit chunks into dieharder.
According to Practrand:
sum [64:1] - Bad
sum [63:1] - Good
sum [63:0] - Bad
According to Dieharder:
sum [64:1] - Bad
sum [63:1] - Good
sum [63:0] - Good
Super!
That means there's agreement that [63:1] is good. Having 63 unique bits is almost as good as having 64. We're in good shape, then, as is.
Yes, it would be nice.
I've compiled PractRand sources and got three binaries. What's the testing command string you are using?
EDIT: Current command is: ./xoroshiro128plus-test | ./RNG_test stdin -a >practrand.out
I've had a single "fail" amongst a mass of "normal"s and a small number of "unusual"s on the simple sum [63:0]. It's not that bad, but I suppose we expected that.
Admittedly sum [63:1] isn't "fail"ing at all and has even less "unusual"s.
PS: Wow! sum [64:1] fails in bulk in the first round! It's smallest output so I'll post it here:
Could somebody give me a crash course (so I don't need to go through 1000's of forum pages) on how to download and run the latest P2 version on my DE2-115?
Third link in Chip's opening post is the dev files. There is image files for the DE2-115/DE0-Nano/BeMicro-A2/BeMicro-A9, I think you might need to use Quartus to load them. PX.exe is only for the Prop123 boards.