LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

unbundle efficiency?

what if any speed/memory penalty is paid by unbundling in a loop as opposed to unbundling outside the loop and wiring directly to the edge? I have a subvi which I pass a cluster containing scalars and arrays, This subvi is called many times during execution and is only read not written to. For my sanity I would prefer to unbundle in the loop if the time penalty is severe. Any advice from the experts?
0 Kudos
Message 1 of 18
(4,590 Views)
slight correction:

I meant....the subvi is called many times during execution and the CLUSTER is unbundled and read not written too, ie. cluster contents never change
0 Kudos
Message 2 of 18
(4,568 Views)
Best would be to run your own benchmark. Wire both alternatives and race them against each other using some simple timing code. 🙂
0 Kudos
Message 3 of 18
(4,542 Views)
Thankyou, that is a valid solution, but I was hoping to gain some insight about efficient Labview Storage and retrieval methods when passing clusters to subVIs. Any advice or links to articles with such information would be most helpful (my searches have not returned much of anything useful yet)
0 Kudos
Message 4 of 18
(4,539 Views)
>> ..but I was hoping to gain some insight about efficient Labview Storage and retrieval methods when passing clusters to subVIs.

Why not use local variables ? Accepted that you will be making a copy of the data, but I still feel that it is much better ( and simpler ) to just unbundle once outside the loop, load the data into local variables and read from these variables wherever there is a need. And as you mention that these are "read only", there should be no confusion.

I do agree that the use of local variables in LV is frowned upon by experts ( like the GOTO instruction in C ). But maybe this is one another place where the locals will come to your rescue ?

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 18
(4,531 Views)

@XCoop wrote:
what if any speed/memory penalty is paid by unbundling in a loop as opposed to unbundling outside the loop and wiring directly to the edge? I have a subvi which I pass a cluster containing scalars and arrays, This subvi is called many times during execution and is only read not written to. For my sanity I would prefer to unbundle in the loop if the time penalty is severe. Any advice from the experts?


Xcoop
The main reason I did not come up with a mode definite answer is the fact that I don't quite understand your description. Is the subVI inside the loop or is the loop inside the subVI? 😉 If the loop is inside the subVI, how many times does the loop run for each subVI call? How big are the arrays in the cluster? Could you attach a simplified example?


@Raghunathan wrote:
Why not use local variables ? Accepted that you will be making a copy of the data, but I still feel that it is much better ( and simpler ) to just unbundle once outside the loop, load the data into local variables and read from these variables wherever there is a need.

Raghunathan
This suggestion makes very little sense to me. I possibly agree with the "unbundle once outside the loop", but why do we need to "load it into a local variables"? Much easier would be to unbundle once outside the loop and wire from there to the nodes that need them. Why would you take a detour via locals if it is already loaded into a wire ;)??? Could you clarify what you meant?
0 Kudos
Message 6 of 18
(4,526 Views)
I would put the unbundle inside the subvi to keep the code of the main vi cleaner.
0 Kudos
Message 7 of 18
(4,518 Views)
altenbach,

my apologies for the incomplete description..I will try again with slightly more background...

This program is part of some image processing vi's I've written to process Laser Induced Fluorescent Pictures I have acquired. (I am full time in fluid dynamics research --->only part time LV wirer :-), so give me a little slack on the LabView Speak -heh)

The Picture Image is converted to a 2D Array and is indexed to every pixel location via a double nested loop. 2D Array size is 1016 x 1000, so a little over a million cycles total. The subvi is inside the doublenested loop and is called each cycle. To clear up some of the clutter from excessive terminals, I would like to pass the subvi a cluster containing all parameters needed for execution. This particular cluster has ten elements of which eight are scalars and two are 1D arrays (1D array lengths are 1016 and 1000 long respectively)

My option is:
1)Unbundle the cluster outside the double nested loop and wire directly to 10 terminals, OR

2) Pass the whole bundle to the subVI itself and unbundle it inside the subVI (1Million+ times)

I guess my question is driving at how LV interprets this when it compiles. Is there a difference? Hopefully I have done a better job of explaining 🙂

Also:
I have been bitten by local variables once before and now only use them in case selects to cut down on duplicate indicators and controls on the front panel, UNLESS I am 100% sure of the execution order.

Thanks Again
0 Kudos
Message 8 of 18
(4,520 Views)
>> Why would you take a detour via locals if it is already loaded into a wire ??? Could you clarify what you meant?

Hi Altenbach,

Of course.

Best would be to directly wire the unbundled data to the node and use it from there. But there are occasions when the same data is required in various functions and "wiring it all the way" into each of the case structures which in turn could be nested, makes it a mess of wires. In such cases is there any harm in using local variables to "transport the data", so to say ? More so when we know that the data is not going to change till we are done with it.

I simply love locals ;-))

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 9 of 18
(4,493 Views)
So it finally boils down to Unbundling a million times Vs Unbundling once.

Unbundling once is going to be messy with many wires. But that is in the background.

I will settle for unbundling once.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 18
(4,491 Views)