Chapter 6
Vectorized Code Generation
6-28
ni.com
Matrix Outputs
When you provide matricized output labeling for a block, AutoCode
generates the resulting “matrix” as a single-dimensional array, even in Ada.
This means that the output of a matrix-labeled block and the output of a
vector-labeled block are identical, provided the number of elements in the
matrix matches the number in the vector. This paradigm was selected
because it insulates the “user” of a signal from the nature of the signal
source. Imagine trying to generate code for a block and having to first
check whether one or more input arrays are single versus
double-dimensional arrays.
One drawback is that some minor arithmetic must often be done in the
generated code to calculate the proper index expression into the “matrix.”
That is, row and column positions must be flattened to a single-dimensional
index number. The performance impact should be minimal and this
approach has the benefit that all optimizations originally implemented for
vectors now transfer immediately to “matrices,” such as partial reuse of
vectorized signals, with the
-Oreuse
option.
There is no rule that limits the use of matrix labeling to the newly
introduced matrix blocks. You can use matrix labeling on any block
outputs. However, since the matrix labels do not produce two-dimensional
arrays in the generated code, and block functionality is not affected by the
type of label present, it becomes clear that the main benefit of matrix
labeling is in the SystemBuild Editor and Connection Editor. For code
generation purposes, you will see no real performance gain in matrix
labeling over vector labeling. For information on matrix optimization,
refer to the
section of Chapter 7,