LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does passing unused data through a loop effect memory usage or propagation time?

Solved!
Go to solution

Does it make a difference if unused wire go through a loop rather than around them?

Possibly trivial but I have a large program with lot's of instances of this.

 

 

0 Kudos
Message 1 of 3
(3,332 Views)

You posted your message in the forum for suggesting ideas on how to improve LabVIEW.  You have a regular question asking for help.  I've asked the moderator to move this thread.

 

To answer your question, no it does not matter.  The compiler will handle each one the same way.

0 Kudos
Message 2 of 3
(3,314 Views)
Solution
Accepted by topic author WileECoyote

Yes, it can have an impact.

 

The LV compiler will optimize away *where it can*. But by running unused data through the loop, you're telling the compiler that, for some reason, you want a data dependency between that value and the loop and what is downstream of the loop. So that definitely changes the efficiency of your code by abandoning any operations that could otherwise run in parallel to your loop.

 

But that's performance, and you asked about memory. Yes, it *can* affect memory. It probably does not, but if that wire forks to several places before the loop, by running it through the loop, LabVIEW may create a copy that it would not otherwise, in order to satisfy other optimization constraints.

 

Of course, the reverse is also true. 😉 You might route around the Loop and LV decide to create a copy in order to allow downstream operations to run in parallel with the For Loop (this would occur if the other operation modifies the array, for example).

 

You'll generally be better off letting the compiler do it's job... I recommend wiring that follows your actual data dependencies -- don't make downstream things depend upon the For Loop unless they have to depend upon the For Loop -- and let the LV compiler take care of optimizations. It's way smarter than any of us individually at this point in most situations. Then, when your program is finished, if you have a performance hotspot, you can track that one hotspot down and then argue about whether a *particular* dependency is a good idea or not. 🙂

Message 3 of 3
(3,254 Views)