09-26-2006 05:32 AM
09-26-2006 05:34 AM
09-26-2006 07:23 AM
09-26-2006 08:15 AM
09-26-2006 10:00 AM
i don't get why the marked wire and the case structure in the attached screenshot shows constant folding. or do i get something wrong?
09-26-2006 10:07 AM - edited 09-26-2006 10:07 AM

Message Edited by Day on 09-26-2006 11:09 AM
09-26-2006 10:13 AM
Yes, that's more or less correct. A non-indexed input tunnel to a loop is effectively a constant with respect to that loop. Here's another thread that discusses this:
http://forums.ni.com/ni/board/message?board.id=170&message.id=202635
09-26-2006 10:24 AM
the documentation says:
"With constant folding, the compiler stores constant values when it compiles VIs instead of calculating them at run time"
the screenshot shows a while loop that runs only once (e.g. for a FGV), but the VI runs many times with different values of the incoming Numeric, so it is impossible to calculate the value of Numeric at compile time....
see the next attchment for another example i don't understand....
09-26-2006 11:30 AM
@chrisger wrote:
the documentation says:
"With constant folding, the compiler stores constant values when it compiles VIs instead of calculating them at run time"
If I understand you right, you're just pointing out an issue with documentation. I agree that the description is maybe a bit too brief:
The full help text is:
LabVIEW uses constant folding to optimize the performance of VIs. With constant folding, the compiler stores constant values when it compiles VIs instead of calculating them at run time. When constants are wired to structures, the compiler calculates the output values of the structures and stores them so they are available at run time.
You can show constant folding on the block diagram by selecting Tools»Options, selecting Block Diagram from the Category list, and placing checkmarks in the Show constant folding of wires and Show constant folding of structures checkboxes. When you place a checkmark in the Show constant folding of wires checkbox, hash marks appear on the wires attached to constants that are constant folded. When you place a checkmark in the Show constant folding of structures checkbox, gray hash marks appear inside structures that are wired to constants. The hash marks might not appear until after you run the VI."
One confusion might be the definition of "compile time" vs. "Run time". As Jeff stated above there is also the case where inputs to a structure (loop, etc) are treated as constants within that structure. Obviously, this must happen at run time whenever that structure is launched from within the code. It is just semantics.
Showing constant folding in this case is also a good learning tool to new users unfamiliar with dataflow. It immediately shows that during the execution of the loop changes in the input will not be seen. 😉 If the control is places inside the loop, the folding disappears.
The only thing we need is another sentence in the help. 🙂
09-26-2006 12:02 PM
doc.: "LabVIEW uses constant folding to optimize the performance of VIs. With constant folding, the compiler stores constant values when it compiles VIs instead of calculating them at run time....."
altenbach. "One confusion might be the definition of "compile time" vs. "Run time". As Jeff stated above there is also the case where inputs to a structure (loop, etc) are treated as constants within that structure. Obviously, this must happen at run time whenever that structure is launched from within the code. It is just semantics."
so when in my example this has to happen at run time (and all is a problem of semantics) i don't understand how the constant folding mechanism can improve performance at all, because in my opinion this is the normal behaviour with no mechanism of constant folding: calculate the value at run time and decide which case to run. i don't see any difference between the two case structures in the attachment.
i'm still convinced that the visualisation of constant folding mechanism in my example is buggy and therefore misleading (espiacially for beginners..).