coder.loop.Control
Description
Use instances of coder.loop.Control
class to optimize MATLAB® for loops in the generated code.
Creation
Description
creates a
loop control object without the transformSchedule property set. loopSchedule
= coder.loop.Control
Use the object functions to add loop transforms to the loop control object. Provide the loop index name as inputs to the object functions.
Properties
Object Functions
apply |
|
interchange |
Use this transform when accessing array elements stored in contiguous memory blocks. If so, the data is loaded into cache and can be reused without a cache refresh. For example, see Interchange for Loops in Generated Code. |
parallelize |
This prompts the generated code for that
loop to execute the iterations in parallel with the threads available for your
target. This transforms requires For example, see Selectively Parallelize for Loops in Generated Code. |
reverse |
This prompts the generated code for that loop to execute the iterations in reverse order. Use this transform when you know the upper bound of the loop iterator. For example, see Reverse for-Loop Iteration Order in Generated Code. |
tile |
This prompts the generated code for that loop to create an outer loop
with loop index Use this transform to reduce iteration space of a loop into smaller blocks. This involves partitioning a large array from memory into smaller blocks that fit into your cache size. Use this transform when you have limited cache availability. For example, see Apply Tile Transform to for-Loop in Generated Code. |
unrollAndJam |
Unroll
and jam transforms are usually applied to perfectly nested loops, or where all the
data elements are accessed within the inner loop. This transform unrolls the body of
the inner loop according to the loop index of the outer loop. The default value of
the For example, see Apply unrollAndJam on a for-Loop in the Generated Code. |
vectorize |
This prompts the code generator to use the
SIMD instruction set for your target hardware in the generated code. Set the
For example, see Vectorize a for-Loop in the Generated Code. |
Examples
Version History
Introduced in R2023a