User`s guide

Programming Tips
3-13
Programming Tips
In this section...
“MATLAB Path” on page 3-13
“Error Handling” on page 3-13
“Limitations” on page 3-13
MATLAB Path
All workers executing an spmd statement must have the same MATLAB search path as
the client, so that they can execute any functions called in their common block of code.
Therefore, whenever you use cd, addpath, or rmpath on the client, it also executes
on all the workers, if possible. For more information, see the parpool reference page.
When the workers are running on a different platform than the client, use the function
pctRunOnAll to properly set the MATLAB path on all workers.
Error Handling
When an error occurs on a worker during the execution of an spmd statement, the error
is reported to the client. The client tries to interrupt execution on all workers, and throws
an error to the user.
Errors and warnings produced on workers are annotated with the worker ID (labindex)
and displayed in the client’s Command Window in the order in which they are received
by the MATLAB client.
The behavior of lastwarn is unspecified at the end of an spmd if used within its body.
Limitations
Transparency
The body of an spmd statement must be transparent, meaning that all references to
variables must be “visible” (i.e., they occur in the text of the program).
In the following example, because X is not visible as an input variable in the spmd body
(only the string 'X' is passed to eval), it does not get transferred to the workers. As a
result, MATLAB issues an error at run time: