MATLAB PARALLEL COMPUTING TOOLBOX - S Guide de l'utilisateur Page 181

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 656
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 180
Control Random Number Streams
6-41
Rg =
-0.0108 -0.7577 -0.8159 0.4742
Worker CPU and Worker GPU
Code running on a worker’s CPU uses the same generator to create random numbers as
code running on a worker’s GPU, but they do not share the same stream. You can use
a common seed to generate the same sequence of numbers, as shown in this example,
where each worker creates the same sequence on GPU and CPU, but different from the
sequence on the other worker.
p = parpool(2);
spmd
sc = RandStream('CombRecursive','Seed',labindex);
RandStream.setGlobalStream(sc);
Rc = rand(1,4)
sg = parallel.gpu.RandStream('CombRecursive','Seed',labindex);
parallel.gpu.RandStream.setGlobalStream(sg);
Rg = rand(1,4,'gpuArray')
end
delete(p)
For normally distributed random numbers from randn, by default a worker CPU
uses a NormalTransform setting of Ziggurat while a worker GPU uses a setting of
Inversion. You can set them both to use Inversion if you need the same sequence
from CPU and GPU.
Vue de la page 180
1 2 ... 176 177 178 179 180 181 182 183 184 185 186 ... 655 656

Commentaires sur ces manuels

Pas de commentaire