User`s guide
3 Single Program Multiple Data (spmd)
3-6
Access Worker Variables with Composites
In this section...
“Introduction to Composites” on page 3-6
“Create Composites in spmd Statements” on page 3-6
“Variable Persistence and Sequences of spmd” on page 3-8
“Create Composites Outside spmd Statements” on page 3-9
Introduction to Composites
Composite objects in the MATLAB client session let you directly access data values
on the workers. Most often you assigned these variables within spmd statements. In
their display and usage, Composites resemble cell arrays. There are two ways to create
Composites:
• Use the Composite function on the client. Values assigned to the Composite elements
are stored on the workers.
• Define variables on workers inside an spmd statement. After the spmd statement, the
stored values are accessible on the client as Composites.
Create Composites in spmd Statements
When you define or assign values to variables inside an spmd statement, the data values
are stored on the workers.
After the spmd statement, those data values are accessible on the client as Composites.
Composite objects resemble cell arrays, and behave similarly. On the client, a Composite
has one element per worker. For example, suppose you create a parallel pool of three
local workers and run an spmd statement on that pool:
parpool('local',3)
spmd % Uses all 3 workers
MM = magic(labindex+2); % MM is a variable on each worker
end
MM{1} % In the client, MM is a Composite with one element per worker
8 1 6