%SPMD Single Program Multiple Data 
%   The general form of an SPMD statement is:
%
%   SPMD
%       <statements>
%   END
%
%   MATLAB executes the code within the SPMD body denoted by STATEMENTS on
%   several MATLAB workers simultaneously.  In order to execute the
%   STATEMENTS in parallel, you must first open a parallel pool of workers
%   using PARPOOL. SPMD can only be used if you have Parallel Computing
%   Toolbox.
%
%   Variables assigned in the body of SPMD will be available for use as
%   Composite objects outside the SPMD block on the MATLAB client. A
%   Composite object can be used to retrieve the values stored on the remote
%   MATLAB workers.  The actual data remains available on the workers for
%   subsequent SPMD statements, so long as the Composite exists on the
%   MATLAB client and the parallel pool remains open.
%
%   By default, MATLAB uses all workers in the pool. When there is no pool
%   active, MATLAB will create a pool and use all the workers from that
%   pool. If your preferences do not allow automatic pool creation, MATLAB
%   executes the block body locally and creates Composite objects as
%   necessary. You cannot execute an SPMD block if any worker is busy
%   executing a parfeval request, unless you use SPMD(0).
%
%   SPMD(N), <statements>, END uses N to specify the exact number of
%   MATLAB workers that will evaluate STATEMENTS in the body, 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.  When SPMD executes locally, assigned
%   variables within SPMD are still converted to Composites for use outside
%   SPMD.
%
%   SPMD(M,N), <statements>, END uses a minimum of M and maximum of N
%   workers to evaluate STATEMENTS.
%
%   EXAMPLE
%
%   Perform a simple calculation in parallel, and plot the results
%
%   parpool(3)
%   spmd
%     % build magic squares in parallel
%     q = magic( spmdIndex + 2 );
%   end
%   for ii=1:length( q )
%     % plot each magic square
%     figure, imagesc( q{ii} );
%   end
%   spmd
%     % modify variable on workers
%     q = q*2;
%   end
%   % Access data on a specific worker
%   figure, imagesc(q{2});
% 
%   See also parpool, Composite

% Copyright 2008-2022 The MathWorks, Inc.
% Built-in function.
