Chapter 5
Generated Code Architecture
for i = 1:y.size do
y(i) = 0.0;
endif;
endif;
Example 5-17
Generated Code for BlockScript Block Example 5-16
/***** Output Update. *****/
/* ----------------------------
/* {deadbsb..2} */
for (i=1; i<=5; i++) {
deadbsb[-1+i] = U->deadbsb[-1+i]/0.001;
}
Special Directives
Directive
Forces the declaration of the listed variable(s)
{volatile}
in the generated code.
Forces the loop to be unrolled instead of
{unroll}
rolled. Only effective when vectorizing code
or when nesting beyond the 8-level limit.
AutoCode Reference
BlockScript Block */
Notice that in the generated code, only the true-branch of the BlockScript
statement is generated, and that the local variable threshold was
if
hard-coded.
Implicit Type Conversion
Compared to Ada and even C, BlockScript is a very loosely typed
language. Thus, you can ignore most data type issues and focus on the
algorithm. However, when translated to code, there might be excessive data
type conversions that severely penalize performance. NI recommends that
if you want to maximize the performance of the generated code, you
eliminate any implicit conversions in your BlockScript block.
The BlockScript language allows special directives that force certain
attributes or conditions to be applied. Table 5-6 describes the currently
supported directives.
Table 5-6. BlockScript Special Directives
Description
For more information about BlockScript, refer to the BlockScript User
Guide or the MATRIXx Help.
{volatile} integer data;
{unroll} for i = 1:10 do
5-36
Example
ni.com
Need help?
Do you have a question about the AutoCode NI MATRIX and is the answer not in the manual?