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

  • 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 630
spmd
11-287
By default, MATLAB uses as many workers as it finds available in the pool. When there
are no MATLAB workers available, MATLAB executes the block body locally and creates
Composite objects as necessary.
spmd(n), statements, end uses n to specify the exact number of MATLAB workers
to evaluate statements, provided that n workers are available from the parallel pool.
If there are not enough workers available, an error is thrown. If n is zero, MATLAB
executes the block body locally and creates Composite objects, the same as if there is no
pool available.
spmd(m,n), statements, end uses a minimum of m and a maximum of n workers to
evaluate statements. If there are not enough workers available, an error is thrown. m
can be zero, which allows the block to run locally if no workers are available.
For more information about spmd and Composite objects, see “Distributed Arrays and
SPMD”.
Examples
Perform a simple calculation in parallel, and plot the results:
parpool(3)
spmd
% build magic squares in parallel
q = magic(labindex + 2);
end
for ii=1:length(q)
% plot each magic square
figure, imagesc(q{ii});
end
delete(gcp)
More About
Tips
An spmd block runs on the workers of the existing parallel pool. If no pool exists, spmd
will start a new parallel pool, unless the automatic starting of pools is disabled in
your parallel preferences. If there is no parallel pool and spmd cannot start one, the
code runs serially in the client session.
Vue de la page 630
1 2 ... 626 627 628 629 630 631 632 633 634 635 636 ... 655 656

Commentaires sur ces manuels

Pas de commentaire