User`s guide

6 Programming Overview
6-40
Keyword Generator Multiple Stream and
Substream Support
Approximate Period In Full
Precision
'CombRecursive' or
'mrg32k3a'
Combined multiple
recursive generator
Yes
2
127
'Philox4x32-10' Philox 4x32 generator
with 10 rounds
Yes
2
129
'Threefry4x64-20' Threefry 4x64
generator with 20
rounds
Yes
2
258
None of these is the default client generator for the CPU. To generate the same
sequence on CPU and GPU, you must use the only generator supported by both:
'CombRecursive'.
sc = RandStream('CombRecursive','Seed',1);
RandStream.setGlobalStream(sc);
Rc = rand(1,4)
Rc =
0.4957 0.2243 0.2073 0.6823
sg = parallel.gpu.RandStream('CombRecursive','Seed',1);
parallel.gpu.RandStream.setGlobalStream(sg);
Rg = rand(1,4,'gpuArray')
Rg =
0.4957 0.2243 0.2073 0.6823
For normally distributed random numbers created by randn, CPU code by default uses
a random stream with a NormalTransform setting of Ziggurat, while GPU code uses
a setting of Inversion. You can set CPU and GPU generators the same to get the same
randn sequence. The GPU supports only Inversion, so set the CPU to match:
sc = RandStream('CombRecursive','NormalTransform','Inversion','Seed',1);
RandStream.setGlobalStream(sc)
sg = parallel.gpu.RandStream('CombRecursive','NormalTransform','Inversion','Seed',1);
parallel.gpu.RandStream.setGlobalStream(sg);
Rc = randn(1,4)
Rc =
-0.0108 -0.7577 -0.8159 0.4742
Rg = randn(1,4,'gpuArray')