User`s guide

Access Worker Variables with Composites
3-9
AA(:) % Composite
[1]
[2]
[3]
[4]
spmd
AA = AA * 2; % Multiply existing value
end
AA(:) % Composite
[2]
[4]
[6]
[8]
clear AA % Clearing in client also clears on workers
spmd; AA = AA * 2; end % Generates error
delete(gcp)
Create Composites Outside spmd Statements
The Composite function creates Composite objects without using an spmd statement.
This might be useful to prepopulate values of variables on workers before an spmd
statement begins executing on those workers. Assume a parallel pool is already running:
PP = Composite()
By default, this creates a Composite with an element for each worker in the parallel
pool. You can also create Composites on only a subset of the workers in the pool. See the
Composite reference page for more details. The elements of the Composite can now be
set as usual on the client, or as variables inside an spmd statement. When you set an
element of a Composite, the data is immediately transferred to the appropriate worker:
for ii = 1:numel(PP)
PP{ii} = ii;
end