Chapter 6 Vectorized Code Generation© National Instruments Corporation 6-21 AutoCode ReferenceYou should notice two things in the code shown in Example 6-8. First,the gain block added to merge the data is generated as copies from therespective inputs into the single array. Second, the integrator block istightly rolled. If the merge was not present, the Integrator would have beenunrolled, causing a 6-fold increase in the amount of code for that block.The only reason to introduce a merge block (unit gain block) is when thecost of unrolling the algorithm of your block—in this case the integratorblock—is more expensive then the merge block. It can be seen from thecode that the cost of a merge block is a copy in a local array. Because theintegrator algorithm is complicated, it is necessary to have the merge so thatthe integrator is rolled.AutoCode will not automatically introduce the merge (copy) just toimprove vectorization. The reason is that traceability from the code tomodel is reduced anytime extra code other than the block algorithm isgenerated. Also, AutoCode is not able to evaluate the design decision tomake one block rolled at the expense of another. Therefore, for optimalvectorization, you might need to change your model.External OutputsAnother variation of the split-merge problem appears with external outputs.External outputs are represented by the Y-structure. It contains only thosesignals marked as external outputs. For scalar code generation, AutoCodedirectly uses the symbol in the Y-structure instead of using local storage.However, when the output of a block is a vector and only a subset of theoutputs are connected to external outputs, a conflict of requirementsappears between storing the block output into an array and optimizingaccess to external output.Copy-BackWhen a split-merge occurs with external outputs, AutoCode must act topreserve the semantics of the model. AutoCode has been designed topreserve the array, and therefore the block vectorization and copy-backthose external outputs from the array into the Y-structure. In the exampleshown in Figure 6-6, a simple gain block has only two of its five outputsconnected to the external output. AutoCode preserves the array for the gainblock, but copies the pieces of the array that are external output into theY-structure.