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

  • 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 502
labSendReceive
11-159
dataReceived = labSendReceive(rcvWkrIdx,srcWkrIdx,dataSent,tag) uses
the specified tag for the communication. tag can be any integer from 0 to 32767.
Examples
Create a unique set of data on each worker, and transfer each worker’s data one worker
to the right (to the next higher labindex).
First use the magic function to create a unique value for the variant array mydata on
each worker.
mydata = magic(labindex)
Lab 1:
mydata =
1
Lab 2:
mydata =
1 3
4 2
Lab 3:
mydata =
8 1 6
3 5 7
4 9 2
Define the worker on either side, so that each worker will receive data from the worker
on its “left,” while sending data to the worker on its “right,” cycling data from the end
worker back to the beginning worker.
rcvWkrIdx = mod(labindex, numlabs) + 1; % one worker to the right
srcWkrIdx = mod(labindex - 2, numlabs) + 1; % one worker to the left
Transfer the data, sending each worker’s mydata into the next worker’s otherdata
variable, wrapping the third worker’s data back to the first worker.
otherdata = labSendReceive(rcvWkrIdx,srcWkrIdx,mydata)
Lab 1:
otherdata =
8 1 6
3 5 7
4 9 2
Vue de la page 502
1 2 ... 498 499 500 501 502 503 504 505 506 507 508 ... 655 656

Commentaires sur ces manuels

Pas de commentaire