parfor
-LoopsWhen a name in a parfor
-loop is recognized
as referring to a variable, the variable is classified into one of
several categories. A parfor
-loop generates an
error if it contains any variables that cannot be uniquely categorized
or if any variables violate their category restrictions.
Classification | Description |
---|---|
Loop Variable | Loop index |
Sliced Variables | Arrays whose segments are operated on by different iterations of the loop |
Broadcast Variables | Variables defined before the loop whose value is required inside the loop, but never assigned inside the loop |
Reduction Variables | Variables that accumulate a value across iterations of the loop, regardless of iteration order |
Temporary Variables | Variables created inside the loop, and not accessed outside the loop |
Each of these variable classifications appears in this code fragment:
The detailed topics linked from the table above, include guidelines
and restrictions in shaded boxes like the one shown below. Those labeled
as Required result in an error if
your parfor
code does not adhere to them. MATLAB® software
catches some of these errors at the time it reads the code, and others
when it executes the code. These are referred to here as static and dynamic errors,
respectively, and are labeled as Required (static) or Required (dynamic). Guidelines that do not
cause errors are labeled as Recommended.
You can use MATLAB Code Analyzer to help make parfor
-loops
comply with the guidelines.
Required (static): Description of the guideline or restriction |