A For Loop, shown as follows, executes a subdiagram a set number of times.
The count terminal, shown as follows, is an input terminal whose value from outside the loop to the left or top side of the count terminal indicates how many times to repeat the subdiagram.
The iteration terminal, shown as follows, is an output terminal that contains the number of completed iterations.
The iteration count for the For Loop always starts at zero.
Both the count and iteration terminals are 32-bit signed integers. If you wire a floating-point or fixed-point number to the count terminal, LabVIEW rounds it and coerces it to within range. If you wire 0 or a negative number to the count terminal, the loop does not execute and the outputs contain the default data for that data type.
The parallel instances terminal, shown as follows, allows you to specify the number of loop instances LabVIEW uses to run parallel loop iterations.
When you enable parallel loop iterations on a For Loop, LabVIEW creates copies of the For Loop at compile time to run in parallel. At run time, each loop instance requests a chunk, or group, of iterations. Each loop instance then executes the chunk and requests another chunk until no more chunks exist. Because the loop instances execute simultaneously, a For Loop with parallel iterations completes all the iterations more quickly than if they executed serially, or one at a time.
If you wire -1 to the parallel instances terminal on a For Loop, LabVIEW uses all the loop instances to run parallel loop iterations. If you wire 0 to the parallel instances terminal or leave the terminal unwired, LabVIEW determines the number of available logical processors at run time and uses that number of loop instances to run the parallel loop iterations.
The parallel instances terminal can provide the following two types of output:
To determine the meaning of the output of the parallel instances terminal, right-click the terminal and select P Terminal Output from the shortcut menu.
The chunk size terminal, shown as follows, is an input terminal whose value specifies the size of the parallel loop iterations.
Display the chunk size terminal by selecting the Specify partitioning with chunk size (C) terminal option in the For Loop Iteration Parallelism dialog box.