Documentation

parfor Programming Considerations

MATLAB Path

All workers executing a parfor-loop must have the same MATLAB® search path as the client, so that they can execute any functions called in the body of the loop. 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 search path on all workers.

Functions files that contain parfor-loops must be available on the search path of the workers in the pool running the parfor, or made available to the workers by the AttachedFiles or AdditionalPaths setting of the parallel pool.

Error Handling

When an error occurs during the execution of a parfor-loop, all iterations that are in progress are terminated, new ones are not initiated, and the loop terminates.

Errors and warnings produced on workers are annotated with the worker ID and displayed in the client's Command Window in the order in which they are received by the client MATLAB.

The behavior of lastwarn is unspecified at the end of the parfor if used within the loop body.

More About

Was this topic helpful?