Hi all,
Consider the following program, which is supposed to check the
"randomness" of pycuda random number generator:
import pycuda.autoinit
import pycuda.curandom as curandom
import numpy
def test(size, dtype):
a = curandom.rand((size,), dtype=dtype).get()
return numpy.sum(a) / size
max_mem = 512 * (2 ** 20)
for dtype in numpy.float32, numpy.float64:
mem = 2 ** 20
print dtype
while mem <= max_mem:
size = mem / dtype().nbytes
print str(float(size) / (2 ** 20)) + "M elements: " +
str(test(size, dtype))
mem *= 2
I get the following output on CentOS, PyCuda 0.94, GF GTX280:
<type 'numpy.float32'>
0.25M elements: 0.500930726528
0.5M elements: 0.499650388956
1.0M elements: 0.500381290913
2.0M elements: 0.499845147133
4.0M elements: 0.499690800905
8.0M elements: 0.499930769205
16.0M elements: 0.49999204278
32.0M elements: 0.5
64.0M elements: 0.25
128.0M elements: 0.125
<type 'numpy.float64'>
0.125M elements: 0.499772083492
0.25M elements: 0.50026633386
0.5M elements: 0.500266385917
1.0M elements: 0.499622306278
2.0M elements: 0.500208270678
4.0M elements: 0.499779380632
8.0M elements: 0.500015098409
16.0M elements: 0.499948681628
32.0M elements: 0.499982760884
64.0M elements: 0.499977268643
It looks like for single precision generator starts repeating itself
after ~16M numbers. Is it some restriction of the algorithm or a bug
in code?
Best regards,
Bogdan
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda