LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

constant folding bug

Constant folding does not show when a VI is opened in the Project Explorer. To recreate this bug make sure the show constant folding is set. Create a new VI through the project explorer with some constants. Save the vi. Open the VI without going through the Project explorer, and the constant folding shows. Then close the VI and open it through the Project explorer, the constant folding will not show.
Message 1 of 15
(4,302 Views)
I forgot. LV8.2 full development. Windows XP SP2.
Message 2 of 15
(4,300 Views)
hello Svingen,
 
 
i added your bug already.
 
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 3 of 15
(4,289 Views)
This was reported to R&D (41P6RV1W) for further investigation, thank you for reporting this.  At this time it looks like in order to see the constant folding information you'll need to open the VI outside a project as you've already commented.  Sorry for the inconvenience.
0 Kudos
Message 4 of 15
(4,271 Views)


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?

 

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 5 of 15
(4,256 Views)
I could be wrong, but isn't that because once that wire enters the loop, it's considered constant?  After it passes through the tunnel, there's nothing that will change it.  If you replace it with a shift register that should go away.


Message Edited by Day on 09-26-2006 11:09 AM

Message 6 of 15
(4,254 Views)

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

0 Kudos
Message 7 of 15
(4,240 Views)

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....

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
Download All
0 Kudos
Message 8 of 15
(4,237 Views)


@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:


Constant Folding

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. 🙂

0 Kudos
Message 9 of 15
(4,214 Views)

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..).

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 10 of 15
(4,206 Views)