A parfor
loop
contains break
and return
statements. The parfor
statement works by breaking up
iterations of a loop and running these iterations on multiple MATLAB workers.
Using break
and return
statements implies
that later iterations of the loop should not run after either of these two
statements execute. Therefore, the loop iterations must run in sequence.
However, for the parfor
loop to be valid, the result of
running the successive loop iterations must not depend on the order in which
they run.
Transform the program so that loop iterations do not depend on the results of other loop iterations.