Reuse of temporary block outputs, Reuse temporaries as specified, Maximal reuse of temporaries – National Instruments AutoCode NI MATRIX User Manual

Page 202: Reuse of temporary block outputs -11

Advertising
background image

Chapter 7

Code Optimization

© National Instruments Corporation

7-11

AutoCode Reference

In Example 7-5, both time delay blocks have separate INIT sections. In
Example 7-6, the initialization code for these blocks is merged along with
the subsystem initialization section.

Reuse of Temporary Block Outputs

Subsystems and procedures generated by AutoCode contain computations
of individual blocks. Output of these blocks could be subsystem
(procedure) outputs, or it could be temporary. Temporary block outputs are
used immediately in the subsequent computations. The temporary block
outputs are implemented in the generated code as automatic variables and
each block output is mapped by default to a unique variable. Although this
improves readability and makes the generated code traceable to the model,
for very large subsystems (or procedures), this could increase the stack
size. AutoCode provides an option to reuse such temporary block outputs,
thus reducing the stack size and bringing down the risk of stack overflow.

AutoCode provides two ways of reusing temporary block output:

Reuse whenever specified (by the user)

Maximal reuse (reuse whenever possible)

Reuse Temporaries as Specified

In this mode, a temporary variable is reused only if you specify it and if it
is safe to do so. You can specify reuse by entering a variable name in the
output name field in the output form of a block. Refer to the SystemBuild
User Guide
for more details on output forms. Even if this temporary
variable was already used as an output name for another block output,
AutoCode tries to reuse it. If the temporary variable is not used (or needed)
anymore, then AutoCode uses it as the output variable for the current block.
In a case where the variable identified cannot be reused, a distinct (entirely
new) variable is used. The command-line option for this optimization mode
is

-Oreuse 1

.

Maximal Reuse of Temporaries

In this optimization mode, AutoCode tries to reuse as many temporary
variables as it can. Again, a temporary variable is reused only if it is not
needed in any further computations. The command-line option

-Oreuse 2

brings about this optimization.

Advertising