Main Content

Optimize Code for Identical Nested Subsystems

The Function packaging parameter Auto option can optimize code in situations in which identical subsystems contain other identical subsystems, by both reusing and inlining generated code. Suppose a model, such as the one shown in Reuse of Identical Nested Subsystems, contains identical subsystems A1 and A2. A1 contains subsystem B1, and A2 contains subsystem B2, which are identical. In such cases, the Auto option causes one function to be generated which is called for both A1 and A2. This function contains one piece of inlined code to execute B1 and B2. This optimization generates less code which improves execution speed.

Reuse of Identical Nested Subsystems