Merging init sections, Merging init sections -8 – National Instruments AutoCode NI MATRIX User Manual

Page 199

Advertising
background image

Chapter 7

Code Optimization

AutoCode Reference

7-8

ni.com

Merging INIT Sections

Most of the dynamic blocks have explicit initialization, output update and
state update sections. The initialization section is guarded by an INIT
Boolean variable that is TRUE only for the first time a subsystem or a
procedure is called. Each initialization section is tested every time the
subsystem or procedure is executed. AutoCode supports an option where
all such initialization branches can be merged into a single initialization
branch.

The command option

-Oinitmerge

tries to merge all initialization

segments within a subsystem or a procedure. This speeds up applications,
particularly for processors with pipeline architecture such as Siemens
166/167. In this case, there would be considerable improvement in the
execution speed.

If AutoCode cannot merge all the INIT sections together, it creates a
separate INIT branch for the blocks that cannot be merged. This happens
when a block uses outputs of other blocks executed before it is in its
initialization section.

Example 7-5 shows generated code without the optimization,
and Example 7-6 shows generated code with the optimization.

Example 7-5

Sample Code Segment Generated by AutoCode without this Optimization

/******* Initialization. *******/

if (SUBSYS_PREINIT[1]) {

iinfo[0] = 0;

iinfo[1] = 1;

iinfo[2] = 1;

iinfo[3] = 1;

INIT = 1;

X = &ss_1_states[0];

XD = &ss_1_states[1];

X->proc_22_S1 = 0.0;

X->proc_24_S1 = 0.0;

XD->proc_22_S1 = 0.0;

XD->proc_24_S1 = 0.0;

SUBSYS_PREINIT[1] = FALSE;

return;

}

/***** Output Update. *****/

Advertising