Classify Variables in parfor-Loops

When 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.

ClassificationDescription
Loop VariableLoop index
Sliced VariablesArrays whose segments are operated on by different iterations of the loop
Broadcast VariablesVariables defined before the loop whose value is required inside the loop, but never assigned inside the loop
Reduction VariablesVariables that accumulate a value across iterations of the loop, regardless of iteration order
Temporary VariablesVariables created inside the loop, and not accessed outside the loop

Each of these variable classifications appears in this code fragment:

Notes about Required and Recommended Guidelines

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

More About

Was this topic helpful?